Пример #1
0
    //AUTHOR : KHIN MYO MYO SHWE
    public void UpdateActingDHead(WCFEmployee e)
    {
        Employee emp = new Employee
        {
            EmpID      = e.Eid,
            DeptCode   = e.DeptCode,
            Role       = e.Role,
            IsTempHead = e.IsTemphead,
            StartDate  = Convert.ToDateTime(e.StartDate),
            EndDate    = Convert.ToDateTime(e.EndDate)
        };

        deptController.UpdateActingDHead(e.DeptCode, e.Eid, e.StartDate, e.EndDate);
    }
Пример #2
0
    protected void BtnUpdate_Click(object sender, EventArgs e)
    {
        if (Session["emp"] != null)
        {
            Employee empSession = (Employee)Session["emp"];
            string   dcode      = empSession.DeptCode;
            string   empRole    = empSession.Role;

            if (dcode != null)
            {
                int cid = deptController.GetCollectionidbyDeptCode(dcode);
                int c   = Convert.ToInt16(ddlCollectionPoint.SelectedValue);


                Employee empDRep     = deptController.GetEmployeeListForDRepSelected(dcode);
                int      empRepid    = empDRep.EmpID;
                string   empRepEmail = empDRep.Email;
                int      empid       = Convert.ToInt16(ddlDRep.SelectedValue);
                Employee newDeptRep  = deptController.GetEmployeeEmailByEid(empid);
                String   newempEmail = newDeptRep.Email;



                if (Convert.ToInt32(ddlActingDHead.SelectedValue) == 0)
                {
                    if (deptController.GetEmployeeListForActingDHeadSelectedCount(dcode) > 0)
                    {
                        int      Aempid           = Convert.ToInt16(ddlActingDHead.SelectedValue);
                        Employee oldDeptTemp      = deptController.GetEmployeeListForActingDHeadSelected(dcode);
                        string   oldDeptTempEmail = oldDeptTemp.Email;



                        string sdate   = txtSDate.Text;
                        string edate   = txtEDate.Text;
                        string lbsdate = lblStartDate.Text;
                        string lbedate = lblEndDate.Text;
                        //lblFax.Text = Aempid.ToString();

                        if (c == cid && empid == empRepid && Aempid == 0 && sdate == "" && edate == "" && lbsdate == "" && lbedate == "")
                        {
                            Response.Redirect(LoginController.DepartmentDetailInfoURI);
                        }
                        else
                        {
                            if (c != cid)
                            {
                                deptController.UpdateCollectionPoint(dcode, c);
                            }
                            if (empid != empRepid)
                            {
                                deptController.UpdateDeptRep(dcode, empid);
                            }
                            if (Aempid != 0 || sdate != "" || edate != "")
                            {
                                Thread emailThreadWithParam = new Thread(() => ADMailNotification(oldDeptTempEmail));
                                emailThreadWithParam.Start();
                            }
                            deptController.UpdateRevoke();

                            Response.Redirect(LoginController.DepartmentDetailInfoURI + "?SuccessMsg=" + "Successfully Updated!!");
                        }
                    }
                    else
                    {
                        int Aempid = Convert.ToInt16(ddlActingDHead.SelectedValue);
                        //Employee newDeptTemp = deptController.GetEmployeeEmailByEid(Aempid);
                        //String newDeptTempEmail = newDeptTemp.Email;
                        string sdate   = txtSDate.Text;
                        string edate   = txtEDate.Text;
                        string lbsdate = lblStartDate.Text;
                        string lbedate = lblEndDate.Text;
                        if (c == cid && empid == empRepid && Aempid == 0 && sdate == "" && edate == "" && lbsdate == "" && lbedate == "")
                        {
                            Response.Redirect(LoginController.DepartmentDetailInfoURI);
                        }
                        else
                        {
                            if (c != cid)
                            {
                                deptController.UpdateCollectionPoint(dcode, c);
                            }
                            if (empid != empRepid)
                            {
                                deptController.UpdateDeptRep(dcode, empid);
                            }

                            Response.Redirect(LoginController.DepartmentDetailInfoURI + "?SuccessMsg=" + "Successfully Updated!!");
                        }
                    }
                }
                else
                {
                    if (deptController.GetEmployeeListForActingDHeadSelectedCount(dcode) > 0)
                    {
                        int Aempid = Convert.ToInt16(ddlActingDHead.SelectedValue);
                        reqForSDate.Enabled         = true;
                        reqForEDate.Enabled         = true;
                        cmpToday.Enabled            = true;
                        cmpStartAndEndDates.Enabled = true;

                        string sdate = txtSDate.Text;
                        string edate = txtEDate.Text;



                        Employee empActingDHead   = deptController.GetEmployeeListForActingDHeadSelected(dcode);
                        int      aid              = empActingDHead.EmpID;
                        string   oldDeptTempEmail = empActingDHead.Email;
                        Employee newDeptTemp      = deptController.GetEmployeeEmailByEid(Aempid);
                        String   newDeptTempEmail = newDeptTemp.Email;
                        string   ssdate           = empActingDHead.StartDate.GetValueOrDefault().ToShortDateString();
                        string   eedate           = empActingDHead.EndDate.GetValueOrDefault().ToShortDateString();
                        string   lbsdate          = lblStartDate.Text;
                        string   lbedate          = lblEndDate.Text;
                        lblFax.Text   = aid.ToString();
                        lblPhone.Text = Aempid.ToString();

                        if (c == cid && empid == empRepid && Aempid == aid && sdate == ssdate && edate == eedate && lbsdate == ssdate && lbedate == eedate)
                        {
                            Response.Redirect(LoginController.DepartmentDetailInfoURI);
                        }
                        else
                        {
                            if (c != cid)
                            {
                                deptController.UpdateCollectionPoint(dcode, c);
                            }
                            if (empid != empRepid)
                            {
                                deptController.UpdateDeptRep(dcode, empid);
                            }
                            if (Aempid != aid || sdate != ssdate || edate != eedate)
                            {
                                Thread emailThreadWithParamnew = new Thread(() => ADNewMailNotification(newDeptTempEmail));
                                emailThreadWithParamnew.Start();
                                Thread emailThreadWithParam = new Thread(() => ADMailNotification(oldDeptTempEmail));
                                emailThreadWithParam.Start();
                            }
                            deptController.UpdateActingDHead(dcode, Aempid, sdate, edate);
                            Response.Redirect(LoginController.DepartmentDetailInfoURI + "?SuccessMsg=" + "Successfully Updated!!");
                        }
                    }
                    else
                    {
                        int      Aempid           = Convert.ToInt16(ddlActingDHead.SelectedValue);
                        Employee newDeptTemp      = deptController.GetEmployeeEmailByEid(Aempid);
                        String   newDeptTempEmail = newDeptTemp.Email;
                        reqForSDate.Enabled         = true;
                        reqForEDate.Enabled         = true;
                        cmpToday.Enabled            = true;
                        cmpStartAndEndDates.Enabled = true;

                        string sdate = txtSDate.Text;
                        string edate = txtEDate.Text;


                        if (c != cid)
                        {
                            deptController.UpdateCollectionPoint(dcode, c);
                        }
                        if (empid != empRepid)
                        {
                            deptController.UpdateDeptRep(dcode, empid);
                        }
                        Thread emailThreadWithParamnew = new Thread(() => ADNewMailNotification(newDeptTempEmail));
                        emailThreadWithParamnew.Start();
                        deptController.UpdateActingDHead(dcode, Aempid, sdate, edate);
                        Response.Redirect(LoginController.DepartmentDetailInfoURI + "?SuccessMsg=" + "Successfully Updated!!");
                    }
                }
            }
            else
            {
                lblMessage.Text = "Update Failed!";
            }
        }
        else
        {
            Utility.logout();
        }
    }