I have an attendance page for employess. Attendance Starts at 9:00 AM. Now, I want after 30 Mintutes, the remaining attendance of the employee should be saved as "ABSENT" autometically as well as attendance page also should be disabled till next date. my code is
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="10"
OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowEditing="GridView1_RowEditing"
OnRowUpdating="GridView1_RowUpdating" Class="table table-striped table-bordered table-hover">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="checkAll" runat="server" onclick="checkAll(this);" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" onclick="Check_Click(this)" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Employee Code">
<ItemTemplate>
<asp:Label ID="lbl_No" runat="server" Text='<%#Eval("EmpCode") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Employee Name">
<ItemTemplate>
<asp:Label ID="lbl_Name" runat="server" Text='<%#Eval("EmpName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Father Phone">
<ItemTemplate>
<asp:Label ID="lbl_Phone" runat="server" Text='<%#Eval("Phone") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="First Name">
<HeaderTemplate>
Attendance Status
</HeaderTemplate>
<ItemTemplate>
<asp:DropDownList ID="ddlRemarks" class="form-control" runat="server">
<asp:ListItem>Present</asp:ListItem>
<asp:ListItem>Absent</asp:ListItem>
<asp:ListItem>Leave</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
int select = 0;
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
{
GridViewRow row = GridView1.Rows[i];
CheckBox Chbox = (CheckBox)row.FindControl("CheckBox1");
if (Chbox.Checked == true)
{
select++;
}
}
if (select == 0)
{
GridView1.Visible = true;
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please Select Record to Save');", true);
}
foreach (GridViewRow g1 in GridView1.Rows)
{
CheckBox chck = g1.FindControl("CheckBox1") as CheckBox;
if (chck.Checked)
{
int success = 0;
con = new SqlDbConnect();
string Dep = ddlClass.SelectedValue.ToString();
DateTime ADate = DateTime.Now;
string No = (g1.FindControl("lbl_No") as Label).Text;
string Name = (g1.FindControl("lbl_Name") as Label).Text;
string FPhone = (g1.FindControl("lbl_Phone") as Label).Text;
string Remarks = (g1.FindControl("ddlRemarks") as DropDownList).Text;
con.SqlQuery("INSERT INTO tblEmpAttendance ([EmpCode],[DepID],[ADate],[Remarks],[Intime],[Outtime]) VALUES (@No,@DId,@ADate,@Rem,@In,@Out)");
con.Cmd.Parameters.AddWithValue("@No", No);
//con.Cmd.Parameters.AddWithValue("@Name", Name);
con.Cmd.Parameters.AddWithValue("@DId", Dep);
con.Cmd.Parameters.AddWithValue("@ADate", ADate.ToString("dd.MM.yyyy"));
con.Cmd.Parameters.AddWithValue("@Rem", Remarks);
con.Cmd.Parameters.AddWithValue("@In", txtTime.Text);
con.Cmd.Parameters.AddWithValue("@Out", txtTime.Text);
con.NonQueryEx();
GridView1.Visible = false;
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('In-Time Attendace Marked successfully');", true);
con.conClose();
}
}