private void lkSalarySolution_FindClick(object sender, EventArgs e)
        {
            Dictionary <string, string> cols = new Dictionary <string, string>();

            cols.Add("SALARYSOLUTIONNAME", "SALARYSOLUTIONNAME");
            //cols.Add("BANKNAME", "BANKNAME");
            cols.Add("BANKACCOUNTNO", "BANKACCOUNTNO");
            System.Collections.ObjectModel.ObservableCollection <object> paras = new System.Collections.ObjectModel.ObservableCollection <object>();
            string filter = "";

            filter = "CHECKSTATE==@" + paras.Count;
            paras.Add(Convert.ToInt16(CheckStates.Approved).ToString());
            //LookupForm lookup = new LookupForm(EntityNames.SalarySolution,
            //    typeof(List<T_HR_SALARYSOLUTION>), cols);
            LookupForm lookup = new LookupForm(EntityNames.SalarySolution,
                                               typeof(List <T_HR_SALARYSOLUTION>), cols, filter, paras);

            lookup.SelectedClick += (o, ev) =>
            {
                T_HR_SALARYSOLUTION ent = lookup.SelectedObj as T_HR_SALARYSOLUTION;
                if (ent != null)
                {
                    lkSalarySolution.DataContext = ent;
                    archive.SALARYSOLUTIONID     = ent.SALARYSOLUTIONID;
                    archive.SALARYSOLUTIONNAME   = ent.SALARYSOLUTIONNAME;
                }
            };

            lookup.Show <string>(DialogMode.Default, SMT.SAAS.Main.CurrentContext.Common.ParentLayoutRoot, "", (result) => { });
        }
Beispiel #2
0
 public void SalarySolutionUpdate(T_HR_SALARYSOLUTION entity)
 {
     using (SalarySolutionBLL bll = new SalarySolutionBLL())
     {
         bll.SalarySolutionUpdate(entity);
     }
 }
Beispiel #3
0
 private void button1_Click(object sender, EventArgs e)
 {
 
     var q =from ent in dal.GetObjects<T_HR_SALARYSOLUTION>().Include("T_HR_SALARYSYSTEM")
        where ent.SALARYSOLUTIONNAME.Contains(txtSolution.Text)
        select ent;
     if(q.Count()==1)
     {
         solution = q.FirstOrDefault();
         MessageBox.Show("薪资方案检查正确。");
     }else
     {
         MessageBox.Show("薪资方案不明确,请指定明确的薪资方案名");
     }
 }
Beispiel #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            var q = from ent in dal.GetObjects <T_HR_SALARYSOLUTION>().Include("T_HR_SALARYSYSTEM")
                    where ent.SALARYSOLUTIONNAME.Contains(txtSolution.Text)
                    select ent;

            if (q.Count() == 1)
            {
                solution = q.FirstOrDefault();
                MessageBox.Show("薪资方案检查正确。");
            }
            else
            {
                MessageBox.Show("薪资方案不明确,请指定明确的薪资方案名");
            }
        }
Beispiel #5
0
        void btnReSubmit_Click(object sender, RoutedEventArgs e)
        {
            ///TODO: 重新提交审核
            if (DtGrid.SelectedItems.Count > 0)
            {
                T_HR_SALARYSOLUTION            tmpEnt = DtGrid.SelectedItems[0] as T_HR_SALARYSOLUTION;
                Form.Salary.SalarySolutionForm form   = new Form.Salary.SalarySolutionForm(FormTypes.Resubmit, tmpEnt.SALARYSOLUTIONID);
                EntityBrowser browser = new EntityBrowser(form);

                browser.ReloadDataEvent += new EntityBrowser.refreshGridView(browser_ReloadDataEvent);
                browser.FormType         = FormTypes.Resubmit;
                browser.Show <string>(DialogMode.Default, SMT.SAAS.Main.CurrentContext.Common.ParentLayoutRoot, "", (result) => { });
            }
            else
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("SELECTERROR", "AUDIT"),
                                               Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
                //Utility.ShowCustomMessage(MessageTypes.Error, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("SELECTERROR", "AUDIT"));
                return;
            }
        }
Beispiel #6
0
        void SalarySolutionForm_Loaded(object sender, RoutedEventArgs e)
        {
            InitParas();
            if (FormType == FormTypes.Audit || FormType == FormTypes.Browse)
            {
                EnableControl();
            }
            if (FormType == FormTypes.New)
            {
                SolutionItemWinForm.IsEnabled = false;
            }
            if (string.IsNullOrEmpty(SalarySolutionID))
            {
                SalarySolution = new T_HR_SALARYSOLUTION();
                SalarySolution.SALARYSOLUTIONID = Guid.NewGuid().ToString();
                SalarySolution.CREATEUSERID     = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;
                SalarySolution.CREATEDATE       = System.DateTime.Now;

                SalarySolution.UPDATEDATE   = System.DateTime.Now;
                SalarySolution.UPDATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;

                SalarySolution.OWNERCOMPANYID    = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID;
                SalarySolution.OWNERDEPARTMENTID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID;
                SalarySolution.OWNERID           = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;
                SalarySolution.OWNERPOSTID       = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID;

                SalarySolution.CHECKSTATE    = Convert.ToInt16(CheckStates.UnSubmit).ToString();
                this.DataContext             = SalarySolution;
                SolutionItemWinForm.SAVEID   = SalarySolution.SALARYSOLUTIONID;
                SolutionItemWinForm.FormType = FormType;
                SolutionItemWinForm.LoadData(SalarySolution.SALARYSOLUTIONID);
                SetToolBar();
            }
            else
            {
                client.GetSalarySolutionByIDAsync(SalarySolutionID);
                SolutionItemWinForm.FormType = FormType;
                SolutionItemWinForm.LoadData(SalarySolutionID);
            }
        }
Beispiel #7
0
        void BtnView_Click(object sender, RoutedEventArgs e)
        {
            if (DtGrid.SelectedItems.Count > 0)
            {
                T_HR_SALARYSOLUTION tmpSolution = DtGrid.SelectedItems[0] as T_HR_SALARYSOLUTION;

                Form.Salary.SalarySolutionForm form = new SMT.HRM.UI.Form.Salary.SalarySolutionForm(FormTypes.Browse, tmpSolution.SALARYSOLUTIONID);
                form.SolutionItemWinForm.ToolBar.IsEnabled = false;
                form.SalaryTaxesWinForm.IsEnabled          = false;
                EntityBrowser browser = new EntityBrowser(form);
                browser.FormType         = FormTypes.Browse;
                browser.ReloadDataEvent += new EntityBrowser.refreshGridView(browser_ReloadDataEvent);
                browser.Show <string>(DialogMode.Default, SMT.SAAS.Main.CurrentContext.Common.ParentLayoutRoot, "", (result) => { });
            }
            else
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("SELECTERROR", "EDIT"),
                                               Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
                // Utility.ShowCustomMessage(MessageTypes.Error, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("SELECTERROR", "EDIT"));
                return;
            }
        }
Beispiel #8
0
        /// <summary>
        /// 批量生成标准
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            ///TODO:ADD 审核
            if (DtGrid.SelectedItems.Count > 0)
            {
                T_HR_SALARYSOLUTION tmpEnt = DtGrid.SelectedItems[0] as T_HR_SALARYSOLUTION;
                if (tmpEnt.CHECKSTATE == Convert.ToInt32(CheckStates.Approved).ToString())
                {
                    T_HR_SALARYSTANDARD standtmp = new T_HR_SALARYSTANDARD();
                    standtmp.SALARYSTANDARDID   = Guid.NewGuid().ToString();
                    standtmp.CREATECOMPANYID    = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID;
                    standtmp.CREATEDEPARTMENTID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID;
                    standtmp.CREATEPOSTID       = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID;
                    standtmp.CREATEUSERID       = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;

                    standtmp.OWNERCOMPANYID    = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID;
                    standtmp.OWNERDEPARTMENTID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID;
                    standtmp.OWNERID           = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;
                    standtmp.OWNERPOSTID       = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID;
                    loadbar.Start();
                    client.CreateSalaryStandBatchAsync(tmpEnt, postlevels, standtmp);
                    this.IsEnabled = false;
                }
                else
                {
                    ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("SALARYSOLUTIONUNAPPROVED"),
                                                   Utility.GetResourceStr("CONFIRM"), MessageIcon.Error);
                    //Utility.ShowCustomMessage(MessageTypes.Error, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("SALARYSOLUTIONUNAPPROVED"));
                    return;
                }
            }
            else
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("SELECTERROR", "BATCHCREATESTAND"),
                                               Utility.GetResourceStr("CONFIRM"), MessageIcon.Exclamation);
                //Utility.ShowCustomMessage(MessageTypes.Error, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("SELECTERROR", "BATCHCREATESTAND"));
                return;
            }
        }
Beispiel #9
0
 public string CreateSalaryStandBatch(T_HR_SALARYSOLUTION solution, Dictionary<string, string> postlevel, T_HR_SALARYSTANDARD standModel)
 {
     using (SalaryStandardBLL bll = new SalaryStandardBLL())
     {
         return bll.CreateSalaryStandBatch(solution, postlevel, standModel);
     }
 }
Beispiel #10
0
 public void TimingPay(T_HR_SALARYSOLUTION salarysolution)
 {
     using (SalarySolutionBLL bll = new SalarySolutionBLL())
     {
         bll.TimingPay(salarysolution);
     }
 }
Beispiel #11
0
 public void GetSalarySolutionEngineXml(T_HR_SALARYSOLUTION entTemp)
 {
     using (SalarySolutionBLL bll = new SalarySolutionBLL())
     {
         bll.GetSalarySolutionEngineXml(entTemp);
     }
 }
Beispiel #12
0
        void SalarySolutionForm_Loaded(object sender, RoutedEventArgs e)
        {
            InitParas();
            if (FormType == FormTypes.Audit || FormType == FormTypes.Browse)
            {
                EnableControl();
            }
            if (FormType == FormTypes.New)
            {
                SolutionItemWinForm.IsEnabled = false;
            }
            if (string.IsNullOrEmpty(SalarySolutionID))
            {
                SalarySolution = new T_HR_SALARYSOLUTION();
                SalarySolution.SALARYSOLUTIONID = Guid.NewGuid().ToString();
                SalarySolution.CREATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;
                SalarySolution.CREATEDATE = System.DateTime.Now;

                SalarySolution.UPDATEDATE = System.DateTime.Now;
                SalarySolution.UPDATEUSERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;

                SalarySolution.OWNERCOMPANYID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].CompanyID;
                SalarySolution.OWNERDEPARTMENTID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID;
                SalarySolution.OWNERID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;
                SalarySolution.OWNERPOSTID = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts[0].PostID;

                SalarySolution.CHECKSTATE = Convert.ToInt16(CheckStates.UnSubmit).ToString();
                this.DataContext = SalarySolution;
                SolutionItemWinForm.SAVEID = SalarySolution.SALARYSOLUTIONID;
                SolutionItemWinForm.FormType = FormType;
                SolutionItemWinForm.LoadData(SalarySolution.SALARYSOLUTIONID);
                SetToolBar();
            }
            else
            {
                client.GetSalarySolutionByIDAsync(SalarySolutionID);
                SolutionItemWinForm.FormType = FormType;
                SolutionItemWinForm.LoadData(SalarySolutionID);
            }
        }
Beispiel #13
0
        /// <summary>
        /// 批量生成薪资标准
        /// </summary>
        /// <param name="solution"></param>
        /// <param name="postLevels"></param>
        /// <param name="standModel"></param>
        /// <returns></returns>
        public string CreateSalaryStandBatch(T_HR_SALARYSOLUTION solution, Dictionary <string, string> postLevels, T_HR_SALARYSTANDARD standModel)
        {
            try
            {
                // 检查方案是否已经使用
                var tmpArchives = from ac in dal.GetObjects <T_HR_SALARYARCHIVE>()
                                  where ac.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                  select ac;
                if (tmpArchives.Count() > 0)
                {
                    Tracer.Debug("方案已经在使用中,无法重新生成薪资标准");
                    return("SALARYSOLUTIONINUSED");
                }

                // 薪资方案的体系ID
                string salarySystemID = solution.T_HR_SALARYSYSTEM.SALARYSYSTEMID;
                //薪资体系名
                string salarySystemName = solution.T_HR_SALARYSYSTEM.SALARYSYSTEMNAME;
                // 岗位级别名
                string postLevelName            = "";
                EmployeeSalaryRecordBLL bll     = new EmployeeSalaryRecordBLL();
                SalaryStandardItemBLL   itemBLL = new SalaryStandardItemBLL();

                //薪资方案所属的薪资体系
                List <T_HR_SALARYLEVEL> salarylevelList = new List <T_HR_SALARYLEVEL>();
                //薪资方案的薪资项集合
                List <V_SALARYITEM> salaryItems = new List <V_SALARYITEM>();

                salarylevelList = (from c in dal.GetObjects <T_HR_SALARYLEVEL>().Include("T_HR_POSTLEVELDISTINCTION")
                                   where c.T_HR_POSTLEVELDISTINCTION.T_HR_SALARYSYSTEM.SALARYSYSTEMID == salarySystemID
                                   select c).OrderBy(m => m.SALARYLEVEL).OrderBy(x => x.T_HR_POSTLEVELDISTINCTION.POSTLEVEL).ToList();


                //salaryItems = (from n in DataContext.T_HR_SALARYITEM
                //               join m in DataContext.T_HR_SALARYSOLUTIONITEM on n.SALARYITEMID equals m.T_HR_SALARYITEM.SALARYITEMID
                //               where m.T_HR_SALARYSOLUTION.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                //               select n).ToList();
                salaryItems = (from n in dal.GetObjects <T_HR_SALARYITEM>()
                               join m in dal.GetObjects <T_HR_SALARYSOLUTIONITEM>() on n.SALARYITEMID equals m.T_HR_SALARYITEM.SALARYITEMID
                               where m.T_HR_SALARYSOLUTION.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                               select new V_SALARYITEM
                {
                    T_HR_SALARYITEM = n,
                    ORDERNUMBER = m.ORDERNUMBER
                }
                               ).ToList();

                //方案所属地区差异补贴
                List <T_HR_AREAALLOWANCE> areaAllowance = new List <T_HR_AREAALLOWANCE>();
                areaAllowance = (from c in dal.GetObjects <T_HR_AREAALLOWANCE>()
                                 join b in dal.GetObjects <T_HR_SALARYSOLUTION>().Include("T_HR_AREADIFFERENCE") on c.T_HR_AREADIFFERENCE.AREADIFFERENCEID equals b.T_HR_AREADIFFERENCE.AREADIFFERENCEID
                                 where b.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                 select c).ToList();

                //新增前删除原有的标准
                SalaryStandardBLL standBLL = new SalaryStandardBLL();
                standBLL.SalaryStandardDeleteBySolutionID(solution.SALARYSOLUTIONID);
                //var enttt = from ccc in salarylevelList where ccc.SALARYSUM>0 select ccc;
                int num = 0;
                #region   薪资标准排序算法
                int numsign    = 0;
                int recordsign = 0;
                for (int x = 0; x < salarylevelList.Count; x++)
                {
                    if (numsign == 0)
                    {
                        recordsign = x;
                    }
                    if ((x + 1 < salarylevelList.Count && salarylevelList[x].T_HR_POSTLEVELDISTINCTION.POSTLEVEL != salarylevelList[x + 1].T_HR_POSTLEVELDISTINCTION.POSTLEVEL) || x == salarylevelList.Count - 1)
                    {
                        numsign++;
                        for (int i = recordsign; i < recordsign + numsign; i++)
                        {
                            for (int j = i + 1; j < recordsign + numsign; j++)
                            {
                                //if (salarylevelList[i].T_HR_POSTLEVELDISTINCTION.POSTLEVEL > 0) break;
                                if (Convert.ToDecimal(salarylevelList[i].SALARYLEVEL) > Convert.ToDecimal(salarylevelList[j].SALARYLEVEL))
                                {
                                    T_HR_SALARYLEVEL t = null;
                                    t = salarylevelList[i];
                                    salarylevelList[i] = salarylevelList[j];
                                    salarylevelList[j] = t;
                                }
                            }
                        }
                        numsign = 0;
                    }
                    else
                    {
                        numsign++;
                    }
                }
                #endregion
                //dal.BeginTransaction();
                foreach (var sl in salarylevelList)
                {
                    // 薪资体系的每条记录都对应一个标准 根据sl生成薪资标准
                    T_HR_SALARYSTANDARD stand = new T_HR_SALARYSTANDARD();
                    //薪资标准的薪资项集合
                    List <T_HR_SALARYSTANDARDITEM> standSalaryitems = new List <T_HR_SALARYSTANDARDITEM>();
                    //获取岗位级别名
                    var ent = from c in postLevels
                              join b in salarylevelList on c.Value equals b.T_HR_POSTLEVELDISTINCTION.POSTLEVEL.ToString()
                                  where b.SALARYLEVELID == sl.SALARYLEVELID
                              select c.Key;

                    if (ent.Count() > 0)
                    {
                        postLevelName = ent.FirstOrDefault().ToString();
                    }

                    //薪资标准名= 薪资体系名+岗位级别名+"-"+薪资级别名
                    stand.SALARYSTANDARDNAME = salarySystemName + postLevelName + "-" + sl.SALARYLEVEL.ToString();
                    stand.SALARYSTANDARDID   = Guid.NewGuid().ToString();
                    // stand.T_HR_SALARYLEVEL = new T_HR_SALARYLEVEL();
                    stand.T_HR_SALARYLEVELReference.EntityKey
                        = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYLEVEL", "SALARYLEVELID", sl.SALARYLEVELID);
                    //  stand.T_HR_SALARYLEVEL.SALARYLEVELID = sl.SALARYLEVELID;
                    stand.SALARYSOLUTIONID = solution.SALARYSOLUTIONID;
                    stand.CHECKSTATE       = Convert.ToInt32(CheckStates.Approved).ToString();
                    stand.BASESALARY       = sl.SALARYSUM;
                    stand.CREATEDATE       = System.DateTime.Now;

                    //有关权限的字段
                    stand.CREATECOMPANYID    = standModel.CREATECOMPANYID;
                    stand.CREATEDEPARTMENTID = standModel.CREATEDEPARTMENTID;
                    stand.CREATEPOSTID       = standModel.CREATEPOSTID;
                    stand.CREATEUSERID       = standModel.CREATEUSERID;
                    stand.OWNERCOMPANYID     = standModel.OWNERCOMPANYID;
                    stand.OWNERDEPARTMENTID  = standModel.OWNERDEPARTMENTID;
                    stand.OWNERID            = standModel.OWNERID;
                    stand.OWNERPOSTID        = standModel.OWNERPOSTID;


                    //增加排序号
                    stand.PERSONALSIRATIO = num;
                    num++;


                    //标准对应的地区差异补贴(和岗位级别有关)
                    decimal?allowance = 0;
                    if (areaAllowance != null)
                    {
                        allowance = (from al in areaAllowance
                                     where al.POSTLEVEL == sl.T_HR_POSTLEVELDISTINCTION.POSTLEVEL.ToString()
                                     select al.ALLOWANCE).FirstOrDefault();
                    }
                    //计算标准的基础数据
                    decimal?BasicData = sl.SALARYSUM;

                    //按照方案的薪资项集合生成薪资标准的薪资项
                    foreach (var item in salaryItems)
                    {
                        T_HR_SALARYSTANDARDITEM standItem = new T_HR_SALARYSTANDARDITEM();
                        standItem.STANDRECORDITEMID = Guid.NewGuid().ToString();
                        standItem.T_HR_SALARYITEMReference.EntityKey
                            = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYITEM", "SALARYITEMID", item.T_HR_SALARYITEM.SALARYITEMID);
                        // standItem.T_HR_SALARYITEM.SALARYITEMID = item.T_HR_SALARYITEM.SALARYITEMID;
                        standItem.CREATEUSERID = solution.CREATEUSERID;
                        standItem.T_HR_SALARYSTANDARDReference.EntityKey
                            = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYSTANDARD", "SALARYSTANDARDID", stand.SALARYSTANDARDID);
                        // standItem.T_HR_SALARYSTANDARD.SALARYSTANDARDID = stand.SALARYSTANDARDID;
                        standItem.CREATEDATE  = System.DateTime.Now;
                        standItem.ORDERNUMBER = item.ORDERNUMBER;
                        //计算类型是手动输入的 金额是薪资项设置是输入的值
                        if (item.T_HR_SALARYITEM.CALCULATORTYPE == "1" || (item.T_HR_SALARYITEM.CALCULATORTYPE == "4" && item.T_HR_SALARYITEM.GUERDONSUM != null))
                        {
                            standItem.SUM = item.T_HR_SALARYITEM.GUERDONSUM.ToString();
                        }
                        //计算类型是公式计算 而且不是在生成薪资时计算
                        else if (item.T_HR_SALARYITEM.CALCULATORTYPE == "3" && item.T_HR_SALARYITEM.ISAUTOGENERATE == "0")
                        {
                            standItem.SUM = bll.AutoCalculateItem(item.T_HR_SALARYITEM.SALARYITEMID, Convert.ToDecimal(BasicData), allowance.ToString()).ToString();
                        }
                        //地区差异补贴
                        else if (item.T_HR_SALARYITEM.ENTITYCOLUMNCODE == "AREADIFALLOWANCE")
                        {
                            standItem.SUM = allowance.ToString();
                        }
                        standSalaryitems.Add(standItem);
                    }
                    //SalaryStandardAdd(stand);
                    //itemBLL.SalaryStandardItemsAdd(standSalaryitems);
                    AddSalaryStanderAndItems(stand, standSalaryitems);
                }
                //dal.CommitTransaction();
                return("SAVESUCCESSED");
            }
            catch (Exception ex)
            {
                //dal.RollbackTransaction();
                SMT.Foundation.Log.Tracer.Debug(ex.Message);
                return(ex.Message);
            }
        }
Beispiel #14
0
        /// <summary>
        /// 批量生成薪资标准
        /// </summary>
        /// <param name="solution"></param>
        /// <param name="postLevels"></param>
        /// <param name="standModel"></param>
        /// <returns></returns>
        public string CreateSalaryStandBatch(T_HR_SALARYSOLUTION solution, Dictionary <string, string> postLevels, T_HR_SALARYSTANDARD standModel)
        {
            try
            {
                //T_HR_SalaryStandard->T_HR_SalarySolution
                //T_HR_SalaryStandard->T_HR_SalaryLevel->T_HR_PostLevelDistinction->T_HR_SalarySystem
                Tracer.Debug("通过薪资方案生成薪资标准:方案名:" + solution.SALARYSOLUTIONNAME);
                #region 获取薪资级别信息
                EmployeeSalaryRecordBLL bll     = new EmployeeSalaryRecordBLL();
                SalaryStandardItemBLL   itemBLL = new SalaryStandardItemBLL();
                // 薪资方案的体系ID
                string salarySystemID = solution.T_HR_SALARYSYSTEM.SALARYSYSTEMID;
                //薪资体系名
                string salarySystemName = solution.T_HR_SALARYSYSTEM.SALARYSYSTEMNAME;
                // 岗位级别名
                string postLevelName = "";
                //薪资方案所属的薪资体系
                List <T_HR_SALARYLEVEL> salarylevelList = new List <T_HR_SALARYLEVEL>();
                //薪资体系薪资级别
                salarylevelList = (from c in dal.GetObjects <T_HR_SALARYLEVEL>().Include("T_HR_POSTLEVELDISTINCTION")
                                   where c.T_HR_POSTLEVELDISTINCTION.T_HR_SALARYSYSTEM.SALARYSYSTEMID == salarySystemID
                                   select c).OrderBy(m => m.SALARYLEVEL).OrderBy(x => x.T_HR_POSTLEVELDISTINCTION.POSTLEVEL).ToList();
                if (salarylevelList.Count < 1)
                {
                    Tracer.Debug("生产薪资标准,未获取到薪资等级 T_HR_SALARYLEVEL 信息");
                }
                //薪资方案的薪资项集合
                List <V_SALARYITEM> salaryItems = new List <V_SALARYITEM>();
                salaryItems = (from n in dal.GetObjects <T_HR_SALARYITEM>()
                               join m in dal.GetObjects <T_HR_SALARYSOLUTIONITEM>() on n.SALARYITEMID equals m.T_HR_SALARYITEM.SALARYITEMID
                               where m.T_HR_SALARYSOLUTION.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                               select new V_SALARYITEM
                {
                    T_HR_SALARYITEM = n,
                    ORDERNUMBER = m.ORDERNUMBER
                }
                               ).ToList();
                if (salaryItems.Count < 1)
                {
                    Tracer.Debug("生产薪资标准,未获取到薪资方案关联的薪资项目 T_HR_SALARYITEM 信息");
                }
                //方案所属地区差异补贴
                List <T_HR_AREAALLOWANCE> areaAllowance = new List <T_HR_AREAALLOWANCE>();
                areaAllowance = (from c in dal.GetObjects <T_HR_AREAALLOWANCE>()
                                 join b in dal.GetObjects <T_HR_SALARYSOLUTION>().Include("T_HR_AREADIFFERENCE")
                                 on c.T_HR_AREADIFFERENCE.AREADIFFERENCEID equals b.T_HR_AREADIFFERENCE.AREADIFFERENCEID
                                 where b.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                 select c).ToList();
                if (salaryItems.Count < 1)
                {
                    Tracer.Debug("生产薪资标准,未获取到薪资方案关联的地区差异补贴 T_HR_AREAALLOWANCE 信息");
                }
                //薪资方案薪资标准
                List <T_HR_SALARYSTANDARD> standAll = (from a in dal.GetObjects <T_HR_SALARYSTANDARD>().Include("T_HR_SALARYLEVEL").Include("T_HR_SALARYSTANDARDITEM")
                                                       where a.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                                       select a).ToList();
                #endregion
                int num = 0;
                foreach (var sl in salarylevelList)
                {
                    #region 获取薪资标准基本信息
                    //1.获取岗位级别名
                    var ent = from c in postLevels
                              join b in salarylevelList on c.Value equals b.T_HR_POSTLEVELDISTINCTION.POSTLEVEL.ToString()
                                  where b.SALARYLEVELID == sl.SALARYLEVELID
                              select c.Key;

                    if (ent.Count() > 0)
                    {
                        postLevelName = ent.FirstOrDefault().ToString();
                    }
                    //2.标准对应的地区差异补贴(和岗位级别有关)
                    decimal?allowance = 0;
                    if (areaAllowance != null)
                    {
                        allowance = (from al in areaAllowance
                                     where al.POSTLEVEL == sl.T_HR_POSTLEVELDISTINCTION.POSTLEVEL.ToString()
                                     select al.ALLOWANCE).FirstOrDefault();
                    }
                    //3.计算标准的基础数据
                    decimal?BasicData = sl.SALARYSUM;
                    #endregion

                    var checkEntity = (from a in standAll
                                       where a.T_HR_SALARYLEVEL.SALARYLEVELID == sl.SALARYLEVELID
                                       select a).FirstOrDefault();
                    #region 更新薪资标准
                    if (checkEntity != null)
                    {
                        try
                        {
                            Tracer.Debug("已存在薪资标准,开始更新:" + checkEntity.SALARYSTANDARDNAME);
                            //已存在,需要更新
                            //薪资标准名= 薪资体系名+岗位级别名+"-"+薪资级别名
                            var entity = (from sent in dal.GetObjects <T_HR_SALARYSTANDARD>().Include("T_HR_SALARYSTANDARDITEM")
                                          where sent.SALARYSTANDARDID == checkEntity.SALARYSTANDARDID
                                          select sent).FirstOrDefault();
                            entity.SALARYSTANDARDNAME = salarySystemName + postLevelName + "-" + sl.SALARYLEVEL.ToString();
                            entity.BASESALARY         = sl.SALARYSUM;
                            dal.UpdateFromContext(entity);
                            List <T_HR_SALARYSTANDARDITEM> listItem = entity.T_HR_SALARYSTANDARDITEM.ToList();
                            foreach (var standItem in listItem)
                            {
                                if (!standItem.T_HR_SALARYITEMReference.IsLoaded)
                                {
                                    standItem.T_HR_SALARYITEMReference.Load();
                                }
                                var q = from item in salaryItems
                                        where item.T_HR_SALARYITEM.SALARYITEMID == standItem.T_HR_SALARYITEMReference.EntityKey.EntityKeyValues[0].Value
                                        select item;
                                if (q.Count() > 0)
                                {
                                    var salaryitem = q.FirstOrDefault();
                                    if (salaryitem.T_HR_SALARYITEM.CALCULATORTYPE == "1" || (salaryitem.T_HR_SALARYITEM.CALCULATORTYPE == "4" && salaryitem.T_HR_SALARYITEM.GUERDONSUM != null))
                                    {
                                        standItem.SUM = salaryitem.T_HR_SALARYITEM.GUERDONSUM.ToString();
                                    }//计算类型是公式计算 而且不是在生成薪资时计算
                                    else if (salaryitem.T_HR_SALARYITEM.CALCULATORTYPE == "3" && salaryitem.T_HR_SALARYITEM.ISAUTOGENERATE == "0")
                                    {
                                        standItem.SUM = bll.AutoCalculateItem(salaryitem.T_HR_SALARYITEM.SALARYITEMID, Convert.ToDecimal(BasicData), allowance.ToString()).ToString();
                                    }
                                    //地区差异补贴
                                    else if (salaryitem.T_HR_SALARYITEM.ENTITYCOLUMNCODE == "AREADIFALLOWANCE")
                                    {
                                        standItem.SUM = allowance.ToString();
                                    }
                                }
                                dal.UpdateFromContext(standItem);
                            }
                            dal.SaveContextChanges();
                            Tracer.Debug("更新薪资标准成功!" + entity.SALARYSTANDARDNAME);
                        }
                        catch (Exception ex)
                        {
                            Tracer.Debug("更新薪资标准异常:" + ex.ToString());
                        }
                        continue;
                    }
                    #endregion

                    #region 新增薪资标准
                    try
                    {
                        Tracer.Debug("未找到薪资标准,开始新增薪资标准信息:" + salarySystemName + postLevelName + "-" + sl.SALARYLEVEL.ToString());
                        // 薪资体系的每条记录都对应一个标准 根据sl生成薪资标准
                        T_HR_SALARYSTANDARD stand = new T_HR_SALARYSTANDARD();
                        //薪资标准名= 薪资体系名+岗位级别名+"-"+薪资级别名
                        stand.SALARYSTANDARDNAME = salarySystemName + postLevelName + "-" + sl.SALARYLEVEL.ToString();
                        stand.SALARYSTANDARDID   = Guid.NewGuid().ToString();
                        stand.T_HR_SALARYLEVELReference.EntityKey
                            = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYLEVEL", "SALARYLEVELID", sl.SALARYLEVELID);
                        stand.SALARYSOLUTIONID = solution.SALARYSOLUTIONID;
                        stand.CHECKSTATE       = Convert.ToInt32(CheckStates.Approved).ToString();
                        stand.BASESALARY       = sl.SALARYSUM;
                        stand.CREATEDATE       = System.DateTime.Now;

                        //有关权限的字段
                        stand.CREATECOMPANYID    = standModel.CREATECOMPANYID;
                        stand.CREATEDEPARTMENTID = standModel.CREATEDEPARTMENTID;
                        stand.CREATEPOSTID       = standModel.CREATEPOSTID;
                        stand.CREATEUSERID       = standModel.CREATEUSERID;
                        stand.OWNERCOMPANYID     = standModel.OWNERCOMPANYID;
                        stand.OWNERDEPARTMENTID  = standModel.OWNERDEPARTMENTID;
                        stand.OWNERID            = standModel.OWNERID;
                        stand.OWNERPOSTID        = standModel.OWNERPOSTID;


                        //增加排序号
                        stand.PERSONALSIRATIO = num;
                        num++;

                        //按照方案的薪资项集合生成薪资标准的薪资项
                        //薪资标准的薪资项集合
                        List <T_HR_SALARYSTANDARDITEM> standSalaryitems = new List <T_HR_SALARYSTANDARDITEM>();
                        foreach (var item in salaryItems)
                        {
                            T_HR_SALARYSTANDARDITEM standItem = new T_HR_SALARYSTANDARDITEM();
                            standItem.STANDRECORDITEMID = Guid.NewGuid().ToString();
                            standItem.T_HR_SALARYITEMReference.EntityKey
                                = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYITEM", "SALARYITEMID", item.T_HR_SALARYITEM.SALARYITEMID);
                            // standItem.T_HR_SALARYITEM.SALARYITEMID = item.T_HR_SALARYITEM.SALARYITEMID;
                            standItem.CREATEUSERID = solution.CREATEUSERID;
                            standItem.T_HR_SALARYSTANDARDReference.EntityKey
                                = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYSTANDARD", "SALARYSTANDARDID", stand.SALARYSTANDARDID);
                            // standItem.T_HR_SALARYSTANDARD.SALARYSTANDARDID = stand.SALARYSTANDARDID;
                            standItem.CREATEDATE  = System.DateTime.Now;
                            standItem.ORDERNUMBER = item.ORDERNUMBER;
                            //计算类型是手动输入的 金额是薪资项设置是输入的值
                            if (item.T_HR_SALARYITEM.CALCULATORTYPE == "1" || (item.T_HR_SALARYITEM.CALCULATORTYPE == "4" && item.T_HR_SALARYITEM.GUERDONSUM != null))
                            {
                                standItem.SUM = item.T_HR_SALARYITEM.GUERDONSUM.ToString();
                            }
                            //计算类型是公式计算 而且不是在生成薪资时计算
                            else if (item.T_HR_SALARYITEM.CALCULATORTYPE == "3" && item.T_HR_SALARYITEM.ISAUTOGENERATE == "0")
                            {
                                standItem.SUM = bll.AutoCalculateItem(item.T_HR_SALARYITEM.SALARYITEMID, Convert.ToDecimal(BasicData), allowance.ToString()).ToString();
                            }
                            //地区差异补贴
                            else if (item.T_HR_SALARYITEM.ENTITYCOLUMNCODE == "AREADIFALLOWANCE")
                            {
                                standItem.SUM = allowance.ToString();
                            }
                            standSalaryitems.Add(standItem);
                        }
                        AddSalaryStanderAndItems(stand, standSalaryitems);
                        Tracer.Debug("未找到薪资标准,新增薪资标准成功!" + salarySystemName + postLevelName + "-" + sl.SALARYLEVEL.ToString());
                    }
                    catch (Exception ex)
                    {
                        Tracer.Debug("未找到薪资标准,新增薪资标准异常:" + ex.ToString());
                    }
                    #endregion
                }
                return("SAVESUCCESSED");
            }
            catch (Exception ex)
            {
                Tracer.Debug("生成薪资标准异常:" + ex.Message);
                return(ex.Message);
            }
        }
Beispiel #15
0
        void client_GetSalaryArchiveMasterByIDCompleted(object sender, GetSalaryArchiveMasterByIDCompletedEventArgs e)
        {
            if (e.Error != null && !string.IsNullOrEmpty(e.Error.Message))
            {
                ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("CONFIRM"), MessageIcon.Error);
            }
            else
            {
                if (e.Result == null)
                {
                    ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("NOTFOUND"), Utility.GetResourceStr("CONFIRM"), MessageIcon.Error);
                    return;
                }
                SalaryArchive = e.Result.archive;
                this.DataContext = SalaryArchive;

                //显示员工名
                SMT.Saas.Tools.PersonnelWS.T_HR_EMPLOYEE ent = new SMT.Saas.Tools.PersonnelWS.T_HR_EMPLOYEE();
                ent.EMPLOYEEID = SalaryArchive.EMPLOYEEID;
                ent.EMPLOYEECODE = SalaryArchive.EMPLOYEECODE;
                ent.EMPLOYEECNAME = SalaryArchive.EMPLOYEENAME;
                lkEmployee.DataContext = ent;
                string fullName = string.Empty;
                //if (string.IsNullOrEmpty(e.Result.PostName))
                //{
                //    fullName = SalaryArchive.EMPLOYEENAME;
                //}
                //else
                //{
                //    fullName = SalaryArchive.EMPLOYEENAME + " - " + e.Result.PostName + " - " + GetFullOrgName(e.Result.DepartmentID);
                //}
                lkEmployee.TxtLookUp.Text = SalaryArchive.EMPLOYEENAME;

                //显示薪资方案名
                T_HR_SALARYSOLUTION tmp = new T_HR_SALARYSOLUTION();
                tmp.SALARYSOLUTIONNAME = SalaryArchive.SALARYSOLUTIONNAME;
                tmp.SALARYSOLUTIONID = SalaryArchive.SALARYSOLUTIONID;
                lkSalarySolution.DataContext = tmp;

                //发薪机构
                var companys = Application.Current.Resources["SYS_CompanyInfo"] as List<OrganizationWS.T_HR_COMPANY>;
                if (companys != null)
                {
                    OrganizationWS.T_HR_COMPANY company = companys.Where(s => s.COMPANYID == SalaryArchive.PAYCOMPANY).FirstOrDefault();
                    lkSalaryCompany.DataContext = company;
                }

                //考勤机构
                if (!string.IsNullOrWhiteSpace(SalaryArchive.ATTENDANCEORGNAME))
                {
                    lkAttendanceCompany.TxtLookUp.Text = SalaryArchive.ATTENDANCEORGNAME;
                }

                //结算岗位
                if (!string.IsNullOrWhiteSpace(SalaryArchive.BALANCEPOSTNAME))
                {
                    lkBalancePost.TxtLookUp.Text = SalaryArchive.BALANCEPOSTNAME;
                }

                //薪资标准
                salaryStand = new T_HR_SALARYSTANDARD();
                salaryStand.SALARYSTANDARDID = e.Result.standerID;
                salaryStand.SALARYSTANDARDNAME = e.Result.standerName;
                SalaryArchive.T_HR_SALARYSTANDARD = salaryStand;

                //传给流程的参数
                createCompanyID = e.Result.CompanyID;
                createDepartmentID = e.Result.DepartmentID;
                createPostID = e.Result.PostID;

                //加载薪资项
                LoadData();

                //重新提交把审核状态修改为未提交
                if (FormType == FormTypes.Resubmit)
                {
                    SalaryArchive.CHECKSTATE = Convert.ToInt32(CheckStates.UnSubmit).ToString();
                    SalaryArchive.EDITSTATE = Convert.ToInt32(EditStates.UnActived).ToString();
                }
                //禁用控件
                if (SalaryArchive.CHECKSTATE != Convert.ToInt32(CheckStates.UnSubmit).ToString())
                {
                    EnableControl();
                }
                if (SalaryArchive.POSTLEVEL != null)
                {
                    BindPostLevel(SalaryArchive.POSTLEVEL);
                    PostLevel = SalaryArchive.POSTLEVEL.ToString();
                }

                if (SalaryArchive.OLDSALARYLEVEL != null)
                {
                    oldsalaryLevel = SalaryArchive.OLDSALARYLEVEL;
                    oldpostlevel = SalaryArchive.OLDPOSTLEVEL == null ? 0 : SalaryArchive.OLDPOSTLEVEL;
                    foreach (SMT.Saas.Tools.PermissionWS.T_SYS_DICTIONARY item in cbxOldSalaryLevel.Items)
                    {
                        if (item.DICTIONARYVALUE == oldsalaryLevel)
                        {
                            cbxOldSalaryLevel.SelectedItem = item;
                            break;
                        }
                    }
                    foreach (SMT.Saas.Tools.PermissionWS.T_SYS_DICTIONARY item in cbxOldPostLevel.Items)
                    {
                        if (item.DICTIONARYVALUE == oldpostlevel)
                        {
                            cbxOldPostLevel.SelectedItem = item;
                            break;
                        }
                    }

                }
                if (SalaryArchive.BALANCE != null)
                {
                    txtbBalance.Text = SalaryArchive.BALANCE.ToString();
                }

                RefreshUI(RefreshedTypes.AuditInfo);
                SetToolBar();
            }
        }
Beispiel #16
0
        public void CreateSalaryStandBatch()
        {
            try
            {

                EmployeeSalaryRecordBLL bll = new EmployeeSalaryRecordBLL();
                SalaryStandardItemBLL itemBLL = new SalaryStandardItemBLL();

                string strsolutionall = @"上海神达物流有限公司薪资方案(A类城市)
                                上海酷武供应链管理服务有限公司薪资方案(A类)
                                北京市神通物流有限公司薪资方案(A类城市)
                                南京红之衣物流有限公司薪资方案(B类城市)
                                南宁市神州通货运代理有限公司薪资方案(D类城市)
                                南昌神州通物流有限公司薪资方案(E类城市)
                                合肥神州通物流有限公司薪资方案(D类城市)
                                哈尔滨神达通运输有限责任公司薪资方案(D类城市)
                                天津神州通物流有限公司薪资方案(C类城市)
                                太原市神通物流有限公司薪资方案(E类城市)
                                广州市神通物流有限公司薪资方案(A类城市)
                                成都通神州物流有限公司薪资方案(D类城市)
                                昆明神州通物流有限公司薪资方案(D类城市)
                                杭州新神州通货物运输有限公司薪资方案(B类城市)
                                武汉通神州仓储服务有限责任公司薪资方案(C类城市)
                                沈阳神州通物流有限公司薪资方案(C类城市)
                                济南神州通物流有限公司薪资方案(C类城市)
                                深圳市神州通物流有限公司薪资方案(A类城市)
                                深圳市神州通物流有限公司薪资方案(B类城市)
                                深圳市神州通物流有限公司薪资方案(C类城市)
                                深圳市神州通物流有限公司薪资方案(D类城市)
                                深圳市神州通物流有限公司薪资方案(E类城市)
                                深圳市神州通物流有限公司贵阳分公司(E类城市)
                                深圳市通神州物流公司薪资方案(A类城市)
                                石家庄神州通物流有限公司薪资方案(D类城市)
                                福州市神州通货运代理有限公司薪资方案(C类城市)
                                西安市神之通物流有限公司薪资方案(D类城市)
                                贵阳市神州通物流有限公司(E类城市)
                                郑州市神州通物流有限公司薪资方案(D类城市)
                                重庆新神州通物流有限公司薪资方案(D类城市)
                                长春市神之通物流有限公司薪资方案(D类城市)
                                长沙市神通物流服务有限公司薪资方案(C类城市)
                                青海神之通电子商务有限公司薪资方案(E类)";
                var solutionAll = (from ent in dal.GetObjects<T_HR_SALARYSOLUTION>().Include("T_HR_SALARYSYSTEM")
                                   where ent.SALARYSOLUTIONNAME.Contains(strsolutionall)
                                   && ent.CHECKSTATE == "2"
                                   select ent).ToList();

                foreach (var solutionItem in solutionAll)
                {
                    solution = solutionItem;


                    standtmp = new T_HR_SALARYSTANDARD();
                    standtmp.SALARYSTANDARDID = Guid.NewGuid().ToString();
                    standtmp.CREATECOMPANYID = solution.CREATECOMPANYID;
                    standtmp.CREATEDEPARTMENTID = solution.CREATEDEPARTMENTID;
                    standtmp.CREATEPOSTID = solution.CREATEPOSTID;
                    standtmp.CREATEUSERID = solution.CREATEUSERID;

                    standtmp.OWNERCOMPANYID = solution.OWNERCOMPANYID;
                    standtmp.OWNERDEPARTMENTID = solution.OWNERDEPARTMENTID;
                    standtmp.OWNERID = solution.OWNERID;
                    standtmp.OWNERPOSTID = solution.OWNERPOSTID;
                    //loadbar.Start();

                    // 薪资方案的体系ID
                    string salarySystemID = solution.T_HR_SALARYSYSTEM.SALARYSYSTEMID;
                    //薪资体系名
                    string salarySystemName = solution.T_HR_SALARYSYSTEM.SALARYSYSTEMNAME;
                    // 岗位级别名
                    string postLevelName = "";

                    //薪资方案所属的薪资体系
                    List<T_HR_SALARYLEVEL> salarylevelList = new List<T_HR_SALARYLEVEL>();
                    //薪资方案的薪资项集合
                    List<V_SALARYITEM> salaryItems = new List<V_SALARYITEM>();

                    salarylevelList = (from c in dal.GetObjects<T_HR_SALARYLEVEL>().Include("T_HR_POSTLEVELDISTINCTION")
                                       where c.T_HR_POSTLEVELDISTINCTION.T_HR_SALARYSYSTEM.SALARYSYSTEMID == salarySystemID
                                       select c).ToList().OrderBy(m => m.SALARYLEVEL).OrderBy(x => x.T_HR_POSTLEVELDISTINCTION.POSTLEVEL).ToList();

                    salaryItems = (from n in dal.GetObjects<T_HR_SALARYITEM>()
                                   join m in dal.GetObjects<T_HR_SALARYSOLUTIONITEM>() on n.SALARYITEMID equals m.T_HR_SALARYITEM.SALARYITEMID
                                   where m.T_HR_SALARYSOLUTION.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                   select new V_SALARYITEM
                                   {
                                       T_HR_SALARYITEM = n,
                                       ORDERNUMBER = m.ORDERNUMBER
                                   }
                                   ).ToList();

                    //方案所属地区差异补贴
                    List<T_HR_AREAALLOWANCE> areaAllowance = new List<T_HR_AREAALLOWANCE>();
                    areaAllowance = (from c in dal.GetObjects<T_HR_AREAALLOWANCE>()
                                     join b in dal.GetObjects<T_HR_SALARYSOLUTION>().Include("T_HR_AREADIFFERENCE") on c.T_HR_AREADIFFERENCE.AREADIFFERENCEID equals b.T_HR_AREADIFFERENCE.AREADIFFERENCEID
                                     where b.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                     select c).ToList();

                    int num = 0;

                    //dal.BeginTransaction();
                    foreach (var sl in salarylevelList)
                    {
                        var ent = from c in postlevels
                                  join b in salarylevelList on c.Value equals b.T_HR_POSTLEVELDISTINCTION.POSTLEVEL.ToString()
                                  where b.SALARYLEVELID == sl.SALARYLEVELID
                                  select c.Key;
                        if (ent.Count() > 0)
                        {
                            postLevelName = ent.FirstOrDefault().ToString();
                        }
                        var ents = (from a in dal.GetObjects<T_HR_SALARYSTANDARD>()
                                    where a.T_HR_SALARYLEVEL.SALARYLEVELID == sl.SALARYLEVELID
                                    && a.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                    select new
                                    {
                                        a.SALARYSTANDARDID,
                                        a.SALARYSTANDARDNAME,
                                        a.T_HR_SALARYLEVEL.SALARYLEVEL
                                    });
                        if (ents.Count() > 0)
                        {
                           

                            var checkEntity = ents.FirstOrDefault();
                            ShowMessage(txtMsg, "薪资标准已存在,跳过:" + solution.SALARYSOLUTIONNAME + " " + checkEntity.SALARYSTANDARDNAME + System.Environment.NewLine);
                            //已存在,跳过生成
                            continue;
                            //if (int.Parse(checkEntity.SALARYLEVEL) > 40)
                            //{
                            //    try { 
                            //    var delentity = (from a in dal.GetObjects<T_HR_SALARYSTANDARD>().Include("T_HR_SALARYSTANDARDITEM")
                            //                     where a.SALARYSTANDARDID
                            //                     == checkEntity.SALARYSTANDARDID
                            //                     select a).FirstOrDefault();
                            //    foreach (var entity in delentity.T_HR_SALARYSTANDARDITEM)
                            //    {
                            //        dal.Delete(entity);
                            //    }
                            //    dal.Delete(delentity);
                            //    ShowMessage(txtMsg, "删除薪资标准成功!" + solution.SALARYSOLUTIONNAME + " " + checkEntity.SALARYSTANDARDNAME + System.Environment.NewLine);
                            //        }catch(Exception ex)
                            //    {
                            //        ShowMessage(txtMsg, "薪资标准已被使用,跳过:" + solution.SALARYSOLUTIONNAME + " " + checkEntity.SALARYSTANDARDNAME + System.Environment.NewLine);
                            //        continue;
                            //    }
                            //}
                            //else
                            //{
                            //    ShowMessage(txtMsg, "薪资标准已存在,跳过:" + solution.SALARYSOLUTIONNAME + " " + checkEntity.SALARYSTANDARDNAME + System.Environment.NewLine);
                            //    //已存在,跳过生成
                            //    continue;
                            //}
                        }
                        // 薪资体系的每条记录都对应一个标准 根据sl生成薪资标准
                        T_HR_SALARYSTANDARD stand = new T_HR_SALARYSTANDARD();
                        //薪资标准的薪资项集合
                        List<T_HR_SALARYSTANDARDITEM> standSalaryitems = new List<T_HR_SALARYSTANDARDITEM>();
                        //获取岗位级别名


                        //薪资标准名= 薪资体系名+岗位级别名+"-"+薪资级别名
                        stand.SALARYSTANDARDNAME = salarySystemName + postLevelName + "-" + sl.SALARYLEVEL.ToString();
                        stand.SALARYSTANDARDID = Guid.NewGuid().ToString();
                        // stand.T_HR_SALARYLEVEL = new T_HR_SALARYLEVEL();
                        stand.T_HR_SALARYLEVELReference.EntityKey
                              = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYLEVEL", "SALARYLEVELID", sl.SALARYLEVELID);
                        //  stand.T_HR_SALARYLEVEL.SALARYLEVELID = sl.SALARYLEVELID;
                        stand.SALARYSOLUTIONID = solution.SALARYSOLUTIONID;
                        stand.CHECKSTATE = "2";
                        stand.BASESALARY = sl.SALARYSUM;
                        stand.CREATEDATE = System.DateTime.Now;

                        //有关权限的字段
                        stand.CREATECOMPANYID = standtmp.CREATECOMPANYID;
                        stand.CREATEDEPARTMENTID = standtmp.CREATEDEPARTMENTID;
                        stand.CREATEPOSTID = standtmp.CREATEPOSTID;
                        stand.CREATEUSERID = standtmp.CREATEUSERID;
                        stand.OWNERCOMPANYID = standtmp.OWNERCOMPANYID;
                        stand.OWNERDEPARTMENTID = standtmp.OWNERDEPARTMENTID;
                        stand.OWNERID = standtmp.OWNERID;
                        stand.OWNERPOSTID = standtmp.OWNERPOSTID;


                        //增加排序号
                        stand.PERSONALSIRATIO = num;
                        num++;


                        //标准对应的地区差异补贴(和岗位级别有关)
                        decimal? allowance = 0;
                        if (areaAllowance != null)
                        {
                            allowance = (from al in areaAllowance
                                         where al.POSTLEVEL == sl.T_HR_POSTLEVELDISTINCTION.POSTLEVEL.ToString()
                                         select al.ALLOWANCE).FirstOrDefault();
                        }
                        //计算标准的基础数据
                        decimal? BasicData = sl.SALARYSUM;

                        //按照方案的薪资项集合生成薪资标准的薪资项
                        foreach (var item in salaryItems)
                        {
                            T_HR_SALARYSTANDARDITEM standItem = new T_HR_SALARYSTANDARDITEM();
                            standItem.STANDRECORDITEMID = Guid.NewGuid().ToString();
                            standItem.T_HR_SALARYITEMReference.EntityKey
                                = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYITEM", "SALARYITEMID", item.T_HR_SALARYITEM.SALARYITEMID);
                            // standItem.T_HR_SALARYITEM.SALARYITEMID = item.T_HR_SALARYITEM.SALARYITEMID;
                            standItem.CREATEUSERID = solution.CREATEUSERID;
                            standItem.T_HR_SALARYSTANDARDReference.EntityKey
                                = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYSTANDARD", "SALARYSTANDARDID", stand.SALARYSTANDARDID);
                            // standItem.T_HR_SALARYSTANDARD.SALARYSTANDARDID = stand.SALARYSTANDARDID;
                            standItem.CREATEDATE = System.DateTime.Now;
                            standItem.ORDERNUMBER = item.ORDERNUMBER;
                            //计算类型是手动输入的 金额是薪资项设置是输入的值
                            if (item.T_HR_SALARYITEM.CALCULATORTYPE == "1" || (item.T_HR_SALARYITEM.CALCULATORTYPE == "4" && item.T_HR_SALARYITEM.GUERDONSUM != null))
                            {
                                standItem.SUM = item.T_HR_SALARYITEM.GUERDONSUM.ToString();
                            }
                            //计算类型是公式计算 而且不是在生成薪资时计算  
                            else if (item.T_HR_SALARYITEM.CALCULATORTYPE == "3" && item.T_HR_SALARYITEM.ISAUTOGENERATE == "0")
                            {
                                standItem.SUM = bll.AutoCalculateItem(item.T_HR_SALARYITEM.SALARYITEMID, Convert.ToDecimal(BasicData), allowance.ToString()).ToString();
                            }
                            //地区差异补贴
                            else if (item.T_HR_SALARYITEM.ENTITYCOLUMNCODE == "AREADIFALLOWANCE")
                            {
                                standItem.SUM = allowance.ToString();
                            }
                            standSalaryitems.Add(standItem);
                        }
                        //SalaryStandardAdd(stand);
                        //itemBLL.SalaryStandardItemsAdd(standSalaryitems);
                        AddSalaryStanderAndItems(stand, standSalaryitems);
                        ShowMessage(txtMsg, "生成薪资标准:" + solution.SALARYSOLUTIONNAME + " " + stand.SALARYSTANDARDNAME + "成功!" + System.Environment.NewLine);
                    }
                }
                //dal.CommitTransaction();
                ShowMessage(txtMsg, "生成所有薪资标准成功!" + System.Environment.NewLine);
                MessageBox.Show("生成所有薪资标准成功!");
            }
            catch (Exception ex)
            {
                //dal.RollbackTransaction();
                MessageBox.Show("生成失败,错误信息:" + ex.ToString());
                SMT.Foundation.Log.Tracer.Debug(ex.Message);
            }
        }
Beispiel #17
0
        public void CreateSalaryStandBatch()
        {
            try
            {
                EmployeeSalaryRecordBLL bll     = new EmployeeSalaryRecordBLL();
                SalaryStandardItemBLL   itemBLL = new SalaryStandardItemBLL();

                string strsolutionall = @"上海神达物流有限公司薪资方案(A类城市)
                                上海酷武供应链管理服务有限公司薪资方案(A类)
                                北京市神通物流有限公司薪资方案(A类城市)
                                南京红之衣物流有限公司薪资方案(B类城市)
                                南宁市神州通货运代理有限公司薪资方案(D类城市)
                                南昌神州通物流有限公司薪资方案(E类城市)
                                合肥神州通物流有限公司薪资方案(D类城市)
                                哈尔滨神达通运输有限责任公司薪资方案(D类城市)
                                天津神州通物流有限公司薪资方案(C类城市)
                                太原市神通物流有限公司薪资方案(E类城市)
                                广州市神通物流有限公司薪资方案(A类城市)
                                成都通神州物流有限公司薪资方案(D类城市)
                                昆明神州通物流有限公司薪资方案(D类城市)
                                杭州新神州通货物运输有限公司薪资方案(B类城市)
                                武汉通神州仓储服务有限责任公司薪资方案(C类城市)
                                沈阳神州通物流有限公司薪资方案(C类城市)
                                济南神州通物流有限公司薪资方案(C类城市)
                                深圳市神州通物流有限公司薪资方案(A类城市)
                                深圳市神州通物流有限公司薪资方案(B类城市)
                                深圳市神州通物流有限公司薪资方案(C类城市)
                                深圳市神州通物流有限公司薪资方案(D类城市)
                                深圳市神州通物流有限公司薪资方案(E类城市)
                                深圳市神州通物流有限公司贵阳分公司(E类城市)
                                深圳市通神州物流公司薪资方案(A类城市)
                                石家庄神州通物流有限公司薪资方案(D类城市)
                                福州市神州通货运代理有限公司薪资方案(C类城市)
                                西安市神之通物流有限公司薪资方案(D类城市)
                                贵阳市神州通物流有限公司(E类城市)
                                郑州市神州通物流有限公司薪资方案(D类城市)
                                重庆新神州通物流有限公司薪资方案(D类城市)
                                长春市神之通物流有限公司薪资方案(D类城市)
                                长沙市神通物流服务有限公司薪资方案(C类城市)
                                青海神之通电子商务有限公司薪资方案(E类)";
                var    solutionAll    = (from ent in dal.GetObjects <T_HR_SALARYSOLUTION>().Include("T_HR_SALARYSYSTEM")
                                         where ent.SALARYSOLUTIONNAME.Contains(strsolutionall) &&
                                         ent.CHECKSTATE == "2"
                                         select ent).ToList();

                foreach (var solutionItem in solutionAll)
                {
                    solution = solutionItem;


                    standtmp = new T_HR_SALARYSTANDARD();
                    standtmp.SALARYSTANDARDID   = Guid.NewGuid().ToString();
                    standtmp.CREATECOMPANYID    = solution.CREATECOMPANYID;
                    standtmp.CREATEDEPARTMENTID = solution.CREATEDEPARTMENTID;
                    standtmp.CREATEPOSTID       = solution.CREATEPOSTID;
                    standtmp.CREATEUSERID       = solution.CREATEUSERID;

                    standtmp.OWNERCOMPANYID    = solution.OWNERCOMPANYID;
                    standtmp.OWNERDEPARTMENTID = solution.OWNERDEPARTMENTID;
                    standtmp.OWNERID           = solution.OWNERID;
                    standtmp.OWNERPOSTID       = solution.OWNERPOSTID;
                    //loadbar.Start();

                    // 薪资方案的体系ID
                    string salarySystemID = solution.T_HR_SALARYSYSTEM.SALARYSYSTEMID;
                    //薪资体系名
                    string salarySystemName = solution.T_HR_SALARYSYSTEM.SALARYSYSTEMNAME;
                    // 岗位级别名
                    string postLevelName = "";

                    //薪资方案所属的薪资体系
                    List <T_HR_SALARYLEVEL> salarylevelList = new List <T_HR_SALARYLEVEL>();
                    //薪资方案的薪资项集合
                    List <V_SALARYITEM> salaryItems = new List <V_SALARYITEM>();

                    salarylevelList = (from c in dal.GetObjects <T_HR_SALARYLEVEL>().Include("T_HR_POSTLEVELDISTINCTION")
                                       where c.T_HR_POSTLEVELDISTINCTION.T_HR_SALARYSYSTEM.SALARYSYSTEMID == salarySystemID
                                       select c).ToList().OrderBy(m => m.SALARYLEVEL).OrderBy(x => x.T_HR_POSTLEVELDISTINCTION.POSTLEVEL).ToList();

                    salaryItems = (from n in dal.GetObjects <T_HR_SALARYITEM>()
                                   join m in dal.GetObjects <T_HR_SALARYSOLUTIONITEM>() on n.SALARYITEMID equals m.T_HR_SALARYITEM.SALARYITEMID
                                   where m.T_HR_SALARYSOLUTION.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                   select new V_SALARYITEM
                    {
                        T_HR_SALARYITEM = n,
                        ORDERNUMBER = m.ORDERNUMBER
                    }
                                   ).ToList();

                    //方案所属地区差异补贴
                    List <T_HR_AREAALLOWANCE> areaAllowance = new List <T_HR_AREAALLOWANCE>();
                    areaAllowance = (from c in dal.GetObjects <T_HR_AREAALLOWANCE>()
                                     join b in dal.GetObjects <T_HR_SALARYSOLUTION>().Include("T_HR_AREADIFFERENCE") on c.T_HR_AREADIFFERENCE.AREADIFFERENCEID equals b.T_HR_AREADIFFERENCE.AREADIFFERENCEID
                                     where b.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                     select c).ToList();

                    int num = 0;

                    //dal.BeginTransaction();
                    foreach (var sl in salarylevelList)
                    {
                        var ent = from c in postlevels
                                  join b in salarylevelList on c.Value equals b.T_HR_POSTLEVELDISTINCTION.POSTLEVEL.ToString()
                                      where b.SALARYLEVELID == sl.SALARYLEVELID
                                  select c.Key;

                        if (ent.Count() > 0)
                        {
                            postLevelName = ent.FirstOrDefault().ToString();
                        }
                        var ents = (from a in dal.GetObjects <T_HR_SALARYSTANDARD>()
                                    where a.T_HR_SALARYLEVEL.SALARYLEVELID == sl.SALARYLEVELID &&
                                    a.SALARYSOLUTIONID == solution.SALARYSOLUTIONID
                                    select new
                        {
                            a.SALARYSTANDARDID,
                            a.SALARYSTANDARDNAME,
                            a.T_HR_SALARYLEVEL.SALARYLEVEL
                        });
                        if (ents.Count() > 0)
                        {
                            var checkEntity = ents.FirstOrDefault();
                            ShowMessage(txtMsg, "薪资标准已存在,跳过:" + solution.SALARYSOLUTIONNAME + " " + checkEntity.SALARYSTANDARDNAME + System.Environment.NewLine);
                            //已存在,跳过生成
                            continue;
                            //if (int.Parse(checkEntity.SALARYLEVEL) > 40)
                            //{
                            //    try {
                            //    var delentity = (from a in dal.GetObjects<T_HR_SALARYSTANDARD>().Include("T_HR_SALARYSTANDARDITEM")
                            //                     where a.SALARYSTANDARDID
                            //                     == checkEntity.SALARYSTANDARDID
                            //                     select a).FirstOrDefault();
                            //    foreach (var entity in delentity.T_HR_SALARYSTANDARDITEM)
                            //    {
                            //        dal.Delete(entity);
                            //    }
                            //    dal.Delete(delentity);
                            //    ShowMessage(txtMsg, "删除薪资标准成功!" + solution.SALARYSOLUTIONNAME + " " + checkEntity.SALARYSTANDARDNAME + System.Environment.NewLine);
                            //        }catch(Exception ex)
                            //    {
                            //        ShowMessage(txtMsg, "薪资标准已被使用,跳过:" + solution.SALARYSOLUTIONNAME + " " + checkEntity.SALARYSTANDARDNAME + System.Environment.NewLine);
                            //        continue;
                            //    }
                            //}
                            //else
                            //{
                            //    ShowMessage(txtMsg, "薪资标准已存在,跳过:" + solution.SALARYSOLUTIONNAME + " " + checkEntity.SALARYSTANDARDNAME + System.Environment.NewLine);
                            //    //已存在,跳过生成
                            //    continue;
                            //}
                        }
                        // 薪资体系的每条记录都对应一个标准 根据sl生成薪资标准
                        T_HR_SALARYSTANDARD stand = new T_HR_SALARYSTANDARD();
                        //薪资标准的薪资项集合
                        List <T_HR_SALARYSTANDARDITEM> standSalaryitems = new List <T_HR_SALARYSTANDARDITEM>();
                        //获取岗位级别名


                        //薪资标准名= 薪资体系名+岗位级别名+"-"+薪资级别名
                        stand.SALARYSTANDARDNAME = salarySystemName + postLevelName + "-" + sl.SALARYLEVEL.ToString();
                        stand.SALARYSTANDARDID   = Guid.NewGuid().ToString();
                        // stand.T_HR_SALARYLEVEL = new T_HR_SALARYLEVEL();
                        stand.T_HR_SALARYLEVELReference.EntityKey
                            = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYLEVEL", "SALARYLEVELID", sl.SALARYLEVELID);
                        //  stand.T_HR_SALARYLEVEL.SALARYLEVELID = sl.SALARYLEVELID;
                        stand.SALARYSOLUTIONID = solution.SALARYSOLUTIONID;
                        stand.CHECKSTATE       = "2";
                        stand.BASESALARY       = sl.SALARYSUM;
                        stand.CREATEDATE       = System.DateTime.Now;

                        //有关权限的字段
                        stand.CREATECOMPANYID    = standtmp.CREATECOMPANYID;
                        stand.CREATEDEPARTMENTID = standtmp.CREATEDEPARTMENTID;
                        stand.CREATEPOSTID       = standtmp.CREATEPOSTID;
                        stand.CREATEUSERID       = standtmp.CREATEUSERID;
                        stand.OWNERCOMPANYID     = standtmp.OWNERCOMPANYID;
                        stand.OWNERDEPARTMENTID  = standtmp.OWNERDEPARTMENTID;
                        stand.OWNERID            = standtmp.OWNERID;
                        stand.OWNERPOSTID        = standtmp.OWNERPOSTID;


                        //增加排序号
                        stand.PERSONALSIRATIO = num;
                        num++;


                        //标准对应的地区差异补贴(和岗位级别有关)
                        decimal?allowance = 0;
                        if (areaAllowance != null)
                        {
                            allowance = (from al in areaAllowance
                                         where al.POSTLEVEL == sl.T_HR_POSTLEVELDISTINCTION.POSTLEVEL.ToString()
                                         select al.ALLOWANCE).FirstOrDefault();
                        }
                        //计算标准的基础数据
                        decimal?BasicData = sl.SALARYSUM;

                        //按照方案的薪资项集合生成薪资标准的薪资项
                        foreach (var item in salaryItems)
                        {
                            T_HR_SALARYSTANDARDITEM standItem = new T_HR_SALARYSTANDARDITEM();
                            standItem.STANDRECORDITEMID = Guid.NewGuid().ToString();
                            standItem.T_HR_SALARYITEMReference.EntityKey
                                = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYITEM", "SALARYITEMID", item.T_HR_SALARYITEM.SALARYITEMID);
                            // standItem.T_HR_SALARYITEM.SALARYITEMID = item.T_HR_SALARYITEM.SALARYITEMID;
                            standItem.CREATEUSERID = solution.CREATEUSERID;
                            standItem.T_HR_SALARYSTANDARDReference.EntityKey
                                = new System.Data.EntityKey(qualifiedEntitySetName + "T_HR_SALARYSTANDARD", "SALARYSTANDARDID", stand.SALARYSTANDARDID);
                            // standItem.T_HR_SALARYSTANDARD.SALARYSTANDARDID = stand.SALARYSTANDARDID;
                            standItem.CREATEDATE  = System.DateTime.Now;
                            standItem.ORDERNUMBER = item.ORDERNUMBER;
                            //计算类型是手动输入的 金额是薪资项设置是输入的值
                            if (item.T_HR_SALARYITEM.CALCULATORTYPE == "1" || (item.T_HR_SALARYITEM.CALCULATORTYPE == "4" && item.T_HR_SALARYITEM.GUERDONSUM != null))
                            {
                                standItem.SUM = item.T_HR_SALARYITEM.GUERDONSUM.ToString();
                            }
                            //计算类型是公式计算 而且不是在生成薪资时计算
                            else if (item.T_HR_SALARYITEM.CALCULATORTYPE == "3" && item.T_HR_SALARYITEM.ISAUTOGENERATE == "0")
                            {
                                standItem.SUM = bll.AutoCalculateItem(item.T_HR_SALARYITEM.SALARYITEMID, Convert.ToDecimal(BasicData), allowance.ToString()).ToString();
                            }
                            //地区差异补贴
                            else if (item.T_HR_SALARYITEM.ENTITYCOLUMNCODE == "AREADIFALLOWANCE")
                            {
                                standItem.SUM = allowance.ToString();
                            }
                            standSalaryitems.Add(standItem);
                        }
                        //SalaryStandardAdd(stand);
                        //itemBLL.SalaryStandardItemsAdd(standSalaryitems);
                        AddSalaryStanderAndItems(stand, standSalaryitems);
                        ShowMessage(txtMsg, "生成薪资标准:" + solution.SALARYSOLUTIONNAME + " " + stand.SALARYSTANDARDNAME + "成功!" + System.Environment.NewLine);
                    }
                }
                //dal.CommitTransaction();
                ShowMessage(txtMsg, "生成所有薪资标准成功!" + System.Environment.NewLine);
                MessageBox.Show("生成所有薪资标准成功!");
            }
            catch (Exception ex)
            {
                //dal.RollbackTransaction();
                MessageBox.Show("生成失败,错误信息:" + ex.ToString());
                SMT.Foundation.Log.Tracer.Debug(ex.Message);
            }
        }