コード例 #1
0
        protected void btnProcess_Click(object sender, EventArgs e)
        {
            try
            {
                if (chSalaryIncrementStatus.Checked)
                {
                    Attendance_BLL _attendancebll            = new Attendance_BLL();
                    string         eid                       = txtbxEID.Text.Trim();
                    List <HRM_EMPLOYEES_VIEWER> employess    = _attendancebll.GetEmployeesByEid(eid);
                    List <HRM_EMPLOYEES_VIEWER> newemployess = new List <HRM_EMPLOYEES_VIEWER>();

                    foreach (HRM_EMPLOYEES_VIEWER aitem in employess)
                    {
                        HRM_EMPLOYEES_VIEWER aemployee = new HRM_EMPLOYEES_VIEWER();
                        aemployee.EID = aitem.EID;
                        //aemployee.EMP_ID = Convert.ToInt32(aitem.EID);
                        aemployee.EmployeeFullName = aitem.FirstName + " " + aitem.LastName;
                        aemployee.DEG_NAME         = aitem.DEG_NAME;
                        aemployee.DATE_JOINED      = Convert.ToDateTime(aitem.DATE_JOINED);
                        aemployee.Type             = drpEntryType.SelectedValue.ToString();
                        aemployee.IncrementDate    = Convert.ToDateTime(txtDate.Text);
                        aemployee.EffectiveDate    = Convert.ToDateTime(txtbxEffectiveDate.Text);
                        aemployee.PreviousSalary   = aitem.PreviousSalary;
                        aemployee.BasicSalary      = aitem.BasicSalary;

                        if (drpEntryType.SelectedValue.ToString() == "Percentage")
                        {
                            decimal calculateSalary = (Convert.ToDecimal(aitem.BasicSalary) * Convert.ToDecimal(txtbxAmountParcentence.Text)) / 100;
                            aemployee.IncrementAmount     = calculateSalary;
                            aemployee.AfterIncrementSalry = aitem.PreviousSalary + calculateSalary;
                        }
                        else
                        {
                            decimal calculateSalary = Convert.ToDecimal(txtbxAmountParcentence.Text);
                            aemployee.IncrementAmount     = calculateSalary;
                            aemployee.AfterIncrementSalry = aitem.PreviousSalary + calculateSalary;
                        }
                        newemployess.Add(aemployee);
                    }
                    List <HRM_EMPLOYEES_VIEWER> assendingnewemployess = newemployess.ToList();

                    if (assendingnewemployess.Count > 0)
                    {
                        if (chSalaryIncrementStatus.Checked)
                        {
                            grdviewIndivitual.DataSource = assendingnewemployess;
                            grdviewIndivitual.DataBind();
                        }
                        else
                        {
                            grdview.DataSource = assendingnewemployess;
                            grdview.DataBind();
                        }
                    }
                }
                else
                {
                    //if (Convert.ToDateTime(txtDate.Text) > DateTime.Now)
                    //{
                    //    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Attendance Date can not be greater than current date!')", true);
                    //    return;
                    //}
                    if (ddlRegion1.SelectedItem.ToString() == "--Select--")
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Select Region')", true);
                    }
                    else if (txtDate.Text == "")
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Input Date')", true);
                    }
                    else if (drpEntryType.SelectedItem.ToString() == "Select Entry Type")
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Select Entry Type')", true);
                    }

                    else
                    {
                        try
                        {
                            Attendance_BLL _attendancebll = new Attendance_BLL();
                            if (ddlSubSections.SelectedValue.ToString() == "" || ddlSubSections.SelectedValue.ToString() == "0" || ddlSection.SelectedValue.ToString() == "" || ddlSection.SelectedValue.ToString() == "0")
                            {
                                int DeptId = Convert.ToInt32(ddlDept1.SelectedValue);

                                List <HRM_EMPLOYEES_VIEWER> employess    = _attendancebll.GetEmployeeByOfficeID(DeptId, Convert.ToDateTime(txtDate.Text));
                                List <HRM_EMPLOYEES_VIEWER> newemployess = new List <HRM_EMPLOYEES_VIEWER>();

                                foreach (HRM_EMPLOYEES_VIEWER aitem in employess)
                                {
                                    HRM_EMPLOYEES_VIEWER aemployee = new HRM_EMPLOYEES_VIEWER();
                                    aemployee.EID = aitem.EID;
                                    // aemployee.EMP_ID = Convert.ToInt32(aitem.EID);
                                    aemployee.EmployeeFullName = aitem.FirstName + " " + aitem.LastName;
                                    aemployee.DEG_NAME         = aitem.DEG_NAME;
                                    aemployee.DATE_JOINED      = Convert.ToDateTime(aitem.DATE_JOINED);
                                    aemployee.Type             = drpEntryType.SelectedValue.ToString();
                                    aemployee.IncrementDate    = Convert.ToDateTime(txtDate.Text);
                                    aemployee.EffectiveDate    = Convert.ToDateTime(txtbxEffectiveDate.Text);
                                    aemployee.PreviousSalary   = aitem.PreviousSalary;
                                    aemployee.BasicSalary      = aitem.BasicSalary;

                                    if (drpEntryType.SelectedValue.ToString() == "Percentage")
                                    {
                                        decimal calculateSalary = (Convert.ToDecimal(aitem.BasicSalary) * Convert.ToDecimal(txtbxAmountParcentence.Text)) / 100;
                                        aemployee.IncrementAmount     = calculateSalary;
                                        aemployee.AfterIncrementSalry = aitem.PreviousSalary + calculateSalary;
                                    }
                                    else
                                    {
                                        decimal calculateSalary = Convert.ToDecimal(txtbxAmountParcentence.Text);
                                        aemployee.IncrementAmount     = calculateSalary;
                                        aemployee.AfterIncrementSalry = aitem.PreviousSalary + calculateSalary;
                                    }
                                    newemployess.Add(aemployee);
                                }

                                List <HRM_EMPLOYEES_VIEWER> ascendingnewemployees = newemployess.ToList();

                                if (ascendingnewemployees.Count > 0)
                                {
                                    if (chSalaryIncrementStatus.Checked)
                                    {
                                        grdviewIndivitual.DataSource = ascendingnewemployees;
                                        grdviewIndivitual.DataBind();
                                    }
                                    else
                                    {
                                        grdview.DataSource = ascendingnewemployees;
                                        grdview.DataBind();
                                    }
                                }
                            }
                            else
                            {
                                int ResionId  = Convert.ToInt32(ddlRegion1.SelectedValue);
                                int OfficeId  = Convert.ToInt32(ddlOffice1.SelectedValue);
                                int DeptId    = Convert.ToInt32(ddlDept1.SelectedValue);
                                int sction    = Convert.ToInt32(ddlSection.SelectedValue);
                                int subsction = Convert.ToInt32(ddlSubSections.SelectedValue);

                                List <HRM_EMPLOYEES_VIEWER> employess    = _attendancebll.GetEmployeeByRODSSUID(ResionId, OfficeId, DeptId, sction, subsction, Convert.ToDateTime(txtDate.Text));
                                List <HRM_EMPLOYEES_VIEWER> newemployess = new List <HRM_EMPLOYEES_VIEWER>();

                                foreach (HRM_EMPLOYEES_VIEWER aitem in employess)
                                {
                                    HRM_EMPLOYEES_VIEWER aemployee = new HRM_EMPLOYEES_VIEWER();
                                    aemployee.EID = aitem.EID;
                                    // aemployee.EMP_ID = Convert.ToInt32(aitem.EID);
                                    aemployee.EmployeeFullName = aitem.FirstName + " " + aitem.LastName;
                                    aemployee.DEG_NAME         = aitem.DEG_NAME;
                                    aemployee.DATE_JOINED      = Convert.ToDateTime(aitem.DATE_JOINED);
                                    aemployee.Type             = drpEntryType.SelectedValue.ToString();
                                    aemployee.IncrementDate    = Convert.ToDateTime(txtDate.Text);
                                    aemployee.EffectiveDate    = Convert.ToDateTime(txtbxEffectiveDate.Text);
                                    aemployee.PreviousSalary   = aitem.PreviousSalary;
                                    aemployee.BasicSalary      = aitem.BasicSalary;
                                    if (drpEntryType.SelectedValue.ToString() == "Percentage")
                                    {
                                        decimal calculateSalary = (Convert.ToDecimal(aitem.BasicSalary) * Convert.ToDecimal(txtbxAmountParcentence.Text)) / 100;
                                        aemployee.IncrementAmount     = calculateSalary;
                                        aemployee.AfterIncrementSalry = aitem.PreviousSalary + calculateSalary;
                                    }
                                    else
                                    {
                                        decimal calculateSalary = Convert.ToDecimal(txtbxAmountParcentence.Text);
                                        aemployee.IncrementAmount     = calculateSalary;
                                        aemployee.AfterIncrementSalry = aitem.PreviousSalary + calculateSalary;
                                    }
                                    newemployess.Add(aemployee);
                                }
                                List <HRM_EMPLOYEES_VIEWER> assendingnewemployess = newemployess.ToList();

                                if (assendingnewemployess.Count > 0)
                                {
                                    if (chSalaryIncrementStatus.Checked)
                                    {
                                        grdviewIndivitual.DataSource = assendingnewemployess;
                                        grdviewIndivitual.DataBind();
                                    }
                                    else
                                    {
                                        grdview.DataSource = assendingnewemployess;
                                        grdview.DataBind();
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }