Esempio n. 1
0
        public void BindEmployeeAttendance()
        {
            LeaveApprovalBl objLeaveApprovalBl = new LeaveApprovalBl();


            var objResult = objLeaveApprovalBl.LeaveApproval_ForReport(Convert.ToInt32(hfSearchName.Value), ddlYear.Text);

            if (objResult.resultDT.Rows.Count > 0)
            {
                gvReport.DataSource = objResult.resultDT;
                gvReport.DataBind();
                gvLeave.DataSource = objResult.resultDT;
                gvLeave.DataBind();

                divReport.Visible                = true;
                btnBack.Visible                  = true;
                btnPrintDetail.Visible           = true;
                pnlStudentAttendanceInfo.Visible = false;
                lblSchoolName.Text               = Session[ApplicationSession.SCHOOLNAME].ToString();
                lblSchool1.Text                  = Session[ApplicationSession.SCHOOLNAME].ToString();
            }
            else
            {
                divReport.Visible                = false;
                btnPrintDetail.Visible           = false;
                pnlStudentAttendanceInfo.Visible = true;
                btnBack.Visible = false;
                ClearAll();
                ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('No Records Found.');", true);
            }
        }
Esempio n. 2
0
        public void BindApprovedLeave()
        {
            ApplicationResult objResult          = new ApplicationResult();
            LeaveApprovalBl   objLeaveApprovalBl = new LeaveApprovalBl();

            if (hfSearchName.Value == "")
            {
                hfSearchName.Value = "0";
            }
            objResult = objLeaveApprovalBl.Approved_Leave_Report(Convert.ToInt32(hfSearchName.Value), txtFromDate.Text, txtToDate.Text);
            if (objResult.resultDT.Rows.Count > 0)
            {
                gvReport.DataSource = objResult.resultDT;
                gvReport.DataBind();
                gvAttendance.DataSource = objResult.resultDT;
                gvAttendance.DataBind();

                divReport.Visible                = true;
                divButtons.Visible               = true;
                btnBack.Visible                  = true;
                btnPrintDetail.Visible           = true;
                pnlStudentAttendanceInfo.Visible = false;
                lblEmployeeName.Text             = txtSearchName.Text == "" ? "All" : txtSearchName.Text;
                lblFromDate.Text                 = txtFromDate.Text;
                lblToDate.Text = txtToDate.Text;
            }
            else
            {
                divReport.Visible                = false;
                btnPrintDetail.Visible           = false;
                pnlStudentAttendanceInfo.Visible = true;
                btnBack.Visible    = false;
                divButtons.Visible = true;
                ClearAll();
                ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('No Records Found.');", true);
            }
        }
Esempio n. 3
0
        protected void btnSave_OnClick(object sender, EventArgs e)
        {
            try
            {
                LeaveApplyBl      objLeaveApplyBl    = new LeaveApplyBl();
                LeaveApplyBo      objLeaveApplyBo    = new LeaveApplyBo();
                LeaveApprovalBo   objLeaveApprovalBo = new LeaveApprovalBo();
                LeaveApprovalBl   objLeaveApprovalBl = new LeaveApprovalBl();
                ApplicationResult objResult          = new ApplicationResult();
                double            dbTotalDays        = 0.0;
                foreach (GridViewRow row in gvLeave.Rows)
                {
                    if (((CheckBox)row.FindControl("cbHalfDay")).Checked)
                    {
                        dbTotalDays += 0.5;
                    }
                    else
                    {
                        dbTotalDays += 1;
                    }
                }

                objLeaveApplyBo.FromDate         = txtFromDate.Text;
                objLeaveApplyBo.ToDate           = txtToDate.Text;
                objLeaveApplyBo.Reason           = txtReason.Text.Trim();
                objLeaveApplyBo.EmployeeMID      = Convert.ToInt32(Session[ApplicationSession.USERID]);
                objLeaveApplyBo.TotalDays        = Convert.ToDouble(dbTotalDays);
                objLeaveApplyBo.CreatedBy        = Convert.ToInt32(Session[ApplicationSession.USERID]);
                objLeaveApplyBo.CreatedDate      = DateTime.UtcNow.AddDays(5.5).ToString();
                objLeaveApplyBo.LastModifiedBy   = Convert.ToInt32(Session[ApplicationSession.USERID]);
                objLeaveApplyBo.LastModifiedDate = DateTime.UtcNow.AddDays(5.5).ToString();

                DatabaseTransaction.OpenConnectionTransation();
                int intLeaveApplyID = 0;
                objResult = objLeaveApplyBl.LeaveApply_Insert(objLeaveApplyBo);
                if (objResult.status == ApplicationResult.CommonStatusType.SUCCESS)
                {
                    //ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record saved successfully.');</script>");
                    //ClearAll();
                    if ((objResult.resultDT.Rows[0]["LeaveApplylID"].ToString()) != "")
                    {
                        intLeaveApplyID = Convert.ToInt32(objResult.resultDT.Rows[0]["LeaveApplylID"].ToString());
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('You have already apply leave between this dates.');</script>");
                        return;
                    }
                }
                int a = 0;
                int b = 0;

                foreach (GridViewRow row in gvLeave.Rows)
                {
                    a += 1;
                    objLeaveApprovalBo.LeaveApplyID     = intLeaveApplyID;
                    objLeaveApprovalBo.ApplyDate        = (((TextBox)row.FindControl("txtGridDates")).Text);
                    objLeaveApprovalBo.LeaveID          = Convert.ToInt32((((DropDownList)row.FindControl("ddlLeaveType")).SelectedValue));
                    objLeaveApprovalBo.IsHalfDay        = Convert.ToInt32((((CheckBox)row.FindControl("cbHalfDay")).Checked));
                    objLeaveApprovalBo.CreatedBy        = Convert.ToInt32(Session[ApplicationSession.USERID]);
                    objLeaveApprovalBo.CreatedDate      = DateTime.UtcNow.AddDays(5.5).ToString();
                    objLeaveApprovalBo.LastModifiedBy   = Convert.ToInt32(Session[ApplicationSession.USERID]);
                    objLeaveApprovalBo.LastModifiedDate = DateTime.UtcNow.AddDays(5.5).ToString();

                    var objResultApproval = objLeaveApprovalBl.LeaveApproval_Insert(objLeaveApprovalBo);
                    if (objResultApproval != null)
                    {
                        if (objResultApproval.status == ApplicationResult.CommonStatusType.SUCCESS)
                        {
                            b += 1;
                        }
                    }
                }
                if (a == b)
                {
                    DatabaseTransaction.CommitTransation();
                    ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Record saved successfully.');</script>");
                    ClearAll();
                    PanelVisibilityMode(1);
                    divLeaveApprove.Visible = true;
                    divDate.Visible         = false;
                    BindApplyLeave();
                }
            }
            catch (Exception ex)
            {
                DatabaseTransaction.RollbackTransation();
                logger.Error("Error", ex);
                ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp",
                                                   "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>");
            }
            finally
            {
                DatabaseTransaction.connection.Close();
            }
        }
        protected void btnSave_OnClick(object sender, EventArgs e)
        {
            try
            {
                LeaveApprovalBo   objLeaveApprovalBo = new LeaveApprovalBo();
                LeaveApprovalBl   objLeaveApprovalBl = new LeaveApprovalBl();
                LeaveApplyBl      objLeaveApplyBl    = new LeaveApplyBl();
                LeaveApplyBo      objLeaveApplyBo    = new LeaveApplyBo();
                ApplicationResult objResult          = new ApplicationResult();
                int a = 0;
                int b = 0;

                if (ViewState["Mode"].ToString() == "Approve")
                {
                    objLeaveApplyBo.LeaveApplylID    = Convert.ToInt32(ViewState["LeaveApplyID"].ToString());
                    objLeaveApplyBo.LastModifiedBy   = Convert.ToInt32(Session[ApplicationSession.USERID].ToString());
                    objLeaveApplyBo.LastModifiedDate = DateTime.UtcNow.AddHours(5.5).ToString();
                    DatabaseTransaction.OpenConnectionTransation();
                    objResult = objLeaveApplyBl.LeaveApply_Update_ForApproval(objLeaveApplyBo);
                    if (objResult.status == ApplicationResult.CommonStatusType.SUCCESS)
                    {
                    }

                    foreach (GridViewRow row in gvLeave.Rows)
                    {
                        a += 1;
                        objLeaveApprovalBo.LeaveApprovalID =
                            Convert.ToInt32(((Label)row.FindControl("lblLeaveApprovalID")).Text);
                        objLeaveApprovalBo.NAReason       = txtReason.Text;
                        objLeaveApprovalBo.LastModifiedBy =
                            Convert.ToInt32(Session[ApplicationSession.USERID].ToString());
                        objLeaveApprovalBo.LastModifiedDate = DateTime.UtcNow.AddHours(5.5).ToString();
                        if (((CheckBox)row.FindControl("cbApprove")).Checked)
                        {
                            objResult = objLeaveApprovalBl.LeaveApproval_Update_ForApproval(objLeaveApprovalBo);
                            if (objResult.status == ApplicationResult.CommonStatusType.SUCCESS)
                            {
                                b += 1;
                            }
                        }
                        else
                        {
                            objResult = objLeaveApprovalBl.LeaveApproval_Update_ForReject(objLeaveApprovalBo);
                            if (objResult.status == ApplicationResult.CommonStatusType.SUCCESS)
                            {
                                b += 1;
                            }
                        }
                    }
                    if (a == b)
                    {
                        DatabaseTransaction.transaction.Commit();
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp",
                                                           "<script>alert('Leave application has been successfully approved or rejected.');</script>");
                        ClearAll();
                        PanelVisibility(1);
                    }
                    else
                    {
                        DatabaseTransaction.RollbackTransation();
                    }
                }
                else if (ViewState["Mode"].ToString() == "Edit")
                {
                    objLeaveApplyBo.LeaveApplylID    = Convert.ToInt32(ViewState["LeaveApplyID"].ToString());
                    objLeaveApplyBo.LastModifiedBy   = Convert.ToInt32(Session[ApplicationSession.USERID].ToString());
                    objLeaveApplyBo.LastModifiedDate = DateTime.UtcNow.AddHours(5.5).ToString();
                    DatabaseTransaction.OpenConnectionTransation();
                    objResult = objLeaveApplyBl.LeaveApply_Update_ForApproval(objLeaveApplyBo);
                    if (objResult.status == ApplicationResult.CommonStatusType.SUCCESS)
                    {
                    }

                    foreach (GridViewRow row in gvLeave.Rows)
                    {
                        a += 1;
                        objLeaveApprovalBo.LeaveApprovalID =
                            Convert.ToInt32(((Label)row.FindControl("lblLeaveApprovalID")).Text);
                        objLeaveApprovalBo.NAReason       = txtReason.Text;
                        objLeaveApprovalBo.LastModifiedBy =
                            Convert.ToInt32(Session[ApplicationSession.USERID].ToString());
                        objLeaveApprovalBo.LastModifiedDate = DateTime.UtcNow.AddHours(5.5).ToString();
                        if (((CheckBox)row.FindControl("cbApprove")).Checked)
                        {
                            objResult = objLeaveApprovalBl.LeaveApproval_Update_ForApproval(objLeaveApprovalBo);
                            if (objResult.status == ApplicationResult.CommonStatusType.SUCCESS)
                            {
                                b += 1;
                            }
                        }
                        else
                        {
                            objResult = objLeaveApprovalBl.LeaveApproval_Update_ForReject(objLeaveApprovalBo);
                            if (objResult.status == ApplicationResult.CommonStatusType.SUCCESS)
                            {
                                b += 1;
                            }
                        }
                    }
                    if (a == b)
                    {
                        DatabaseTransaction.transaction.Commit();
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp",
                                                           "<script>alert('Leave application has been successfully Updated.');</script>");
                        ClearAll();
                        PanelVisibility(1);
                    }
                    else
                    {
                        DatabaseTransaction.RollbackTransation();
                    }
                }
            }
            catch (Exception ex)
            {
                DatabaseTransaction.RollbackTransation();
                logger.Error("Error", ex);
                ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp",
                                                   "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>");
            }
            finally
            {
                DatabaseTransaction.connection.Close();
            }
        }