Design

<%@ Page Language="C#" MasterPageFile="~/MasterPage/Team Lead.master" AutoEventWireup="true" CodeFile="TimePerformance.aspx.cs" Inherits="TeamLeaderModule_Default" Title="Untitled Page" %>





    contentplaceholderid="FullContentArea">




  
 

    <%----%>

   
   

                           
                    
           
       
     
     <%--  
           

        --%>
       

               
                EMPLOYEE TIME PERFORMANCE

               
                 Click
                Here

           

   

        
     

                                    AllowSorting="True" AutoGenerateColumns="false" CellPadding="4" DataKeyNames="Pk"
                    ForeColor="#333333" GridLines="None"
                  AllowPaging="true" PageSize="3"
                    style="height: 189px"
                    Width="292px"
                    onrowcommand="Gridview1_RowCommand" onrowdatabound="Gridview1_RowDataBound">
                   
                   
                   
                   
                   
                   
                   
                   
                       
                           
                               
                                 

                       

                       
                       
                           
                               
                           

                       

                       
                       
                           
                               
                           

                       

                       
                           
                               
                           

                       

                       
                           
                               
                           

                       

                       
                           
                               
                           

                       

                       
                           
                                                                    AutoPostBack="True" />
                           

                       

                       
                           
                                                                    AutoPostBack="True" ontextchanged="txteffh_TextChanged"/>
                           

                       

                        
                           
                                                                    AutoPostBack="True"/>
                           

                       

                      
                       
                       
                           
                             
                           

                       

                       

                   

             

   
          

          
          
           <%--
           
           
           
           
           
           
           
           
           
           
           

                 
           

               
           

           
           
           
                   
--%>
                                

    










Code

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Globalization;

public partial class TeamLeaderModule_Default : System.Web.UI.Page
{
    REMO obj = new REMO();
    string s=ConfigurationManager.AppSettings["RM"].ToString();
    SqlConnection con;
  
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            MultiView1.SetActiveView(View2);
            Grid();

        }
    }
   


    private void Grid()
    {         
        string q = "select convert([varchar],getdate(),(103)) as Date,Pk,EmployeeId,EmployeeName from EmpPersonal";
        DataSet ds = new DataSet();
        ds = obj.GETDS(q);
        Gridview1.Visible = true;
        Gridview1.DataSource = ds;
        Gridview1.DataBind();
        foreach (GridViewRow gvr in Gridview1.Rows)
        {
           TextBox AttenedHourst = (TextBox)(Gridview1.Rows[gvr.RowIndex].Cells[4].FindControl("txtah"));
            TextBox WorkedHourst = (TextBox)(Gridview1.Rows[gvr.RowIndex].Cells[5].FindControl("txtwh"));
            TextBox EffectiveHourst = (TextBox)(Gridview1.Rows[gvr.RowIndex].Cells[6].FindControl("txteffh"));
            TextBox Differencet = (TextBox)(Gridview1.Rows[gvr.RowIndex].Cells[7].FindControl("txtdfrec"));
            AttenedHourst.Enabled = true;
            WorkedHourst.Enabled = true;
            EffectiveHourst.Enabled = true;
            Differencet.Enabled = true;
        }
    }
        
    protected void Gridview1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Edit")
        {
            LinkButton ll = (LinkButton)e.CommandSource;
            if (ll != null)
            ll.Text = "Submitted";
        }
   }
    protected void Gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
    {    
      if (e.Row.RowType == DataControlRowType.DataRow)
            {
                    con = new SqlConnection(s);
                    con.Open();
                    string emid = ((Label)e.Row.FindControl("lbeid")).Text;
          string EffectiveHours = ((TextBox)e.Row.FindControl("txtwh")).Text;
          string AttenedHours = ((TextBox)e.Row.FindControl("txtah")).Text;
          string WorkedHours = ((TextBox)e.Row.FindControl("txtwh")).Text;
          string Difference = ((TextBox)e.Row.FindControl("txtdfrec")).Text;

                    DataSet ds = new DataSet();
                    string qry = "select HoursWorked from logout where EmployeeId='" + emid + "'";
                   ds= obj.GETDS(qry);
                   con.Close();
                   for(int i=0; i                    {

                   EffectiveHours = ds.Tables[0].Rows[i]["HoursWorked"].ToString();
                   }
                   ((TextBox)e.Row.FindControl("txtwh")).Text = EffectiveHours;
                   //((TextBox)e.Row.FindControl("txtah")).Text = AttenedHours;
                   //((TextBox)e.Row.FindControl("txtwh")).Text = WorkedHours;
                   //((TextBox)e.Row.FindControl("txtdfrec")).Text = Difference;
                      
            }
     
    }







    protected void Button1_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow gvr in Gridview1.Rows)
        {
            string date = ((Label)gvr.FindControl("lbdatee")).Text;
            string emid = ((Label)gvr.FindControl("lbeid")).Text;
            string eename = ((Label)gvr.FindControl("lename")).Text;

            string AttenedHours = ((TextBox)gvr.FindControl("txtah")).Text;
            string WorkedHours = ((TextBox)gvr.FindControl("txtwh")).Text;
            string EffectiveHours = ((TextBox)gvr.FindControl("txteffh")).Text;
            //string Difference = ((TextBox)gvr.FindControl("txtdfrec")).Text;
            string lal5 = ((TextBox)gvr.FindControl("txtdfrec")).Text;
            ((TextBox)gvr.FindControl("txtdfrec")).Text = lal5;
            string ars = "insert into Timeperformamce(Date,EmpID,EmpName,TotalHours) values ('" + date;
            ars += "','" + emid;
            ars += "','" + eename;
            // ars += "','" + atence;
            // ars += "','" + AttenedHours;
            // ars += "','" + WorkedHours;
            // ars += "','" + EffectiveHours;
            ars += "','" + lal5;
            ars += "')";
            obj.Insert(ars);
        }
    }
//    protected void  txtdfrec_TextChanged(object sender, EventArgs e)
//{
//          foreach (GridViewRow gvr in Gridview1.Rows)
//        {
//            string date = ((Label)gvr.FindControl("lbdatee")).Text;
//            string emid = ((Label)gvr.FindControl("lbeid")).Text;
//            string eename = ((Label)gvr.FindControl("lename")).Text;

//            string AttenedHours = ((TextBox)gvr.FindControl("txtah")).Text;
//            string WorkedHours = ((TextBox)gvr.FindControl("txtwh")).Text;
//            string EffectiveHours = ((TextBox)gvr.FindControl("txteffh")).Text;
//            //string Difference = ((TextBox)gvr.FindControl("txtdfrec")).Text;
//            string lal5 = ((TextBox)gvr.FindControl("txtdfrec")).Text;
//            ((TextBox)gvr.FindControl("txtdfrec")).Text = lal5;
//            string ars = "insert into Timeperformamce(Date,EmpID,EmpName,TotalHours) values ('" + date;
//            ars += "','" + emid;
//            ars += "','" + eename;
//            // ars += "','" + atence;
//           // ars += "','" + AttenedHours;
//           // ars += "','" + WorkedHours;
//           // ars += "','" + EffectiveHours;
//            ars += "','" + lal5;
//            ars += "')";
//            obj.Insert(ars);
//        }
//}
protected void  txteffh_TextChanged(object sender, EventArgs e)
{

     foreach (GridViewRow gvr in Gridview1.Rows)
        {
            if(((CheckBox)gvr.FindControl("CheckBox1")).Checked ==true)
                {
            //string date = ((Label)gvr.FindControl("lbdatee")).Text;
            //string emid = ((Label)gvr.FindControl("lbeid")).Text;
            //string eename = ((Label)gvr.FindControl("lename")).Text;

            //string AttenedHours = ((TextBox)gvr.FindControl("txtah")).Text;
            //string WorkedHours = ((TextBox)gvr.FindControl("txtwh")).Text;
            //string EffectiveHours = ((TextBox)gvr.FindControl("txteffh")).Text;
            //string Difference = ((TextBox)gvr.FindControl("txtdfrec")).Text;
            string lal3 = "01-01-0001 " + ((TextBox)gvr.FindControl("txtwh")).Text;
            string lal4 = "01-01-0001 " + ((TextBox)gvr.FindControl("txteffh")).Text;
            string lal5 = ((TextBox)gvr.FindControl("txtdfrec")).Text;

           // string L = System.DateTime.Now.ToString();
           // string Difference = ((TextBox)gvr.FindControl("txtdfrec")).Text;
            DateTime d1 = DateTime.ParseExact(lal3, "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture);
            DateTime d2 = DateTime.ParseExact(lal4, "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture);

            TimeSpan tSpan = d2 - d1;
            lal5 = tSpan.ToString();

            //lal5 = tSpan.Tostring();
            ((TextBox)gvr.FindControl("txtdfrec")).Text = lal5;
              //  int a, b, c;
               // a = int.Parse(lal3);
               // b = int.Parse(lal4);

               // c = (a - b);
               // Difference = c.ToString();
                //((TextBox)gvr.FindControl("txteffh")).Text = EffectiveHours;
                //((TextBox)gvr.FindControl("txtwh")).Text = WorkedHours;
                //((TextBox)gvr.FindControl("txtdfrec")).Text = Difference;

                }

      
}
}
//protected void txteffh_TextChanged(object sender, EventArgs e)
//    {
//        foreach (GridViewRow gvr in Gridview1.Rows)
//        {
//            if(((CheckBox)gvr.FindControl("CheckBox1")).Checked ==true)
//                {
//            //string date = ((Label)gvr.FindControl("lbdatee")).Text;
//            //string emid = ((Label)gvr.FindControl("lbeid")).Text;
//            //string eename = ((Label)gvr.FindControl("lename")).Text;

//            //string AttenedHours = ((TextBox)gvr.FindControl("txtah")).Text;
//            //string WorkedHours = ((TextBox)gvr.FindControl("txtwh")).Text;
//            //string EffectiveHours = ((TextBox)gvr.FindControl("txteffh")).Text;
//            //string Difference = ((TextBox)gvr.FindControl("txtdfrec")).Text;
//            string lal3 = "01-01-0001 " + ((TextBox)gvr.FindControl("txtwh")).Text;
//            string lal4 = "01-01-0001 " + ((TextBox)gvr.FindControl("txteffh")).Text;
//            string lal5 = ((TextBox)gvr.FindControl("txtdfrec")).Text;
//           // string L = System.DateTime.Now.ToString();
//           // string Difference = ((TextBox)gvr.FindControl("txtdfrec")).Text;
//            DateTime d1 = DateTime.ParseExact(lal3, "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture);
//            DateTime d2 = DateTime.ParseExact(lal4, "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture);

//            TimeSpan tSpan = d2 - d1;
//            lal5 = tSpan.ToString();
//            //lal5 = tSpan.Tostring();
//            ((TextBox)gvr.FindControl("txtdfrec")).Text = lal5;
//              //  int a, b, c;
//               // a = int.Parse(lal3);
//               // b = int.Parse(lal4);

//               // c = (a - b);
//               // Difference = c.ToString();
//                //((TextBox)gvr.FindControl("txteffh")).Text = EffectiveHours;
//                //((TextBox)gvr.FindControl("txtwh")).Text = WorkedHours;
//                //((TextBox)gvr.FindControl("txtdfrec")).Text = Difference;

//                }

//        }





//    }
  
}


i need the differece in time is like (01:00:00-00:00:20) if i give 01:00:00 like this the worked hours is retrieve from another table and i give the worked hours it should be subtracted from effective hours . and the time difference should be show in the difference textbox .the value should not be inserted