design
<%@ Page Language="C#" MasterPageFile="~/MasterPage/Team Lead.master" AutoEventWireup="true" CodeFile="TimePerformance.aspx.cs" Inherits="TeamLeaderModule_Default" Title="Untitled Page" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%----%>
<%--
source code is
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;
}
}
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 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 += "','" + 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 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;
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();
((TextBox)gvr.FindControl("txtdfrec")).Text = lal5;
}
}
}
protected void button1_Click(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 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 += "','" + lal5;
ars += "')";
obj.Insert(ars);
}
}
}
}
what wrong in this query it throws the error in this line DateTime d2 = DateTime.ParseExact(lal4, "dd-MM-yyyy HH:mm:ss", CultureInfo.InvariantCulture);
... i need if i give in effective hours as constant (1) need to throw the error

Sandeep Singh ShekhawatPosted Nov 1, 2012, 8:05 AM
Please write error and scenario.
selvi subramanianPosted Nov 1, 2012, 7:08 AM
if i never check the checkbox i need the javascript error and in effective hours i give 2 hours i need the error like (have to enter like 00:00:00).
Sandeep Singh ShekhawatPosted Nov 1, 2012, 3:42 AM
selvi subramanianPosted Nov 1, 2012, 3:26 AM
after i run d i got error An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code Additional information: String was not recognized as a valid DateTime.
Sandeep Singh ShekhawatPosted Nov 1, 2012, 3:21 AM
function err()
{
var timeper=document.getElementById('txteffh').value;
timeper="00:00:00";
var s=timeper.split(':');
return false;
}
and pls write what error are you getting
selvi subramanianPosted Nov 1, 2012, 3:06 AM
Sandeep Singh ShekhawatPosted Nov 1, 2012, 2:44 AM