design
<%@ Page Language="C#" MasterPageFile="~/MasterPage/Employee.master" AutoEventWireup="true" CodeFile="Attendance.aspx.cs" Inherits="EmployeeModule_Attendance" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content9" runat="server" contentplaceholderid="ContentReport">
<%--<script type="text/javascript">
function ddd()
{
if(document.getElementById("ddlattendanceslot").value=="0")
{
txttimein.en
}
}
</script>--%>
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
<form runat="server">
<table align="center" style="border-color: #1d599e; height: 50px; border-style: inherit;
border-width: thin; " width="100%">
<tr style="background: #1d599e;">
<td align="center" colspan="4" class="style18">
<span class="style9">
<strong>EMPLOYEE ATTENDANCE MAINTENANCE</strong></span>
</td>
</tr>
<tr>
<td colspan="4" style="height: 5px;" align="left">
<asp:Label ID="Label19" runat="server" Text="To View Attendance:"></asp:Label>
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Click
Here</asp:LinkButton>
</td>
</tr>
</table>
</form>
</asp:View>
<asp:View ID="View2" runat="server">
<form runat="server">
<asp:GridView ID="grdview" runat="server"
AllowSorting="True" AutoGenerateColumns="false" CellPadding="4"
ForeColor="#333333" GridLines="None"
style="height: 189px"
Width="292px">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<%-- <asp:BoundField DataField="Pk" HeaderText="SlNo" />
<asp:BoundField DataField="Date" HeaderText="Date" />
<asp:BoundField DataField="EmployeeId" HeaderText="EmpId" />
<asp:BoundField DataField="EmployeeName" HeaderText="EmpName" />--%>
<asp:TemplateField HeaderText="SlNo">
<ItemTemplate>
<asp:Label ID="lbpppk" runat="server" Text="<%#bind('Pk') %>"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date">
<ItemTemplate>
<asp:Label ID="lbdatee" runat="server" Text="<%#bind('Date') %>"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="EmpId">
<ItemTemplate>
<asp:Label ID="lbeid" runat="server" Text="<%#bind('EmployeeId') %>"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="EmpName">
<ItemTemplate>
<asp:Label ID="lename" runat="server" Text="<%#bind('EmployeeName') %>"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="AttedenceBySlot">
<ItemTemplate>
<asp:DropDownList ID="ddlattendanceslot" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlattendanceslot_SelectedIndexChanged" Width="170px">
<asp:ListItem Value="0">Select</asp:ListItem>
<asp:ListItem Value="1">Morning 9.00-11.00am</asp:ListItem>
<asp:ListItem Value="2">Noon 11.10am-1.00pm</asp:ListItem>
<asp:ListItem Value="3">Afternoon 1.30-3.00pm</asp:ListItem>
<asp:ListItem Value="4">Evening 3.10-6.00pm</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TimeIN">
<ItemTemplate>
<asp:TextBox ID="txttimein" runat="server" Enabled="False" Width="100px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TimeOUT">
<ItemTemplate>
<asp:TextBox ID="txttimeout" runat="server" Enabled="False" Width="100px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SUBMIT">
<ItemTemplate>
<%-- <asp:LinkButton ID="libtn" runat="server" BorderStyle="None"
CommandName="Insert" ForeColor="#0066FF" Width="10px"> Insert</asp:LinkButton>--%>
<asp:Button ID="Button1" runat="server" Text="Button"
onclick="Button1_Click1" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</form>
</asp:View>
</asp:MultiView>
</asp:Content>
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;
public partial class EmployeeModule_Attendance : System.Web.UI.Page
{
REMO obj = new REMO();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
MultiView1.Visible = true;
MultiView1.SetActiveView(View1);
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
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);
grdview.Visible = true;
grdview.DataSource = ds;
grdview.DataBind();
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
grdview.PageIndex = e.NewPageIndex;
Grid();
}
protected void ddlattendanceslot_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox txtin = new TextBox();
TextBox txtout = new TextBox();
DropDownList ddlat = new DropDownList();
foreach (GridViewRow row in grdview.Rows)
{
txtin = (TextBox)(grdview.Rows[row.RowIndex].Cells[5].FindControl("txttimein"));
txtout = (TextBox)(grdview.Rows[row.RowIndex].Cells[6].FindControl("txttimeout"));
ddlat = (DropDownList)(grdview.Rows[row.RowIndex].Cells[4].FindControl("ddlattendanceslot"));
string ddl = ddlat.Text;
if (ddlat.SelectedIndex == 0)
{
txtin.Enabled = false;
txtout.Enabled = false;
}
else
{
txtin.Enabled = true;
txtout.Enabled = true;
}
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Insert")
{
string dsaaa = Convert.ToString(e.CommandArgument);
}
// Grid();
// //GridView gr=grdview.Rows[e.CommandName];
// Label pkk = (Label)grdview.FooterRow.FindControl("lbpk");
// Label date = (Label)grdview.FooterRow.FindControl("lbdatee");
// Label emid = (Label)grdview.FooterRow.FindControl("lbeid");
// Label eename = (Label)grdview.FooterRow.FindControl("lename");
// DropDownList atence = (DropDownList)grdview.FooterRow.FindControl("ddlattendanceslot");
// TextBox tiin = (TextBox)grdview.FooterRow.FindControl("txttimein");
// TextBox tout = (TextBox)grdview.FooterRow.FindControl("txttimeout");
// string ars = "insert into Attendance(Date,EmpID,EmpName,AttendanceSlot,TimeIn,TimeOut) values ('" + date.Text;
// ars += "','" + emid.Text;
// ars += "','" + eename.Text;
// ars += "','" + atence.Text;
// ars += "','" + tiin.Text;
// ars += "','" + tout.Text;
// ars+="')";
// obj.Insert(ars);
}
// }
//}
//protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
//{
//}
protected void Button1_Click1(object sender, EventArgs e)
{
// Grid();
//GridView gr=grdview.Rows[e.CommandName];
Label pkk = (Label)grdview.FooterRow.FindControl("lbpppk");
Label date = (Label)grdview.FooterRow.FindControl("lbdatee");
Label emid = (Label)grdview.FooterRow.FindControl("lbeid");
Label eename = (Label)grdview.FooterRow.FindControl("lename");
DropDownList atence = (DropDownList)grdview.FooterRow.FindControl("ddlattendanceslot");
TextBox tiin = (TextBox)grdview.FooterRow.FindControl("txttimein");
TextBox tout = (TextBox)grdview.FooterRow.FindControl("txttimeout");
string ars = "insert into Attendance(Date,EmpID,EmpName,AttendanceSlot,TimeIn,TimeOut) values ('" + date;
ars += "','" + emid;
ars += "','" + eename;
ars += "','" + atence;
ars += "','" + tiin;
ars += "','" + tout;
ars += "')";
obj.Insert(ars);
}
}
values are not inserted . values cum empty thats d problem int his query
gridview the values are not inserted .