protected void imgbtnEmployeeEdit_Click(object sender, EventArgs e)
        {
            HRM_JOB_TERMINATE objHRM_JOB_TERMINATE = new HRM_JOB_TERMINATE();
            ImageButton       imgbtn = (ImageButton)sender;
            GridViewRow       row    = (GridViewRow)imgbtn.NamingContainer;

            try
            {
                Label lblEmployeeIdId   = (Label)GridViewEMP_TR.Rows[row.RowIndex].FindControl("lblEmployeeIdId");
                Label lblTERMINATE_DATE = (Label)GridViewEMP_TR.Rows[row.RowIndex].FindControl("lblTERMINATE_DATE");
                Label lblStatus         = (Label)GridViewEMP_TR.Rows[row.RowIndex].FindControl("lblStatus");
                Label lblREMARKS        = (Label)GridViewEMP_TR.Rows[row.RowIndex].FindControl("lblREMARKS");
                if (lblEmployeeIdId != null)
                {
                    string OCODE = ((SessionUser)Session["SessionUser"]).OCode;

                    string eId = lblEmployeeIdId.Text;

                    objHRM_JOB_TERMINATE = objEmp_BLL.GetSeparationDate(eId, OCODE);

                    if (objHRM_JOB_TERMINATE != null)
                    {
                        hidEid.Value                = objHRM_JOB_TERMINATE.EID.ToString();
                        hidTerminationid.Value      = objHRM_JOB_TERMINATE.TERMINATE_ID.ToString();
                        txtTerminateDate.Text       = ConvertDate(lblTERMINATE_DATE.Text);
                        drpstatus.SelectedItem.Text = lblStatus.Text;
                        txtRemarks_TRM.Text         = lblREMARKS.Text;

                        if (btnJobTermntSubmit.Text == "Submit")
                        {
                            btnJobTermntSubmit.Text = "Update";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string EID = Convert.ToString(((SessionUser)Session["SessionUser"]).EID);
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }
        protected void btnJobTermntUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                ERPSSLHBEntities  _context = new ERPSSLHBEntities();
                HRM_JOB_TERMINATE obj      = new HRM_JOB_TERMINATE();
                obj.EID                = hidEid.Value;
                obj.TERMINATE_DATE     = Convert.ToDateTime(txtTerminateDate.Text);
                obj.Termination_Status = true;
                obj.REMARKS            = txtRemarks_TRM.Text;
                obj.EDIT_USER          = ((SessionUser)Session["SessionUser"]).UserId;
                obj.EDIT_DATE          = DateTime.Now;
                obj.OCODE              = ((SessionUser)Session["SessionUser"]).OCode;

                if (drpstatus.SelectedItem.ToString() != "------- Select --------")
                {
                    if (drpstatus.SelectedItem.ToString() != "Active")
                    {
                        // int employeeID = Convert.ToInt32(lblHiddenIdTR.Text);
                        //obj.EmpId = employeeID;

                        if (drpstatus.SelectedItem.ToString() == "Resignation")
                        {
                            obj.Status = "Resignation";
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Termination")
                        {
                            obj.Status = "Termination";
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Retirement")
                        {
                            obj.Status = "Retirement";
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Dismissal")
                        {
                            obj.Status = "Dismissal";
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Died")
                        {
                            obj.Status = "Died";
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Dis-Continution")
                        {
                            obj.Status = "Dis-Continution";
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Others")
                        {
                            obj.Status = "Others";
                        }


                        //--------------------------------
                        HRM_PersonalInformations objEmpUpdate = _context.HRM_PersonalInformations.First(x => x.EID == obj.EID);

                        objEmpUpdate.EMP_TERMIN_STATUS          = false;
                        objEmpUpdate.EMP_Retired_Status         = false;
                        objEmpUpdate.EMP_Resignation_Status     = false;
                        objEmpUpdate.EMP_Dismissal_Status       = false;
                        objEmpUpdate.EMP_Died_Status            = false;
                        objEmpUpdate.EMP_Dis_Continution_Status = false;
                        objEmpUpdate.EMP_Other = false;

                        if (drpstatus.SelectedItem.ToString() == "Termination")
                        {
                            objEmpUpdate.EMP_TERMIN_STATUS = true;
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Retirement")
                        {
                            objEmpUpdate.EMP_Retired_Status = true;
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Resignation")
                        {
                            objEmpUpdate.EMP_Resignation_Status = true;
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Dismissal")
                        {
                            objEmpUpdate.EMP_Dismissal_Status = true;
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Died")
                        {
                            objEmpUpdate.EMP_Died_Status = true;
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Dis-Continution")
                        {
                            objEmpUpdate.EMP_Dis_Continution_Status = true;
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Others")
                        {
                            objEmpUpdate.EMP_Other = true;
                        }



                        //  _context.HRM_JOB_TERMINATE.AddObject(obj);



                        _context.SaveChanges();
                        //lblTrMessage.Text = "Record Added successfully!";
                        //lblTrMessage.ForeColor = System.Drawing.Color.Green;
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Separation Successfully!')", true);
                        ClearAll();
                        GetSeparationList();
                    }
                    else
                    {
                        HRM_PersonalInformations objEmpUpdate1 = _context.HRM_PersonalInformations.First(x => x.EID == obj.EID);
                        objEmpUpdate1.EMP_TERMIN_STATUS          = false;
                        objEmpUpdate1.EMP_Retired_Status         = false;
                        objEmpUpdate1.EMP_Resignation_Status     = false;
                        objEmpUpdate1.EMP_Dismissal_Status       = false;
                        objEmpUpdate1.EMP_Died_Status            = false;
                        objEmpUpdate1.EMP_Dis_Continution_Status = false;
                        objEmpUpdate1.EMP_Other = false;

                        HRM_JOB_TERMINATE objEmpUpdate = _context.HRM_JOB_TERMINATE.First(x => x.EID == obj.EID);
                        objEmpUpdate.Status         = "Re-Active";
                        objEmpUpdate.TERMINATE_DATE = Convert.ToDateTime(txtTerminateDate.Text);

                        _context.SaveChanges();
                        //lblTrMessage.Text = "Record Added successfully!";
                        //lblTrMessage.ForeColor = System.Drawing.Color.Green;
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Active Successfully!')", true);
                        ClearAll();
                        GetSeparationList();
                    }
                }
                else
                {
                    //lblTrMessage.Text = "Please Select Status";
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Select Status')", true);
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }
Esempio n. 3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtEid_TRNS.Text == "")
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Input E-ID')", true);
                }
                else if (chewithPreviousData.Checked == false && cheWithoutPreviousData.Checked == false)
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Please Select Condition')", true);
                }
                else
                {
                    ERPSSLHBEntities  _context = new ERPSSLHBEntities();
                    HRM_JOB_TERMINATE obj      = new HRM_JOB_TERMINATE();
                    obj.TERMINATE_DATE = DateTime.Now;
                    obj.REMARKS        = txtRemarks_TRM.Text;
                    obj.EDIT_USER      = ((SessionUser)Session["SessionUser"]).UserId;
                    obj.EDIT_DATE      = DateTime.Now;
                    obj.OCODE          = ((SessionUser)Session["SessionUser"]).OCode;
                    string eid = txtEid_TRNS.Text;

                    if (cheWithoutPreviousData.Text == "Without Previous Data")
                    {
                        List <HRM_LeaveApply> hrm_leaveDetails = _leaveBll.GetLeavesByEID(eid);
                        int result = SaveReactiveLeavetable(hrm_leaveDetails);

                        HRM_PersonalInformations objEmpUpdate1 = _context.HRM_PersonalInformations.First(x => x.EID == eid);
                        objEmpUpdate1.EMP_TERMIN_STATUS          = false;
                        objEmpUpdate1.EMP_Retired_Status         = false;
                        objEmpUpdate1.EMP_Resignation_Status     = false;
                        objEmpUpdate1.EMP_Dismissal_Status       = false;
                        objEmpUpdate1.EMP_Died_Status            = false;
                        objEmpUpdate1.EMP_Dis_Continution_Status = false;
                        objEmpUpdate1.EMP_Other       = false;
                        objEmpUpdate1.Seperation_Date = null;

                        HRM_JOB_TERMINATE objEmpUpdate = _context.HRM_JOB_TERMINATE.First(x => x.EID == eid);

                        objEmpUpdate.Status             = "Re-Active";
                        objEmpUpdate.Termination_Status = false;
                        objEmpUpdate.TERMINATE_DATE     = DateTime.Now;
                        _context.SaveChanges();
                        int reslut = _leaveBll.DeleteLeaveDetailsByEID(eid);
                        //lblTrMessage.Text = "Record Added successfully!";
                        //lblTrMessage.ForeColor = System.Drawing.Color.Green;
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Active Successfully!')", true);
                    }
                    else
                    {
                        HRM_PersonalInformations objEmpUpdate1 = _context.HRM_PersonalInformations.First(x => x.EID == eid);
                        objEmpUpdate1.EMP_TERMIN_STATUS          = false;
                        objEmpUpdate1.EMP_Retired_Status         = false;
                        objEmpUpdate1.EMP_Resignation_Status     = false;
                        objEmpUpdate1.EMP_Dismissal_Status       = false;
                        objEmpUpdate1.EMP_Died_Status            = false;
                        objEmpUpdate1.EMP_Dis_Continution_Status = false;
                        objEmpUpdate1.EMP_Other       = false;
                        objEmpUpdate1.Seperation_Date = null;

                        HRM_JOB_TERMINATE objEmpUpdate = _context.HRM_JOB_TERMINATE.First(x => x.EID == eid);
                        objEmpUpdate.Status             = "Re-Active";
                        objEmpUpdate.Termination_Status = false;
                        objEmpUpdate.TERMINATE_DATE     = DateTime.Now;
                        _context.SaveChanges();
                        //lblTrMessage.Text = "Record Added successfully!";
                        //lblTrMessage.ForeColor = System.Drawing.Color.Green;
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Active Successfully!')", true);
                    }
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }
        //private void BindGridEmployeeTermination()
        //{
        //    try
        //    {
        //     string OCODE = ((SessionUser)Session["SessionUser"]).OCode;

        //        using (ERPSSLHBEntities context = new ERPSSLHBEntities())
        //        {
        //                if (context.HRM_JOB_TERMINATE.Count() > 0)
        //                {
        //                        var query = (from ter in context.HRM_JOB_TERMINATE
        //                                     where ter.OCODE == OCODE
        //                                     select ter).OrderByDescending(ter => ter.TERMINATE_ID);

        //                        GridViewEMP_TR.DataSource = query;
        //                        GridViewEMP_TR.DataBind();
        //                }
        //                else
        //                {
        //                        var obj = new List<HRM_JOB_TERMINATE>();
        //                        obj.Add(new HRM_JOB_TERMINATE());

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

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


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

        //                        //set No Results found to the new added cell
        //               //         GridViewEMP_TR.Rows[0].Cells[0].Text = "NO RECORDS FOUND!";

        //                }
        //        }
        //    }
        //    catch (Exception)
        //    {
        //        throw;
        //    }
        //}

        protected void btnJobTermntSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                HRM_JOB_TERMINATE        obj           = new HRM_JOB_TERMINATE();
                List <HRM_JOB_TERMINATE> jobterminates = new List <HRM_JOB_TERMINATE>();
                string OCODE = ((SessionUser)Session["SessionUser"]).OCode;

                if (drpstatus.SelectedItem.ToString() != "------- Select --------")
                {
                    List <HRM_ATTENDANCE> lstHRM_ATTENDANCE = aAttendance_BLL.GetAttendanceInfo_DateWise(Convert.ToDateTime(txtTerminateDate.Text)).Where(x => x.EID == txtEid_TR.Text && x.Status == "P").ToList();

                    if (lstHRM_ATTENDANCE.Count == 0)
                    {
                        string eid = obj.EID = txtEid_TR.Text;
                        obj.TERMINATE_DATE     = Convert.ToDateTime(txtTerminateDate.Text);
                        obj.REMARKS            = txtRemarks_TRM.Text;
                        obj.EDIT_USER          = ((SessionUser)Session["SessionUser"]).UserId;
                        obj.EDIT_DATE          = DateTime.Now;
                        obj.OCODE              = ((SessionUser)Session["SessionUser"]).OCode;
                        obj.Termination_Status = true;

                        if (drpstatus.SelectedItem.ToString() == "Resignation")
                        {
                            obj.Status = "Resignation";
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Termination")
                        {
                            obj.Status = "Termination";
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Retirement")
                        {
                            obj.Status = "Retirement";
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Dismissal")
                        {
                            obj.Status = "Dismissal";
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Died")
                        {
                            obj.Status = "Died";
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Dis-Continution")
                        {
                            obj.Status = "Dis-Continution";
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Others")
                        {
                            obj.Status = "Others";
                        }
                        //--------------------------------
                        HRM_PersonalInformations objEmpUpdate = context.HRM_PersonalInformations.First(x => x.EID == obj.EID);
                        if (drpstatus.SelectedItem.ToString() == "Termination")
                        {
                            objEmpUpdate.EMP_TERMIN_STATUS = true;
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Retirement")
                        {
                            objEmpUpdate.EMP_Retired_Status = true;
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Resignation")
                        {
                            objEmpUpdate.EMP_Resignation_Status = true;
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Dismissal")
                        {
                            objEmpUpdate.EMP_Dismissal_Status = true;
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Died")
                        {
                            objEmpUpdate.EMP_Died_Status = true;
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Dis-Continution")
                        {
                            objEmpUpdate.EMP_Dis_Continution_Status = true;
                        }
                        else if (drpstatus.SelectedItem.ToString() == "Others")
                        {
                            objEmpUpdate.EMP_Other = true;
                        }

                        objEmpUpdate.Seperation_Date = Convert.ToDateTime(txtTerminateDate.Text);

                        if (btnJobTermntSubmit.Text == "Submit")
                        {
                            int count = (from terminat in context.HRM_JOB_TERMINATE
                                         where terminat.TERMINATE_DATE == obj.TERMINATE_DATE && terminat.EID == obj.EID
                                         select terminat.TERMINATE_DATE).Count();
                            if (count > 0)
                            {
                                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Separation Date Already Exists!')", true);
                                return;
                            }
                            context.HRM_JOB_TERMINATE.AddObject(obj);
                            context.SaveChanges();
                        }
                        else
                        {
                            int    terminationid = Convert.ToInt32(hidTerminationid.Value);
                            string employeeid    = hidEid.Value;
                            var    result        = objEmp_BLL.GetEmployeeDetailsID(employeeid, OCODE).ToList();

                            if (result.Count > 0)
                            {
                                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Active Employee separated information can not be update!')", true);
                                return;
                            }

                            HRM_JOB_TERMINATE objHRM_JOB_TERMINATE = context.HRM_JOB_TERMINATE.First(x => x.TERMINATE_ID == terminationid && x.EID == employeeid);
                            objHRM_JOB_TERMINATE.TERMINATE_DATE = obj.TERMINATE_DATE;
                            objHRM_JOB_TERMINATE.Status         = obj.Status;
                            objHRM_JOB_TERMINATE.REMARKS        = obj.REMARKS;
                            context.SaveChanges();
                        }

                        #region Commented Code

                        //aAttendance_BLL.Delete_Attendance_ByEID_Date(txtEid_TR.Text, Convert.ToDateTime(txtTerminateDate.Text));

                        //DateTime CurrentDate = DateTime.Now;
                        //DateTime SeparationDate = Convert.ToDateTime(txtTerminateDate.Text);

                        //List<HRM_ATTENDANCE> attendences = (from att in context.HRM_ATTENDANCE
                        //                                    where att.EID == eid && (att.Attendance_Date >= SeparationDate && att.Attendance_Date <= CurrentDate)
                        //                                    select att).ToList();

                        //if (attendences.Count > 0)
                        //{
                        //    foreach (HRM_ATTENDANCE aitem in attendences)
                        //    {
                        //        HRM_ATTENDANCE _att = context.HRM_ATTENDANCE.First(a => a.EID == aitem.EID && a.Attendance_Date == aitem.Attendance_Date);

                        //        context.HRM_ATTENDANCE.DeleteObject(_att);
                        //        context.SaveChanges();
                        //    }
                        //}

                        //lblTrMessage.Text = "Record Added successfully!";
                        //lblTrMessage.ForeColor = System.Drawing.Color.Green;
                        #endregion

                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Record Added successfully')", true);
                        jobterminates.Add(obj);
                        GetEmployee_Separation_Details(txtEid_TR.Text, OCODE);

                        ClearAll();
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('This Employee is present in this day!')", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Status!')", true);
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }