Пример #1
0
        void ckh_Click(object sender, RoutedEventArgs e)
        {
            CheckBox chk = sender as CheckBox;
            var ent = dgEmployeeList.SelectedItem as PersonnelWS.V_EMPLOYEEVIEW;

            var tmps = from n in SelectedEmployees
                       where n.EMPLOYEEID == ent.EMPLOYEEID
                       select n;

            //这里判断了,但是可能会导致存入不了相同EMPLOYEEID的数据,例如一个员工有两个岗位,
            //那么后面就会只有一条数据,所以注释掉
            //bool bIsNotExists = false;
            //if (tmps != null)
            //{
            //    if (tmps.Count() > 0)
            //    {
            //        bIsNotExists = true;
            //    }
            //}

            //PersonnelWS.T_HR_EMPLOYEE temp = new PersonnelWS.T_HR_EMPLOYEE();
            //temp.EMPLOYEEID = ent.EMPLOYEEID;
            //temp.EMPLOYEECNAME = ent.EMPLOYEECNAME;
            //temp.EMPLOYEECODE = ent.EMPLOYEECODE;
            //temp.SEX = ent.SEX;
            //temp.IDNUMBER = ent.IDNUMBER;
            //temp.OWNERCOMPANYID = ent.OWNERCOMPANYID;
            //temp.OWNERDEPARTMENTID = ent.OWNERDEPARTMENTID;
            //temp.OWNERPOSTID = ent.OWNERPOSTID;


            /// <summary>
            /// Modify Desc:在信息的处理中,在初始值中不能加入列表选择信息,所以在checkbox选择中
            ///             进行数据加入和移除,然后传入到初始值中进行初始化,而且也要注意不同表单
            ///             要传入的值可能不一样,这是目前发现用到的信息,以后有需要可继续加入
            /// Modify Date:2012-8-8

            //信息存入视图
            PersonnelWS.V_EMPLOYEEVIEW temp = new PersonnelWS.V_EMPLOYEEVIEW();
            temp.EMPLOYEEID = ent.EMPLOYEEID;
            temp.EMPLOYEECNAME = ent.EMPLOYEECNAME;
            temp.EMPLOYEECODE = ent.EMPLOYEECODE;
            temp.SEX = ent.SEX;
            temp.IDNUMBER = ent.IDNUMBER;
            temp.OWNERCOMPANYID = ent.OWNERCOMPANYID;
            temp.OWNERDEPARTMENTID = ent.OWNERDEPARTMENTID;
            temp.OWNERPOSTID = ent.OWNERPOSTID;
            temp.ISAGENCY = ent.ISAGENCY;
            temp.POSTLEVEL = ent.POSTLEVEL;
            temp.EMPLOYEEPOSTID = ent.EMPLOYEEPOSTID;
            temp.COMPANYNAME = ent.COMPANYNAME;
            temp.DEPARTMENTNAME = ent.DEPARTMENTNAME;
            temp.POSTNAME = ent.POSTNAME;
            temp.MOBILE = ent.MOBILE;
            temp.OFFICEPHONE = ent.OFFICEPHONE;

            //存入数据到V_EMPLOYEEVIEW视图和部门,岗位表
            PersonnelWS.V_EMPLOYEEVIEW vTemp = new PersonnelWS.V_EMPLOYEEVIEW();
            vTemp.EMPLOYEEID = ent.EMPLOYEEID;
            vTemp.EMPLOYEECNAME = ent.EMPLOYEECNAME;
            vTemp.EMPLOYEECODE = ent.EMPLOYEECODE;
            vTemp.SEX = ent.SEX;
            vTemp.IDNUMBER = ent.IDNUMBER;
            vTemp.OWNERCOMPANYID = ent.OWNERCOMPANYID;
            vTemp.OWNERDEPARTMENTID = ent.OWNERDEPARTMENTID;
            vTemp.OWNERPOSTID = ent.OWNERPOSTID;
            vTemp.DEPARTMENTNAME = ent.DEPARTMENTNAME;
            vTemp.POSTNAME = ent.POSTNAME;
            vTemp.POSTLEVEL = ent.POSTLEVEL;
            vTemp.ISAGENCY = ent.ISAGENCY;
            vTemp.EMPLOYEEPOSTID = ent.EMPLOYEEPOSTID;
            vTemp.MOBILE = ent.MOBILE;
            vTemp.OFFICEPHONE = ent.OFFICEPHONE;

            //信息存入PersonnelWS.T_HR_POSTDICTIONARY里
            PersonnelWS.T_HR_POSTDICTIONARY postDicTemp = new PersonnelWS.T_HR_POSTDICTIONARY();
            postDicTemp.POSTNAME = ent.POSTNAME;
            postDicTemp.POSTLEVEL = ent.POSTLEVEL;

            //信息存入PersonnelWS.T_HR_DEPARTMENTDICTIONARY里
            PersonnelWS.T_HR_DEPARTMENTDICTIONARY departmentTemp = new PersonnelWS.T_HR_DEPARTMENTDICTIONARY();
            departmentTemp.DEPARTMENTNAME = ent.DEPARTMENTNAME;


            //把信息存入PersonnelWS.T_HR_POST,然后再把PersonnelWS.T_HR_POST数据存入PersonnelWS.T_HR_EMPLOYEEPOST
            //最后把数据存入PersonnelWS.T_HR_EMPLOYEEPOST
            //注意他们之间数据类型转换
            PersonnelWS.T_HR_POST tempPerWSPost = new PersonnelWS.T_HR_POST();
            tempPerWSPost.POSTLEVEL = ent.POSTLEVEL;
            tempPerWSPost.POSTID = ent.OWNERPOSTID;


            PersonnelWS.T_HR_EMPLOYEE tempEmployee = new PersonnelWS.T_HR_EMPLOYEE();
            tempEmployee.EMPLOYEECNAME = ent.EMPLOYEECNAME;
            tempEmployee.EMPLOYEEID = ent.EMPLOYEEID;
            tempEmployee.EMPLOYEEENAME = ent.EMPLOYEEENAME;
            tempEmployee.EMPLOYEECODE = ent.EMPLOYEECODE;

            //把PersonnelWS.T_HR_EMPLOYEEPOST信息存入,有些表单可能会用到
            PersonnelWS.T_HR_EMPLOYEEPOST tempPerWSEmployeePost = new PersonnelWS.T_HR_EMPLOYEEPOST();
            tempPerWSEmployeePost.EMPLOYEEPOSTID = ent.EMPLOYEEPOSTID;
            tempPerWSEmployeePost.ISAGENCY = ent.ISAGENCY;
            tempPerWSEmployeePost.POSTLEVEL = ent.POSTLEVEL;
            tempPerWSEmployeePost.T_HR_POST = tempPerWSPost;
            tempPerWSEmployeePost.T_HR_EMPLOYEE = tempEmployee;



            try
            {
                if (chk.IsChecked.Value)
                {
                    //if (!bIsNotExists)
                    //{
                    //单多选进行判断,这段代码目前是为了解决员工考勤方案分配时,
                    //同一员工的考勤分配,一个人有两个岗位情况,那么只算一个考勤分配
                    //到底分配什么考勤方案,那就看情况,目前还不懂考勤分配
                    if (this.MultiSelected == true)
                    {
                        if (SelectedEmployees.Count() == 0)
                        {
                            SelectedDepartment.Add(departmentTemp);
                            SelectedPost.Add(postDicTemp);
                            SelectedEmployees.Add(temp);
                            SelectedPersonnelEmloyeePostNew.Add(tempPerWSEmployeePost);
                        }
                        else
                        {

                            for (int i = 0; i < SelectedEmployees.Count(); i++)
                            {
                                //岗位一样则只算一个,这个地方想了好久的逻辑
                                if (SelectedEmployees[i].EMPLOYEEID == temp.EMPLOYEEID && SelectedEmployees[i].EMPLOYEECNAME==temp.EMPLOYEECNAME)
                                {
                                    break;
                                }
                                if (i == SelectedEmployees.Count() - 1)
                                {
                                    //加入字典信息这两个没有用到,写着为了测试盒调试使用,以后可能有用
                                    SelectedDepartment.Add(departmentTemp);
                                    SelectedPost.Add(postDicTemp);
                                    SelectedEmployees.Add(temp);
                                    SelectedPersonnelEmloyeePostNew.Add(tempPerWSEmployeePost);
                                }
                               
                            }
                        }
                    }
                    if (this.MultiSelected == false)
                    {
                        SelectedDepartment.Add(departmentTemp);
                        SelectedPost.Add(postDicTemp);
                        SelectedEmployees.Add(temp);
                        SelectedPersonnelEmloyeePostNew.Add(tempPerWSEmployeePost);
                    }
                    //}
                }
                else
                {
                    //这里显然是个悲剧,原始的移除根本不起作用,所以在这加个判断,
                    //如果信息一致就移除相应序号的信息,考虑到一个人可能有几个岗位
                    //所以这里不仅要判断员工ID还要判断部门ID和岗位ID,我就不信这人
                    //在一个部门里面还有两个岗位,如果有那他可能就是程序员兼客服兼测试……
                    //那就没办法了
                    for (int i = 0; i < SelectedEmployees.Count(); i++)
                    {
                        if ((SelectedEmployees[i].EMPLOYEEID == temp.EMPLOYEEID) && (SelectedEmployees[i].OWNERDEPARTMENTID == temp.OWNERDEPARTMENTID) && (SelectedEmployees[i].OWNERPOSTID == temp.OWNERPOSTID))
                        {
                            SelectedDepartment.Remove(departmentTemp);
                            SelectedPost.Remove(postDicTemp);
                            SelectedEmployees.RemoveAt(i);
                            SelectedPersonnelEmloyeePostNew.RemoveAt(i);
                        }
                    }

                }
            }
            catch (Exception ex)
            {
                Utility.ShowCustomMessage(MessageTypes.Caution, Utility.GetResourceStr("CAUTION"), "数据存入缓存错误,可关掉重新选择");
            }
            //if (chk.IsChecked.Value)
            //{
            //    if (!bIsNotExists)
            //    {
            //        SelectedEmployees.Add(temp);
            //    }
            //}
            //else
            //{
            //    if (bIsNotExists)
            //    {
            //        SelectedEmployees.Remove(temp);
            //    }
            //}
        }
Пример #2
0
        void ckh_Click(object sender, RoutedEventArgs e)
        {
            CheckBox chk = sender as CheckBox;
            var      ent = dgEmployeeList.SelectedItem as PersonnelWS.V_EMPLOYEEVIEW;

            var tmps = from n in SelectedEmployees
                       where n.EMPLOYEEID == ent.EMPLOYEEID
                       select n;

            //这里判断了,但是可能会导致存入不了相同EMPLOYEEID的数据,例如一个员工有两个岗位,
            //那么后面就会只有一条数据,所以注释掉
            //bool bIsNotExists = false;
            //if (tmps != null)
            //{
            //    if (tmps.Count() > 0)
            //    {
            //        bIsNotExists = true;
            //    }
            //}

            //PersonnelWS.T_HR_EMPLOYEE temp = new PersonnelWS.T_HR_EMPLOYEE();
            //temp.EMPLOYEEID = ent.EMPLOYEEID;
            //temp.EMPLOYEECNAME = ent.EMPLOYEECNAME;
            //temp.EMPLOYEECODE = ent.EMPLOYEECODE;
            //temp.SEX = ent.SEX;
            //temp.IDNUMBER = ent.IDNUMBER;
            //temp.OWNERCOMPANYID = ent.OWNERCOMPANYID;
            //temp.OWNERDEPARTMENTID = ent.OWNERDEPARTMENTID;
            //temp.OWNERPOSTID = ent.OWNERPOSTID;


            /// <summary>
            /// Modify Desc:在信息的处理中,在初始值中不能加入列表选择信息,所以在checkbox选择中
            ///             进行数据加入和移除,然后传入到初始值中进行初始化,而且也要注意不同表单
            ///             要传入的值可能不一样,这是目前发现用到的信息,以后有需要可继续加入
            /// Modify Date:2012-8-8

            //信息存入视图
            PersonnelWS.V_EMPLOYEEVIEW temp = new PersonnelWS.V_EMPLOYEEVIEW();
            temp.EMPLOYEEID        = ent.EMPLOYEEID;
            temp.EMPLOYEECNAME     = ent.EMPLOYEECNAME;
            temp.EMPLOYEECODE      = ent.EMPLOYEECODE;
            temp.SEX               = ent.SEX;
            temp.IDNUMBER          = ent.IDNUMBER;
            temp.OWNERCOMPANYID    = ent.OWNERCOMPANYID;
            temp.OWNERDEPARTMENTID = ent.OWNERDEPARTMENTID;
            temp.OWNERPOSTID       = ent.OWNERPOSTID;
            temp.ISAGENCY          = ent.ISAGENCY;
            temp.POSTLEVEL         = ent.POSTLEVEL;
            temp.EMPLOYEEPOSTID    = ent.EMPLOYEEPOSTID;
            temp.COMPANYNAME       = ent.COMPANYNAME;
            temp.DEPARTMENTNAME    = ent.DEPARTMENTNAME;
            temp.POSTNAME          = ent.POSTNAME;
            temp.MOBILE            = ent.MOBILE;
            temp.OFFICEPHONE       = ent.OFFICEPHONE;

            //存入数据到V_EMPLOYEEVIEW视图和部门,岗位表
            PersonnelWS.V_EMPLOYEEVIEW vTemp = new PersonnelWS.V_EMPLOYEEVIEW();
            vTemp.EMPLOYEEID        = ent.EMPLOYEEID;
            vTemp.EMPLOYEECNAME     = ent.EMPLOYEECNAME;
            vTemp.EMPLOYEECODE      = ent.EMPLOYEECODE;
            vTemp.SEX               = ent.SEX;
            vTemp.IDNUMBER          = ent.IDNUMBER;
            vTemp.OWNERCOMPANYID    = ent.OWNERCOMPANYID;
            vTemp.OWNERDEPARTMENTID = ent.OWNERDEPARTMENTID;
            vTemp.OWNERPOSTID       = ent.OWNERPOSTID;
            vTemp.DEPARTMENTNAME    = ent.DEPARTMENTNAME;
            vTemp.POSTNAME          = ent.POSTNAME;
            vTemp.POSTLEVEL         = ent.POSTLEVEL;
            vTemp.ISAGENCY          = ent.ISAGENCY;
            vTemp.EMPLOYEEPOSTID    = ent.EMPLOYEEPOSTID;
            vTemp.MOBILE            = ent.MOBILE;
            vTemp.OFFICEPHONE       = ent.OFFICEPHONE;

            //信息存入PersonnelWS.T_HR_POSTDICTIONARY里
            PersonnelWS.T_HR_POSTDICTIONARY postDicTemp = new PersonnelWS.T_HR_POSTDICTIONARY();
            postDicTemp.POSTNAME  = ent.POSTNAME;
            postDicTemp.POSTLEVEL = ent.POSTLEVEL;

            //信息存入PersonnelWS.T_HR_DEPARTMENTDICTIONARY里
            PersonnelWS.T_HR_DEPARTMENTDICTIONARY departmentTemp = new PersonnelWS.T_HR_DEPARTMENTDICTIONARY();
            departmentTemp.DEPARTMENTNAME = ent.DEPARTMENTNAME;


            //把信息存入PersonnelWS.T_HR_POST,然后再把PersonnelWS.T_HR_POST数据存入PersonnelWS.T_HR_EMPLOYEEPOST
            //最后把数据存入PersonnelWS.T_HR_EMPLOYEEPOST
            //注意他们之间数据类型转换
            PersonnelWS.T_HR_POST tempPerWSPost = new PersonnelWS.T_HR_POST();
            tempPerWSPost.POSTLEVEL = ent.POSTLEVEL;
            tempPerWSPost.POSTID    = ent.OWNERPOSTID;


            PersonnelWS.T_HR_EMPLOYEE tempEmployee = new PersonnelWS.T_HR_EMPLOYEE();
            tempEmployee.EMPLOYEECNAME = ent.EMPLOYEECNAME;
            tempEmployee.EMPLOYEEID    = ent.EMPLOYEEID;
            tempEmployee.EMPLOYEEENAME = ent.EMPLOYEEENAME;
            tempEmployee.EMPLOYEECODE  = ent.EMPLOYEECODE;

            //把PersonnelWS.T_HR_EMPLOYEEPOST信息存入,有些表单可能会用到
            PersonnelWS.T_HR_EMPLOYEEPOST tempPerWSEmployeePost = new PersonnelWS.T_HR_EMPLOYEEPOST();
            tempPerWSEmployeePost.EMPLOYEEPOSTID = ent.EMPLOYEEPOSTID;
            tempPerWSEmployeePost.ISAGENCY       = ent.ISAGENCY;
            tempPerWSEmployeePost.POSTLEVEL      = ent.POSTLEVEL;
            tempPerWSEmployeePost.T_HR_POST      = tempPerWSPost;
            tempPerWSEmployeePost.T_HR_EMPLOYEE  = tempEmployee;



            try
            {
                if (chk.IsChecked.Value)
                {
                    //if (!bIsNotExists)
                    //{
                    //单多选进行判断,这段代码目前是为了解决员工考勤方案分配时,
                    //同一员工的考勤分配,一个人有两个岗位情况,那么只算一个考勤分配
                    //到底分配什么考勤方案,那就看情况,目前还不懂考勤分配
                    if (this.MultiSelected == true)
                    {
                        if (SelectedEmployees.Count() == 0)
                        {
                            SelectedDepartment.Add(departmentTemp);
                            SelectedPost.Add(postDicTemp);
                            SelectedEmployees.Add(temp);
                            SelectedPersonnelEmloyeePostNew.Add(tempPerWSEmployeePost);
                        }
                        else
                        {
                            for (int i = 0; i < SelectedEmployees.Count(); i++)
                            {
                                //岗位一样则只算一个,这个地方想了好久的逻辑
                                if (SelectedEmployees[i].EMPLOYEEID == temp.EMPLOYEEID && SelectedEmployees[i].EMPLOYEECNAME == temp.EMPLOYEECNAME)
                                {
                                    break;
                                }
                                if (i == SelectedEmployees.Count() - 1)
                                {
                                    //加入字典信息这两个没有用到,写着为了测试盒调试使用,以后可能有用
                                    SelectedDepartment.Add(departmentTemp);
                                    SelectedPost.Add(postDicTemp);
                                    SelectedEmployees.Add(temp);
                                    SelectedPersonnelEmloyeePostNew.Add(tempPerWSEmployeePost);
                                }
                            }
                        }
                    }
                    if (this.MultiSelected == false)
                    {
                        SelectedDepartment.Add(departmentTemp);
                        SelectedPost.Add(postDicTemp);
                        SelectedEmployees.Add(temp);
                        SelectedPersonnelEmloyeePostNew.Add(tempPerWSEmployeePost);
                    }
                    //}
                }
                else
                {
                    //这里显然是个悲剧,原始的移除根本不起作用,所以在这加个判断,
                    //如果信息一致就移除相应序号的信息,考虑到一个人可能有几个岗位
                    //所以这里不仅要判断员工ID还要判断部门ID和岗位ID,我就不信这人
                    //在一个部门里面还有两个岗位,如果有那他可能就是程序员兼客服兼测试……
                    //那就没办法了
                    for (int i = 0; i < SelectedEmployees.Count(); i++)
                    {
                        if ((SelectedEmployees[i].EMPLOYEEID == temp.EMPLOYEEID) && (SelectedEmployees[i].OWNERDEPARTMENTID == temp.OWNERDEPARTMENTID) && (SelectedEmployees[i].OWNERPOSTID == temp.OWNERPOSTID))
                        {
                            SelectedDepartment.Remove(departmentTemp);
                            SelectedPost.Remove(postDicTemp);
                            SelectedEmployees.RemoveAt(i);
                            SelectedPersonnelEmloyeePostNew.RemoveAt(i);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.ShowCustomMessage(MessageTypes.Caution, Utility.GetResourceStr("CAUTION"), "数据存入缓存错误,可关掉重新选择");
            }
            //if (chk.IsChecked.Value)
            //{
            //    if (!bIsNotExists)
            //    {
            //        SelectedEmployees.Add(temp);
            //    }
            //}
            //else
            //{
            //    if (bIsNotExists)
            //    {
            //        SelectedEmployees.Remove(temp);
            //    }
            //}
        }