Esempio n. 1
0
    protected void OkButton2_Click(object sender, EventArgs e)
    {
        List <ATTEmployeeLeave> lstEmployeeLeave = (List <ATTEmployeeLeave>)Session["EmployeeLeave"];
        ATTEmployeeLeave        objEmp           = lstEmployeeLeave[int.Parse(Session["index"].ToString())];

        if (BLLEmployeeLeaveApprove.LeaveApprove(objEmp))
        {
            this.lblStatusMessage.Text = "Information Saved";
            this.programmaticModalPopup.Show();
        }
    }
    protected void btnAppSubmit_Click1(object sender, EventArgs e)
    {
        try
        {
            List <ATTEmployeeLeave> lstEmployeeLeave = (List <ATTEmployeeLeave>)Session["EmployeeLeave"];
            ATTEmployeeLeave        objEmp           = lstEmployeeLeave[int.Parse(Session["index"].ToString())];
            objEmp.EntryBy = Session["UserName"].ToString();
            if (objEmp.Approved == "N")
            {
                if (BLLEmployeeLeaveApprove.LeaveApprove(objEmp))
                {
                    this.lblStatusMessage.Text = "Employee Leave Approved Successfully";
                    this.programmaticModalPopup.Show();
                    grdRecLeaveApplications.DataSource = BLLEmployeeLeave.GetEmployeeLeave(null, "APP");
                    grdRecLeaveApplications.DataBind();
                }
            }
            else
            {
                List <ATTEmployeeLeave> LSTLvAPP = BLLEmployeeLeaveApprove.LeaveCheck(objEmp);
                if (LSTLvAPP[0].OutMessage != "OK")
                {
                    this.lblStatusMessage2.Text = LSTLvAPP[0].OutMessage;
                    this.programmaticModalPopup2.Show();
                    return;
                }
                else if (LSTLvAPP[0].OutMessage == "OK")
                {
                    if (BLLEmployeeLeaveApprove.LeaveApprove(objEmp))
                    {
                        this.lblStatusMessage.Text = "Employee Leave Approved Successfully";
                        this.programmaticModalPopup.Show();
                        this.CollapsiblePanelExtender1.Collapsed   = true;
                        this.CollapsiblePanelExtender1.ClientState = "true";
                        grdRecLeaveApplications.DataSource         = BLLEmployeeLeave.GetEmployeeLeave(null, "APP");
                        grdRecLeaveApplications.DataBind();
                    }
                }
            }
            ClearControls("Submit");
        }

        catch (Exception ex)
        {
            this.lblStatusMessage.Text = ex.Message.ToString();
            this.programmaticModalPopup.Show();
        }
    }
Esempio n. 3
0
    protected void btnAppSubmit_Click1(object sender, EventArgs e)
    {
        try
        {
            List <ATTEmployeeLeave> lstEmployeeLeave = (List <ATTEmployeeLeave>)Session["EmployeeLeave"];
            ATTEmployeeLeave        objEmp           = lstEmployeeLeave[int.Parse(Session["index"].ToString())];
            objEmp.EntryBy = Session["UserName"].ToString();
            if (objEmp.Approved == "N")
            {
                if (BLLEmployeeLeaveApprove.LeaveApprove(objEmp))
                {
                    this.lblStatusMessage.Text = "Information Saved";
                    this.programmaticModalPopup.Show();
                }
            }
            else
            {
                List <ATTEmployeeLeave> LSTLvAPP = BLLEmployeeLeaveApprove.LeaveCheck(objEmp);
                if (LSTLvAPP[0].OutMessage != "OK")
                {
                    this.lblStatusMessage2.Text = LSTLvAPP[0].OutMessage;
                    this.programmaticModalPopup2.Show();
                }
                else if (LSTLvAPP[0].OutMessage == "OK")
                {
                    if (BLLEmployeeLeaveApprove.LeaveApprove(objEmp))
                    {
                        this.lblStatusMessage.Text = "Information Saved";
                        this.programmaticModalPopup.Show();
                    }
                }
            }

            //if (BLLEmployeeLeave.SaveEmpLeaveApplication(lstEmployeeLeave))
            //{
            //    this.lblStatusMessage.Text = "Information Saved.";
            //    this.programmaticModalPopup.Show();
            //}
            ClearControls("Submit");
        }

        catch (Exception ex)
        {
            this.lblStatusMessage.Text = ex.Message.ToString();
            this.programmaticModalPopup.Show();
        }
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        //int leaveCount=0;
        if (ddlMonth.SelectedIndex <= 0)
        {
            this.lblStatusMessage.Text = "महिना छान्नुहोस्";
            this.programmaticModalPopup.Show();
            return;
        }
        GetCalender();
        GetMonthlyHolidays();
        int sata          = (int)Session["Saturdays_Date"];
        int holidayCounts = (int)Session["MonthlyHolidaysCount"];

        foreach (GridViewRow rw in this.grdAttendance.Rows)
        {
            rw.Cells[36].Text = holidayCounts.ToString();
            rw.Cells[37].Text = sata.ToString();
        }
        int orgid = int.Parse(this.ddlOrganization.SelectedValue.ToString());
        int desid = 0;

        if (this.ddlDesignation.SelectedIndex > 0)
        {
            desid = int.Parse(this.ddlDesignation.SelectedValue.ToString());
        }
//-----------------------------------------------------------------------------------------------------------
        #region Leave

        DataTable dt       = SetDataTable();
        string    FromDate = ddlYear.SelectedValue + "/" + ddlMonth.SelectedValue + "/" + "01";
        string    ToDate   = "";
        if (ddlMonth.SelectedIndex > 0 && ddlMonth.SelectedValue != "12")
        {
            ToDate = ddlYear.SelectedValue + "/" + 00 + (int.Parse(ddlMonth.SelectedValue) + 1) + "/" + "01";
        }
        else if (ddlMonth.SelectedIndex > 0 & ddlMonth.SelectedValue == "12")
        {
            ToDate = (int.Parse(ddlYear.SelectedValue) + 1) + "/" + 00 + (int.Parse(ddlMonth.SelectedValue) + 1) + "/" + "01";
        }
        List <ATTEmployeeLeave> LSTEmpLeave = BLLEmployeeLeaveApprove.GetaApprovedLeave(FromDate, ToDate, orgid, desid);
        List <ATTEmployeeLeave> PersonLv    = new List <ATTEmployeeLeave>();
        foreach (ATTEmployeeLeave lst in LSTEmpLeave)
        {
            bool existed = PersonLv.Exists(
                delegate(ATTEmployeeLeave obj)
            {
                return(obj.EmpID == lst.EmpID);
            }
                );
            if (!existed)
            {
                ATTEmployeeLeave objLeave = new ATTEmployeeLeave();
                objLeave = lst;
                PersonLv.Add(objLeave);
            }
        }
        if (PersonLv.Count > 0)
        {
            foreach (ATTEmployeeLeave lsts in PersonLv)
            {
                DataRow dr = dt.NewRow();

                int i = LSTEmpLeave.FindIndex(delegate(ATTEmployeeLeave obj)
                {
                    return(obj.EmpID == lsts.EmpID);
                }
                                              );

                if (i >= 0)
                {
                    dr[1] = LSTEmpLeave[i].EmpFullName.ToString();
                    dt.Rows.Add(dr);
                }
            }
        }

        if (LSTEmpLeave.Count > 0)
        {
            int k = 0;
            foreach (ATTEmployeeLeave lsts in LSTEmpLeave)
            {
                if (lsts.ApprovedLeaves.Trim() != "")
                {
                    string[] lvs = lsts.ApprovedLeaves.Split(',');
                    for (int j = 0; j < lvs.Length; j++)
                    {
                        if (lvs[j].Length == 1)
                        {
                            lvs[j] = "0" + lvs[j];
                        }
                        dt.Rows[k][lvs[j]] = "L";
                    }
                    dt.Rows[k]["Leave"] = lvs.Length;
                }
                k++;
            }
        }
        else
        {
            DataRow dr = dt.NewRow();
            dt.Rows.Add(dr);
            //GetCalender();
        }

        #endregion

//-----------------------------------------------------------------------------------------------------------
        #region Present

        string yearmonth = this.ddlYear.SelectedValue.ToString() + "/" + ddlMonth.SelectedValue.ToString();
        List <ATTAttendance> LSTAttendance = BLLAttendance.GetEmpAttendance(orgid, desid, yearmonth);
        List <ATTAttendance> Persons       = new List <ATTAttendance>();
        foreach (ATTAttendance lst in LSTAttendance)
        {
            bool existed = Persons.Exists(
                delegate(ATTAttendance obj)
            {
                return(obj.EmpID == lst.EmpID);
            }
                );
            if (!existed)
            {
                ATTAttendance objAttn = new ATTAttendance();
                objAttn = lst;
                Persons.Add(objAttn);
            }
        }
        //DataTable dt = SetDataTable();

        if (Persons.Count > 0)
        {
            foreach (ATTAttendance lst in Persons)
            {
                int i = LSTEmpLeave.FindIndex(delegate(ATTEmployeeLeave obj)
                {
                    return(obj.EmpID == lst.EmpID);
                }
                                              );
                if (i >= 0)
                {
                    //DataRow dr = dt.NewRow();

                    //dt.Rows[i]["FullName"] = lst.EmpFullName.ToString();

                    List <ATTAttendance> LST = LSTAttendance.FindAll(delegate(ATTAttendance obj)
                    {
                        return(lst.EmpID == obj.EmpID);
                    });

                    foreach (ATTAttendance var in LST)
                    {
                        string day = var.PresentDate.Substring((var.PresentDate.LastIndexOf('/') + 1), 2);
                        if (day != null)
                        {
                            dt.Rows[i][day] = "P";
                        }
                    }
                }
            }
        }
        //else
        //{
        //    DataRow dr = dt.NewRow();
        //    dt.Rows.Add(dr);
        //    //GetCalender();
        //}

        #endregion
//-----------------------------------------------------------------------------------------------------------
        string holidays = Session["Month"].ToString();
        //string fromDate=holidays.Substring(1,4) ((str.LastIndexOf('/') + 1), (str.Length - (str.LastIndexOf('/') + 1)));

        int sat          = (int)Session["Saturdays_Date"];
        int holidayCount = (int)Session["MonthlyHolidaysCount"];
        int daysCount    = (int)Session["Days"];
        //int leaveCount = (int)Session["ApprovedLeavesCount"];

        //foreach (GridViewRow rw in this.grdAttendance.Rows)
        //{
        //    //rw.Cells[35].Text = LeaveCount.ToString();
        //    rw.Cells.["Holiday"].Text = holidayCount.ToString();
        //    rw.Cells["Weekend"].Text = sat.ToString();
        //}
        foreach (DataRow rw in dt.Rows)
        {
            int    leaveCount = 0;
            string lvCnt      = rw["Leave"].ToString();
            if (lvCnt != "")
            {
                leaveCount = int.Parse(lvCnt);
            }
            //rw.Cells[35].Text = LeaveCount.ToString();
            rw["Holiday"] = holidayCount.ToString();
            rw["Weekend"] = sat.ToString();
            string workingDays = (daysCount - (holidayCount + sat)).ToString();
            rw["WorkingDays"]   = workingDays;
            Session["WorkDays"] = workingDays;

            foreach (DataColumn dc in dt.Columns)
            {
                string st = rw[dc].ToString().Trim();
                if (st == "")
                {
                    rw[dc] = "A";
                }
            }
            string ACheck = rw["Leave"].ToString().Trim();
            string FCheck = rw["FullName"].ToString().Trim();
            if (ACheck == "A")
            {
                rw["Leave"] = "";
            }
            if (FCheck == "A")
            {
                rw["FullName"] = "";
            }
        }
        int colCount = dt.Columns.Count;
        foreach (DataRow dr in dt.Rows)
        {
            int AbsCount  = 0;
            int PresCount = 0;
            for (int i = 0; i < colCount - 1; i++)
            {
                if (dr[i].ToString() == "A")
                {
                    AbsCount++;
                }
                else if (dr[i].ToString() == "P")
                {
                    PresCount++;
                }
            }
            dr["Absent"]  = AbsCount.ToString();
            dr["Present"] = PresCount.ToString();
        }


        grdAttendance.DataSource = dt;
        grdAttendance.DataBind();
        Session["Data"] = dt;
    }