Пример #1
0
    protected void grdViewAttendanceSummary_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName.Equals("EditRecord"))
            {
                int      attendanceID = 0;
                string[] args         = e.CommandArgument.ToString().Split(new char[] { ':' });
                if (args.Length == 4)
                {
                    if (int.TryParse(args[0], out attendanceID))
                    {
                        hdnfAttendanceID.Value = attendanceID.ToString();
                        string        connection         = Request.Cookies["Company"].Value;
                        string        username           = Request.Cookies["LoggedUserName"].Value;
                        BusinessLogic bl                 = new BusinessLogic(connection);
                        DataSet       dtAttendanceDetail = bl.GetAttendanceDetails(attendanceID, username);
                        if (dtAttendanceDetail != null)
                        {
                            hdnfIsNewAttendance.Value = "0";
                            string status = args[3];

                            // Make attendance details readonly.
                            SetAttendanceDetailsAsReadOnly(status.Equals("Submitted"));


                            ViewState["AttendanceYear"]         = args[1];
                            ViewState["AttendanceMonth"]        = args[2];
                            Session["DtAttendanceDetails"]      = dtAttendanceDetail.Tables[0];
                            GridViewAttendanceDetail.DataSource = dtAttendanceDetail.Tables[0];

                            ChangeGridColumnHeaderText();
                            GridViewAttendanceDetail.DataBind();

                            GridViewAttendanceDetail.Visible = true;
                            AttendanceDetailPopUp.Visible    = true;
                            ModalPopupExtender1.Show();
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }
Пример #2
0
    protected void lnkBtnAddAttendance_Click(object sender, EventArgs e)
    {
        try
        {
            string        connection = Request.Cookies["Company"].Value;
            string        username   = Request.Cookies["LoggedUserName"].Value;
            BusinessLogic bl         = new BusinessLogic(connection);
            if (!bl.IsAttendanceSummaryExists(username, DateTime.Today.Year.ToString(), DateTime.Today.Month.ToString()))
            {
                DataTable dtAttendanceDetails = bl.GetNewAttendanceDetailsForMonth(connection, DateTime.Today.Year, DateTime.Today.Month, username).Tables[0];

                ViewState["AttendanceYear"]         = DateTime.Today.Year.ToString();
                ViewState["AttendanceMonth"]        = DateTime.Today.Month.ToString();
                Session["DtAttendanceDetails"]      = dtAttendanceDetails;
                GridViewAttendanceDetail.DataSource = dtAttendanceDetails;

                ChangeGridColumnHeaderText();
                GridViewAttendanceDetail.DataBind();
                hdnfIsNewAttendance.Value = "1";

                GridViewAttendanceDetail.Visible = true;
                AttendanceDetailPopUp.Visible    = true;
                ModalPopupExtender1.Show();
            }
            else
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(),
                                                    @"alert('Attendance has been already available for the period " + DateTime.Today.ToString("MMM", CultureInfo.InvariantCulture) + "-" + DateTime.Today.Year.ToString() + "');", true);
            }
        }

        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }