void BindGridEmployeeSalaryByOffice()
        {
            try
            {
                string OCODE = ((SessionUser)Session["SessionUser"]).OCode;

                List <Salary_Viewer> empSalary = new List <Salary_Viewer>();

                empSalary = aSalary_Proccess_BLL.Get_SalProccess_TempByOffice(Convert.ToDateTime(txtDateFrom.Text), Convert.ToInt16(ddlOffice.SelectedValue)).ToList();
                if (empSalary.Count > 0)
                {
                    GridViewEMP_AT.DataSource = empSalary.ToList();
                    GridViewEMP_AT.DataBind();
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('No Data Processed!')", true);
                    GridViewEMP_AT.DataSource = null;
                    GridViewEMP_AT.DataBind();
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }
        void BindGridEmployeeAttendanceById(string id)
        {
            string OCODE    = ((SessionUser)Session["SessionUser"]).OCode;
            var    row      = objAtt_BLL.GetAllAttendance(OCODE).ToList();
            var    employee = row.Where(x => x.EID == id && x.Attendance_Date == Convert.ToDateTime(txtAttDate.Text)).ToList();

            GridViewEMP_AT.DataSource = employee;
            GridViewEMP_AT.DataBind();
        }
        void BindGridEmployeeAttendance()
        {
            try
            {
                string OCODE = ((SessionUser)Session["SessionUser"]).OCode;
                //DateTime attDate = Convert.ToDateTime(txtAttDate.Text);

                using (ERPSSLHBEntities context = new ERPSSLHBEntities())
                {
                    if (context.HRM_ATTENDANCE.Count() > 0)
                    {
                        var row = objAtt_BLL.GetAllAttendance(OCODE).ToList();

                        if (row.Count > 0)
                        {
                            GridViewEMP_AT.DataSource = row.ToList();
                            GridViewEMP_AT.DataBind();
                        }
                    }
                    else
                    {
                        var obj = new List <HRM_ATTENDANCE>();
                        obj.Add(new HRM_ATTENDANCE());

                        // Bind the DataTable which contain a blank row to the GridView
                        GridViewEMP_AT.DataSource = obj;
                        GridViewEMP_AT.DataBind();

                        int columnsCount = GridViewEMP_AT.Columns.Count;
                        GridViewEMP_AT.Rows[0].Cells.Clear();                      // clear all the cells in the row
                        GridViewEMP_AT.Rows[0].Cells.Add(new TableCell());         //add a new blank cell
                        GridViewEMP_AT.Rows[0].Cells[0].ColumnSpan = columnsCount; //set the column span to the new added cell

                        GridViewEMP_AT.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
                        GridViewEMP_AT.Rows[0].Cells[0].ForeColor       = System.Drawing.Color.Red;
                        GridViewEMP_AT.Rows[0].Cells[0].Font.Bold       = true;

                        //set No Results found to the new added cell
                        GridViewEMP_AT.Rows[0].Cells[0].Text = "NO RECORDS FOUND!";
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        void BindGridAttendanceByEID()
        {
            try
            {
                string OCODE = ((SessionUser)Session["SessionUser"]).OCode;
                using (ERPSSLHBEntities context = new ERPSSLHBEntities())
                {
                    if (context.HRM_ATTENDANCE.Count() > 0)
                    {
                        var row = objAtt_BLL.GetAttendanceByEID(OCODE, txtEID.Text).ToList();
                        if (row.Count > 0)
                        {
                            GridViewEMP_AT.DataSource = row.ToList();
                            GridViewEMP_AT.DataBind();
                        }
                    }
                    else
                    {
                        var obj = new List <HRM_ATTENDANCE>();
                        obj.Add(new HRM_ATTENDANCE());

                        // Bind the DataTable which contain a blank row to the GridView
                        GridViewEMP_AT.DataSource = obj;
                        GridViewEMP_AT.DataBind();

                        int columnsCount = GridViewEMP_AT.Columns.Count;
                        GridViewEMP_AT.Rows[0].Cells.Clear();                      // clear all the cells in the row
                        GridViewEMP_AT.Rows[0].Cells.Add(new TableCell());         //add a new blank cell
                        GridViewEMP_AT.Rows[0].Cells[0].ColumnSpan = columnsCount; //set the column span to the new added cell

                        GridViewEMP_AT.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
                        GridViewEMP_AT.Rows[0].Cells[0].ForeColor       = System.Drawing.Color.Red;
                        GridViewEMP_AT.Rows[0].Cells[0].Font.Bold       = true;

                        //set No Results found to the new added cell
                        GridViewEMP_AT.Rows[0].Cells[0].Text = "NO RECORDS FOUND!";
                    }
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }
Example #5
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                string        OCODE      = ((SessionUser)Session["SessionUser"]).OCode;
                List <string> ShiftCodes = objAtt_BLL.GetAllShiftCode(OCODE).ToList();
                foreach (string ashiftcode in ShiftCodes)
                {
                    var result = objAtt_BLL.UpdateOT_ByDateandShift(Convert.ToDateTime(txtDateFrom.Text), Convert.ToDateTime(txtDateTo.Text), ashiftcode);
                    if (result == 1)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('OT Processed Successfully')", true);
                        BindGridEmployeeAttendance();
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('OT Processing Failure!')", true);
                        GridViewEMP_AT.DataSource = null;
                        GridViewEMP_AT.DataBind();
                    }
                }

                //ot process log
                DateTime fromdate = Convert.ToDateTime(txtDateFrom.Text.Trim());
                DateTime todate   = Convert.ToDateTime(txtDateTo.Text.Trim());
                Guid     USERID   = ((SessionUser)Session["SessionUser"]).UserId;

                var    ParamempID1 = new SqlParameter("@DateFrom", fromdate);
                var    ParamempID2 = new SqlParameter("@DateTo", todate);
                var    ParamempID3 = new SqlParameter("@Edit_User", USERID);
                var    ParamempID4 = new SqlParameter("@Edit_Date", DateTime.Now);
                var    ParamempID5 = new SqlParameter("@OCODE", OCODE);
                string SP_SQL      = "HRM_Insert_OTProcessLog @DateFrom, @DateTo, @Edit_User, @Edit_Date, @OCODE";
                context.ExecuteStoreCommand(SP_SQL, ParamempID1, ParamempID2, ParamempID3, ParamempID4, ParamempID5);
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                if (GridViewEMP_AT.Rows.Count == 0)
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('No processed salary in the list!')", true);
                    return;
                }

                List <HRM_PaySalary_Temp> aHRM_PaySalary_Temp = new List <HRM_PaySalary_Temp>();
                aHRM_PaySalary_Temp = aSalary_Proccess_BLL.GetSalaryTemp(((SessionUser)Session["SessionUser"]).OCode, Convert.ToDateTime(txtDateFrom.Text));

                foreach (HRM_PaySalary_Temp salary_temp in aHRM_PaySalary_Temp)
                {
                    HRM_Pay_Salary salaryPay = new HRM_Pay_Salary();
                    salaryPay.EmpId              = salary_temp.EmpId;
                    salaryPay.EID                = salary_temp.EID;
                    salaryPay.Worked_Day         = salary_temp.Worked_Day;
                    salaryPay.Total_Day_Of_Month = salary_temp.Total_Day_Of_Month;
                    salaryPay.Over_Time          = salary_temp.Over_Time;
                    salaryPay.OT_Compliance      = salary_temp.OT_Compliance;
                    salaryPay.OT_Extra           = salary_temp.OT_Extra;

                    salaryPay.Work_Holiday    = salary_temp.Work_Holiday;
                    salaryPay.Other_Holiday   = salary_temp.Other_Holiday;
                    salaryPay.Total_Leave     = salary_temp.Total_Leave;
                    salaryPay.Salary_Month    = salary_temp.Salary_Month;
                    salaryPay.Date_Processed  = salary_temp.Date_Processed;
                    salaryPay.Total_Basic_New = salary_temp.Total_Basic_New;
                    salaryPay.Payable_Salary  = salary_temp.Payable_Salary;

                    salaryPay.Total_Gross_Sal_Compliance = salary_temp.Total_Gross_Sal_Compliance;
                    salaryPay.Net_Payable_Compliance     = salary_temp.Net_Payable_Compliance;

                    salaryPay.Total_Gross_Sal          = salary_temp.Total_Gross_Sal;
                    salaryPay.Net_Payable              = salary_temp.Net_Payable;
                    salaryPay.Total_Tax                = salary_temp.Total_Tax;
                    salaryPay.Total_Bonus              = salary_temp.Total_Bonus;
                    salaryPay.Total_LateDeduction_Cost = salary_temp.Total_LateDeduction_Cost;
                    salaryPay.Total_Leave_Cost         = salary_temp.Total_Leave_Cost;
                    salaryPay.Total_Absent_Cost        = salary_temp.Total_Absent_Cost;
                    salaryPay.Pay_Status               = salary_temp.Pay_Status;
                    salaryPay.Edit_User                = salary_temp.Edit_User;
                    salaryPay.Edit_Date                = salary_temp.Edit_Date;
                    salaryPay.OCode   = salary_temp.OCode;
                    salaryPay.OT_Rate = salary_temp.OT_Rate;

                    salaryPay.OT_Compliance_Amount = salary_temp.OT_Compliance_Amount;
                    salaryPay.OT_Extra_Amount      = salary_temp.OT_Extra_Amount;
                    salaryPay.OT_Taka = salary_temp.OT_Taka;

                    salaryPay.Attendance_Bonus = salary_temp.Attendance_Bonus;

                    salaryPay.Total_Deduction            = salary_temp.Total_Deduction;
                    salaryPay.Total_Compliance_Deduction = salary_temp.Total_Compliance_Deduction;

                    salaryPay.P                 = salary_temp.P;
                    salaryPay.L                 = salary_temp.L;
                    salaryPay.SL                = salary_temp.SL;
                    salaryPay.CL                = salary_temp.CL;
                    salaryPay.ML                = salary_temp.ML;
                    salaryPay.AL                = salary_temp.AL;
                    salaryPay.LWP               = salary_temp.LWP;
                    salaryPay.Absent_Day        = salary_temp.Absent_Day;
                    salaryPay.Absent_Deduction  = salary_temp.Absent_Deduction;
                    salaryPay.TotalDeductDay    = salary_temp.TotalDeductDay;
                    salaryPay.Other_Deduction   = salary_temp.Other_Deduction;
                    salaryPay.Salary_Punishment = salary_temp.Salary_Punishment;

                    salaryPay.Night_Bill    = salary_temp.Night_Bill;
                    salaryPay.Holiday_Bill  = salary_temp.Holiday_Bill;
                    salaryPay.Total_Benifit = salary_temp.Total_Benifit;

                    salaryPay.Stamp            = salary_temp.Stamp;
                    salaryPay.AdvanceDeduction = salary_temp.AdvanceDeduction;

                    salaryPay.IsSalaryHeldup = salary_temp.IsSalaryHeldup;

                    //delete previous proccessed dated data
                    //List<HRM_Pay_Salary> paySalaryBydate = aSalary_Proccess_BLL.GetPaySalaryByDate_ByEID(Convert.ToDateTime(txtDateFrom.Text), salaryPay.EID);
                    //if (paySalaryBydate.Count > 0)
                    //{
                    aSalary_Proccess_BLL.DeletePaySalaryByEIDandMonth(salaryPay.EID, Convert.ToDateTime(salaryPay.Salary_Month));
                    //}

                    aSalary_Proccess_BLL.InsertPaySalary(salaryPay);                      // insert salary proccessed data from temp to original table

                    aSalary_Proccess_BLL.DeleteSalaryTemp(salary_temp.PaySalary_Temp_ID); //delete temp table data

                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Salary processed successfully')", true);

                    //txtDateFrom.Text = "";
                    txtDateTo.Text = "";
                    ddlRegion.ClearSelection();
                    ddlOffice.ClearSelection();
                    txtWeekend.Text      = "";
                    txtWeekend1.Text     = "";
                    txtWeekend2.Text     = "";
                    txtTotalDay.Text     = "";
                    txtHoliday.Text      = "";
                    lblTotalPayable.Text = "";

                    GridViewEMP_AT.DataSource = null;
                    GridViewEMP_AT.DataBind();
                }

                // create voucher to temp table

                //string OCODE = ((SessionUser)Session["SessionUser"]).OCode;
                //string Edit_User = ((SessionUser)Session["SessionUser"]).UserId.ToString();
                //string Company_Code = "CMP201507251";
                //string ModuleName = "Payroll";
                //string ModuleType = "Salary";
                //string VoucherType = "JOURNAL";

                //var row = aSalary_Proccess_BLL.GetTotalPayableByDate(Convert.ToDateTime(txtDateFrom.Text)).ToList();
                //if (row.Count > 0)
                //{
                //    var Total = row.First();
                //    aSalary_Proccess_BLL.Enter_VoucherDetailsForTotalSalary(OCODE, Company_Code, Edit_User, ModuleName, ModuleType, VoucherType, Convert.ToDecimal(Total.TotalPayable),"n/a");
                //}
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }
        private void BindGridForBankAdvice()
        {
            try
            {
                string OCODE = ((SessionUser)Session["SessionUser"]).OCode;


                List <BankAdviceRe> Bank1 = new List <BankAdviceRe>();


                if (drpDepartment.SelectedValue != " " && txtDateFrom.Text != "" && txtEid_TRNS.Text == "")
                {
                    string FormDate = txtDateFrom.Text.ToString();
                    //DateTime Todate = Convert.ToDateTime(txtDateFrom.Text.ToString());
                    string dptId = drpDepartment.SelectedValue.ToString();
                    List <BankAdviceRe> Bank2 = new List <BankAdviceRe>();
                    Bank2 = objAtt_BLL.GetBankAdviceByDepartmentId(OCODE, dptId, FormDate).ToList();
                    if (Bank2.Count > 0)
                    {
                        GridViewEMP_AT.DataSource = Bank2.ToList();
                        GridViewEMP_AT.DataBind();
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('No Data Found!')", true);
                    }
                }
                else if (txtDateFrom.Text != "" && txtEid_TRNS.Text != "")
                {
                    string eid      = txtEid_TRNS.Text.ToString();
                    string FormDate = txtDateFrom.Text.ToString();
                    //DateTime Todate = Convert.ToDateTime(txtDateFrom.Text.ToString());
                    List <BankAdviceRe> Bank3 = new List <BankAdviceRe>();
                    Bank3 = objAtt_BLL.GetBankAdviceByEid(OCODE, eid, FormDate).ToList();
                    if (Bank3.Count > 0)
                    {
                        GridViewEMP_AT.DataSource = Bank3.ToList();
                        GridViewEMP_AT.DataBind();
                    }

                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('No Data Found!')", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Item !')", true);
                    //Bank1 = objAtt_BLL.GetBankAdviceAll(OCODE).ToList();
                    //if (Bank1.Count > 0)
                    //{
                    //    GridViewEMP_AT.DataSource = Bank1.ToList();
                    //    GridViewEMP_AT.DataBind();

                    //}
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }
        protected void btnAttSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                Attendance_BLL        _attendancebll = new Attendance_BLL();
                List <HRM_ATTENDANCE> attendances    = new List <HRM_ATTENDANCE>();

                foreach (GridViewRow gvRow in GridViewEMP_AT.Rows)
                {
                    CheckBox rowChkBox = ((CheckBox)gvRow.FindControl("rowLevelCheckBox"));

                    HRM_ATTENDANCE obj = new HRM_ATTENDANCE();

                    if (rowChkBox.Checked == true)
                    {
                        Label   lblId           = ((Label)gvRow.FindControl("lblId"));
                        TextBox txtbxExtraOtAdd = ((TextBox)gvRow.FindControl("OTExtraAdd"));
                        Label   lblAttnDate     = ((Label)gvRow.FindControl("lblAttnDate"));
                        //Label lbltotalot = ((Label)gvRow.FindControl("lbltotalot"));
                        //double totalOT = Convert.ToDouble(lbltotalot.Text);

                        DateTime otDate = Convert.ToDateTime(lblAttnDate.Text);

                        obj.ATTE_ID = Convert.ToInt32(lblId.Text);
                        int AttId = Convert.ToInt32(obj.ATTE_ID);

                        if (rdExtraOT.Checked)
                        {
                            obj.OT_ExtraAdd = Convert.ToInt32(txtbxExtraOtAdd.Text);
                            // obj.OT_Total = totalOT + Convert.ToDouble(txtbxExtraOtAdd.Text);
                        }
                        else if (rdExtraOTDeduct.Checked)
                        {
                            obj.OT_Deduction = Convert.ToInt32(txtbxExtraOtAdd.Text);
                            // obj.OT_Total = totalOT - Convert.ToDouble(txtbxExtraOtAdd.Text);
                        }

                        obj.OCode     = ((SessionUser)Session["SessionUser"]).OCode;
                        obj.Edit_Date = DateTime.Now;
                        obj.Edit_User = ((SessionUser)Session["SessionUser"]).UserId;

                        var result = objAtt_BLL.UpdateAttendanceOT(obj, AttId);

                        if (result == 1)
                        {
                            //ot process

                            string OCODE  = Convert.ToString(((SessionUser)Session["SessionUser"]).OCode);
                            string userId = Convert.ToString(((SessionUser)Session["SessionUser"]).UserId);

                            objAtt_BLL.UpdateOT_ByShift_EID(otDate, otDate, hdnEmployeeShiftCode.Value, txtEid_AT.Text);

                            //ot process log
                            var    ParamempID1 = new SqlParameter("@DateFrom", Convert.ToDateTime(otDate));
                            var    ParamempID2 = new SqlParameter("@DateTo", Convert.ToDateTime(otDate));
                            var    ParamempID3 = new SqlParameter("@Edit_User", userId);
                            var    ParamempID4 = new SqlParameter("@Edit_Date", DateTime.Now);
                            var    ParamempID5 = new SqlParameter("@OCODE", OCODE);
                            string SP_SQL      = "HRM_Insert_OTProcessLog @DateFrom, @DateTo, @Edit_User, @Edit_Date, @OCODE";
                            context.ExecuteStoreCommand(SP_SQL, ParamempID1, ParamempID2, ParamempID3, ParamempID4, ParamempID5);

                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Update Successfully.')", true);

                            // load grid
                            DateTime fromdate = Convert.ToDateTime(txtfromDate.Text);
                            DateTime toDate   = Convert.ToDateTime(txtToDate.Text);

                            var row = objAtt_BLL.GetAttendanceByEID(txtEid_AT.Text).Where(x => x.Attendance_Date >= fromdate && x.Attendance_Date <= toDate).ToList();

                            if (row.Count > 0)
                            {
                                GridViewEMP_AT.DataSource = row.ToList();
                                GridViewEMP_AT.DataBind();
                            }
                            else
                            {
                                GridViewEMP_AT.DataSource = null;
                                GridViewEMP_AT.DataBind();
                            }
                            ///
                        }
                    }
                }
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('No Employee selected in the list!')", true);
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtfromDate.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Input Date!')", true);
                }
                if (txtEid_AT.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Input E-ID!')", true);
                }

                string   OCODE    = ((SessionUser)Session["SessionUser"]).OCode;
                DateTime fromdate = Convert.ToDateTime(txtfromDate.Text);
                DateTime toDate   = Convert.ToDateTime(txtToDate.Text);

                using (ERPSSLHBEntities context = new ERPSSLHBEntities())
                {
                    if (context.HRM_ATTENDANCE.Count() > 0)
                    {
                        var row = objAtt_BLL.GetAttendanceByEID(txtEid_AT.Text).Where(x => x.Attendance_Date >= fromdate && x.Attendance_Date <= toDate).ToList();

                        if (row.Count > 0)
                        {
                            GridViewEMP_AT.DataSource = row.ToList();
                            GridViewEMP_AT.DataBind();
                        }
                        else
                        {
                            GridViewEMP_AT.DataSource = null;
                            GridViewEMP_AT.DataBind();
                        }
                    }
                    else
                    {
                        var obj = new List <HRM_ATTENDANCE>();
                        obj.Add(new HRM_ATTENDANCE());

                        // Bind the DataTable which contain a blank row to the GridView
                        GridViewEMP_AT.DataSource = obj;
                        GridViewEMP_AT.DataBind();

                        int columnsCount = GridViewEMP_AT.Columns.Count;
                        GridViewEMP_AT.Rows[0].Cells.Clear();                      // clear all the cells in the row
                        GridViewEMP_AT.Rows[0].Cells.Add(new TableCell());         //add a new blank cell
                        GridViewEMP_AT.Rows[0].Cells[0].ColumnSpan = columnsCount; //set the column span to the new added cell

                        GridViewEMP_AT.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
                        GridViewEMP_AT.Rows[0].Cells[0].ForeColor       = System.Drawing.Color.Red;
                        GridViewEMP_AT.Rows[0].Cells[0].Font.Bold       = true;

                        //set No Results found to the new added cell
                        GridViewEMP_AT.Rows[0].Cells[0].Text = "NO RECORDS FOUND!";
                    }
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }