Expand|Select|Wrap|Line Numbers
- <asp:Panel ID="pnlScrolls" runat="server" ScrollBars="vertical" Height="600px">
- <asp:GridView ID="gvRegistList" ShowFooter="True" runat="server"
- AutoGenerateColumns="False"
- DataKeyNames="CPR_NO" BorderColor="#999999" RowStyle-BorderStyle="Solid"
- Width="800px" AllowSorting="True"
- RowStyle-BorderWidth="1px" Font-Names="Arial" Font-Size="Medium"
- CellPadding="3" BackColor="White" BorderStyle="Solid"
- BorderWidth="1px" GridLines="Vertical" PageSize="20" AllowPaging="True"
- onpageindexchanging="gvRegistList_PageIndexChanging"
- ForeColor="Black" en >
- <AlternatingRowStyle BackColor="#CCCCCC" />
- <Columns>
- <%-- <asp:ButtonField CommandName="Select" Text="Button" HeaderText="CPR No."
- DataTextField="CPR_NO" SortExpression="nUserID">
- <ItemStyle CssClass="TDStyleLT" HorizontalAlign="Left" />
- <HeaderStyle CssClass="THStyle " HorizontalAlign="Left" />
- </asp:ButtonField>
- <asp:boundfield datafield="name" headertext="Patient Name" readonly="true" />--%>
- <asp:TemplateField HeaderText="CPR No." >
- <ItemTemplate>
- <asp:Label ID="lblCpr" runat="server" Text='<%# Bind("CPR_NO") %>'></asp:Label>
- </ItemTemplate>
- <ItemStyle CssClass="TDStyleLT" HorizontalAlign="Left" />
- <HeaderStyle CssClass="THStyle" HorizontalAlign="Left" />
- </asp:TemplateField>
- <asp:TemplateField HeaderText="NAME" >
- <ItemTemplate>
- <asp:Label ID="lblpatname" runat="server" Text='<%# Bind("NAME") %>'></asp:Label>
- <%--<asp:Label ID="lblCpr" runat="server" Visible="false" Text='<%# Bind("CPR_NO") %>'></asp:Label>--%>
- </ItemTemplate>
- <ItemStyle CssClass="TDStyleLT" HorizontalAlign="Left" />
- <HeaderStyle CssClass="THStyle" HorizontalAlign="Left" />
- </asp:TemplateField>
- <asp:TemplateField HeaderText="DATE" >
- <ItemTemplate>
- <asp:Label ID="lblDate" runat="server" Text='<%# Bind("DATE") %>'></asp:Label>
- </ItemTemplate>
- <ItemStyle CssClass="TDStyleLT" HorizontalAlign="Left" />
- <HeaderStyle CssClass="THStyle" HorizontalAlign="Left" />
- </asp:TemplateField>
- <asp:TemplateField HeaderText="TIME" >
- <ItemTemplate>
- <asp:Label ID="lblTimeIn" runat="server" Text='<%# Bind("TIMEIN") %>'></asp:Label>
- <%--<asp:Label ID="lblTimeIn" runat="server" Text='<%if # Bind("TIME") %>'></asp:Label>--%>
- <%--<asp:Label ID="lbGender" runat="server" Text='<% if(#Eval("NTNAEVENT")='0' { 'Male' else 'Female' }%>'></asp:Label>--%>
- </ItemTemplate>
- <ItemStyle CssClass="TDStyleLT" HorizontalAlign="Left" />
- <HeaderStyle CssClass="THStyle" HorizontalAlign="Left" />
- </asp:TemplateField>
- <asp:TemplateField HeaderText="NTNAEVENT" >
- <ItemTemplate>
- <asp:Label ID="lblTimeOut" runat="server" Text='<%# Bind("TIMEOUT") %>'></asp:Label>
- </ItemTemplate>
- <ItemStyle CssClass="TDStyleLT" HorizontalAlign="Left" />
- <HeaderStyle CssClass="THStyle" HorizontalAlign="Left" />
- </asp:TemplateField>
- </Columns>
- <%-- <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White"/>--%>
- <RowStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px"
- Height="20px" />
- <PagerStyle HorizontalAlign="Center" BackColor="#999999" ForeColor="Black" />
- <FooterStyle BackColor="#CCCCCC" />
- <HeaderStyle BorderColor="#404040" BorderStyle="Solid" BorderWidth="2px"
- Wrap="True" BackColor="Black" Font-Bold="True" ForeColor="White" />
- <PagerSettings NextPageText="Next" PreviousPageText="Previous" Visible="true" />
- <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
- <SortedAscendingCellStyle BackColor="#F1F1F1" />
- <SortedAscendingHeaderStyle BackColor="#808080" />
- <SortedDescendingCellStyle BackColor="#CAC9C9" />
- <SortedDescendingHeaderStyle BackColor="#383838" />
- </asp:GridView>
- </asp:Panel>
- protected void gvRegistList_PageIndexChanging(object sender, GridViewPageEventArgs e)
- {
- //if(gvRegistList.PageIndex != null)
- // {
- // //Use
- gvRegistList.PageIndex = e.NewPageIndex;
- DataList();
- // }
- }
- public void DataList()
- {
- try
- {
- //Label lblCprNo = (Label)
- string strFDay, strFMonth, strFYear, strTDay, strTMonth, strTYear, strFDate, strTDate;
- strFDay = dtpFDate.SelectedDate.ToString().Substring(0, 2);
- strFMonth = dtpFDate.SelectedDate.ToString().Substring(3, 2);
- strFYear = dtpFDate.SelectedDate.ToString().Substring(6, 4);
- strFDate = strFYear + "-" + strFMonth + "-" + strFDay;
- strTDay = dtpTDate.SelectedDate.ToString().Substring(0, 2);
- strTMonth = dtpTDate.SelectedDate.ToString().Substring(3, 2);
- strTYear = dtpTDate.SelectedDate.ToString().Substring(6, 4);
- strTDate = strTYear + "-" + strTMonth + "-" + strTDay;
- DataTable dtSearch = new DataTable("TABLE");
- //dtSearch = attList.Attendance_List(dtpFDate.SelectedDate.ToString().Substring(0, 10), dtpTDate.SelectedDate.ToString().Substring(0, 10), txtCpr.Text.Trim());
- dtSearch = attList.Attendance_List(strFDate, strTDate, txtCpr.Text.Trim());
- if (dtSearch.Rows.Count > 0)
- {
- //gvRegistList.Rows. = dtSearch.Rows.Count;
- gvRegistList.DataSource = GetEmptyDataTableRegList(dtSearch.Rows.Count);
- gvRegistList.DataBind();
- lblMsg.Text = "";
- for (int iCurow = 0; iCurow <= dtSearch.Rows.Count - 1; iCurow++)
- {
- if (dtSearch.Rows[iCurow]["DATE"].ToString().Trim() != InDate.ToString().Trim())
- {
- //string DataId = gvRegistList.Rows[this.gvRegistList.SelectedRows[0].Index].Cells["CPR_NO"].Value.ToString();
- //((Label)gvRegistList.Rows[iCurow].FindControl("lblCpr")).Text = (Convert.IsDBNull(dtSearch.Rows[iCurow]["CPR_NO"]) ? "" : dtSearch.Rows[iCurow]["CPR_NO"].ToString());
- //((Label)gvRegistList.Rows[iCurow].FindControl("lblpatname")).Text = (Convert.IsDBNull(dtSearch.Rows[iCurow]["NAME"]) ? "" : dtSearch.Rows[iCurow]["NAME"].ToString());
- //((Label)gvRegistList.Rows[iCurow].FindControl("lblDate")).Text = (Convert.IsDBNull(dtSearch.Rows[iCurow]["DATE"]) ? "" : dtSearch.Rows[iCurow]["DATE"].ToString());
- PrevTmIn = "";
- PrevTmOut = "";
- for (int jCurow = iCurow; jCurow < dtSearch.Rows.Count - 1 && dtSearch.Rows[iCurow]["DATE"].ToString().Trim() == dtSearch.Rows[jCurow]["DATE"].ToString().Trim(); jCurow++)
- {
- //if (iCurow > intRow)
- //{
- // iCurow = intRow + 1;
- //}
- if (dtSearch.Rows[jCurow]["NTNAEVENT"].ToString().Trim() == "0")// && dtSearch.Rows[iCurow]["DATE"].ToString().Trim() != PrevDate.ToString().Trim()) //"0" -- Time In
- {
- if (PrevTmIn.ToString().Trim() == "")
- {
- ((Label)gvRegistList.Rows[iCurow].FindControl("lblCpr")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["CPR_NO"]) ? "" : dtSearch.Rows[jCurow]["CPR_NO"].ToString());
- ((Label)gvRegistList.Rows[iCurow].FindControl("lblpatname")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["NAME"]) ? "" : dtSearch.Rows[jCurow]["NAME"].ToString());
- ((Label)gvRegistList.Rows[iCurow].FindControl("lblDate")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["DATE"]) ? "" : dtSearch.Rows[jCurow]["DATE"].ToString());
- ((Label)gvRegistList.Rows[iCurow].FindControl("lblTimeIn")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["TIMEIN"]) ? "" : dtSearch.Rows[jCurow]["TIMEIN"].ToString());
- }
- else if (dtSearch.Rows[jCurow]["TIMEIN"].ToString().Trim() != PrevTmIn.ToString().Trim())
- {
- ((Label)gvRegistList.Rows[iCurow + 1].FindControl("lblCpr")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["CPR_NO"]) ? "" : dtSearch.Rows[jCurow]["CPR_NO"].ToString());
- ((Label)gvRegistList.Rows[iCurow + 1].FindControl("lblpatname")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["NAME"]) ? "" : dtSearch.Rows[jCurow]["NAME"].ToString());
- ((Label)gvRegistList.Rows[iCurow + 1].FindControl("lblDate")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["DATE"]) ? "" : dtSearch.Rows[jCurow]["DATE"].ToString());
- ((Label)gvRegistList.Rows[iCurow + 1].FindControl("lblTimeIn")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["TIMEIN"]) ? "" : dtSearch.Rows[jCurow]["TIMEIN"].ToString());
- }
- PrevTmIn = dtSearch.Rows[jCurow]["TIMEIN"].ToString().Trim();
- //intRow = iCurow;
- }
- else if (dtSearch.Rows[jCurow]["NTNAEVENT"].ToString() == "1") //"1" -- Time Out
- {
- if (PrevTmOut.ToString().Trim() == "")
- {
- ((Label)gvRegistList.Rows[iCurow].FindControl("lblCpr")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["CPR_NO"]) ? "" : dtSearch.Rows[jCurow]["CPR_NO"].ToString());
- ((Label)gvRegistList.Rows[iCurow].FindControl("lblpatname")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["NAME"]) ? "" : dtSearch.Rows[jCurow]["NAME"].ToString());
- ((Label)gvRegistList.Rows[iCurow].FindControl("lblDate")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["DATE"]) ? "" : dtSearch.Rows[jCurow]["DATE"].ToString());
- ((Label)gvRegistList.Rows[iCurow].FindControl("lblTimeOut")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["TIMEOUT"]) ? "" : dtSearch.Rows[jCurow]["TIMEOUT"].ToString());
- }
- else if (dtSearch.Rows[jCurow]["TIMEOUT"].ToString().Trim() != PrevTmOut.ToString().Trim())
- {
- ((Label)gvRegistList.Rows[iCurow + 1].FindControl("lblCpr")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["CPR_NO"]) ? "" : dtSearch.Rows[jCurow]["CPR_NO"].ToString());
- ((Label)gvRegistList.Rows[iCurow + 1].FindControl("lblpatname")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["NAME"]) ? "" : dtSearch.Rows[jCurow]["NAME"].ToString());
- ((Label)gvRegistList.Rows[iCurow + 1].FindControl("lblDate")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["DATE"]) ? "" : dtSearch.Rows[jCurow]["DATE"].ToString());
- ((Label)gvRegistList.Rows[iCurow + 1].FindControl("lblTimeOut")).Text = (Convert.IsDBNull(dtSearch.Rows[jCurow]["TIMEOUT"]) ? "" : dtSearch.Rows[jCurow]["TIMEOUT"].ToString());
- }
- PrevTmOut = dtSearch.Rows[jCurow]["TIMEOUT"].ToString().Trim();
- }
- PrevDate = dtSearch.Rows[jCurow]["DATE"].ToString();
- }
- intRow = iCurow;
- }
- InDate = dtSearch.Rows[iCurow]["DATE"].ToString();
- //((Label)gvRegistList.Rows[iCurow].FindControl("lblCpr")).Text = (Convert.IsDBNull(dtSearch.Rows[iCurow]["CPR_NO"]) ? "" : dtSearch.Rows[iCurow]["CPR_NO"].ToString());
- }
- //gvRegistList.DataSource = dtSearch;
- //gvRegistList.DataBind();
- }
- else
- {
- lblMsg.Text = "No Records Available.";
- gvRegistList.DataSource = GetEmptyDataTableRegList(20);
- gvRegistList.DataBind();
- }
- }
- catch (Exception ex)
- {
- lblMsg.Text = "Exception caught here: " + ex.ToString();
- }
- }