예제 #1
0
파일: lvcryfwdDal.cs 프로젝트: zxlnet/hrms
        public double getCarryDaysByEmp(vw_employment empInfo, string _ltcd, double _year)
        {
            try
            {
                if (empInfo == null)
                {
                    return(0);
                }

                var q = from p in gDB.tlvcryfwds
                        where p.emno == empInfo.emno &&
                        p.year == (_year - 1).ToString() &&
                        p.ltcd == _ltcd
                        select new { days = p.days };

                if (q == null)
                {
                    return(0);
                }
                if (q.ToList().Count < 1)
                {
                    return(0);
                }

                return(q.ToList().Single().days.Value);

                //return q.
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }
예제 #2
0
        public double getYearTTLVHoursByEmp(vw_employment empInfo, string _otcd, DateTime _overtimeDate)
        {
            try
            {
                //查询本年消耗数
                var q = (from p in gDB.totdetails
                         where p.sttm.Year == _overtimeDate.Year &&
                         p.otcd == _otcd &&
                         p.emno == empInfo.emno
                         select p.tlhr).Sum();

                double tlhrConsumed = Convert.ToDouble(q);

                return(tlhrConsumed);
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }
예제 #3
0
파일: lvanalevBll.cs 프로젝트: zxlnet/hrms
        private void AnalyzeOneDay(vw_employment _emp, tatrosdtl curRosterDtl, tatshift curShift, tatroshi curRosterHistory, DateTime _calcStart, DateTime _calcEnd, tlvleaapp _leaveApp, bool _isSaveDetail)
        {
            store         = new AtCalculationInfo();
            store.EmpInfo = _emp;
            store.CurDay  = _calcStart;

            //curDayR = store.CurDay;

            //取得标准班次设定时间
            analatBll.GetStandardValue(curRosterDtl, curShift, ref store);

            //判断是否是休息日
            analatBll.CheckIsRestDay(curRosterDtl, curShift, curRosterHistory, lstPriCalendar, ref store);

            if (store.IsRestDay == false)
            {
                #region 非休息日
                if ((_calcStart <= store.StdTimeIn) && (_calcEnd >= store.StdTimeOut))
                {
                    //抓班次设定的工作小时数和天数
                    store.LvStart = store.StdTimeIn;
                    store.LvEnd   = store.StdTimeOut;

                    store.LvHours = Convert.ToDouble(curShift.wkhr);
                    store.LvDays  = Convert.ToDouble(curShift.wkda);
                }
                else
                {
                    if (_calcStart <= store.StdTimeIn)
                    {
                        store.LvStart = store.StdTimeIn;
                    }
                    else
                    {
                        store.LvStart = _calcStart;
                    }

                    if (_calcEnd >= store.StdTimeOut)
                    {
                        store.LvEnd = store.StdTimeOut;
                    }
                    else
                    {
                        store.LvEnd = _calcEnd;
                    }

                    store.LvHours = CountLeaveTime(store.LvStart, store.LvEnd, curShift, store);
                    store.LvHours = Math.Round(store.LvHours, 2);
                    //计算天数
                    store.LvDays = Math.Round((store.LvHours / Convert.ToDouble(curShift.wkhr)) * Convert.ToDouble(curShift.wkda), 2);
                }
                #endregion
            }
            else
            {
                #region 休息日
                store.LvHours = 0;
                store.LvDays  = 0;
                #endregion
            }

            TotalLvHours += store.LvHours;
            TotalLvDays  += store.LvDays;

            if ((_isSaveDetail) && (_leaveApp != null) && (store.LvHours > 0))
            {
                //如果需要保存则保存每一条明细到DTL表
                tlvleaapd newdtl = new tlvleaapd();

                newdtl.emno = _emp.emno;
                newdtl.days = store.LvDays;
                newdtl.hurs = store.LvHours;
                newdtl.ltcd = _leaveApp.ltcd;
                newdtl.apno = _leaveApp.apno;
                newdtl.totm = store.LvEnd.Value;
                newdtl.frtm = store.LvStart.Value;

                DoInsert <tlvleaapd>(newdtl);
            }
        }
예제 #4
0
        public double GetlmbyEmp(vw_employment empInfo, string _ltcd, HRMS_Limit_Scope _scope, HRMS_Limit_Type _limitType)
        {
            try
            {
                double lmbyEmpHours   = -1;
                double lmbyYearHours  = -1;
                double lmbyOtherHours = -1;

                double lmbyEmpCarryHours   = -1;
                double lmbyYearCarryHours  = -1;
                double lmbyOtherCarryHours = -1;

                //针对员工的设定
                var q = (from p in gDB.tlvlealmts
                         where p.lmsp == _scope.ToString() &&
                         (p.ltcd == _ltcd || (_ltcd == "ALL")) &&
                         p.lmby == HRMS_Limit_By.E.ToString() &&
                         p.lmva == empInfo.emno
                         select p).ToList <tlvlealmt>();

                for (int i = 0; i < q.Count; i++)
                {
                    lmbyEmpHours      = q[i].mxlh.Value;
                    lmbyEmpCarryHours = q[i].mxch.Value;
                    break;
                }

                //针对服务年数的设定
                q = (from p in gDB.tlvlealmts
                     where p.lmsp == _scope.ToString() &&
                     (p.ltcd == _ltcd || (_ltcd == "ALL")) &&
                     p.lmby == HRMS_Limit_By.Y.ToString() &&
                     p.lmva == empInfo.yearservice.ToString()
                     select p).ToList <tlvlealmt>();

                for (int i = 0; i < q.Count; i++)
                {
                    lmbyYearHours      = q[i].mxlh.Value;
                    lmbyYearCarryHours = q[i].mxch.Value;
                    break;
                }

                //针对其他项目的设定

                q = (from p in gDB.tlvlealmts
                     join s in gDB.tstdefcfgs on p.lmby equals s.dfnm
                     where (p.ltcd == _ltcd || (_ltcd == "ALL")) &&
                     p.lmby != HRMS_Limit_By.E.ToString() && p.lmby != HRMS_Limit_By.Y.ToString() &&
                     p.lmsp == _scope.ToString()
                     //&& p.lmva == empInfo.GetType().GetProperty(s.fieldname).GetValue(empInfo, null).ToString()
                     select p).ToList <tlvlealmt>();

                var q1 = (from p in q
                          where p.lmva == empInfo.GetType().GetProperty(p.tstdefcfg.finm).GetValue(empInfo, null).ToString().Trim()
                          select p).ToList();

                for (int i = 0; i < q1.Count; i++)
                {
                    lmbyOtherHours      = q1[i].mxlh.Value;
                    lmbyOtherCarryHours = q1[i].mxch.Value;
                    break;
                }

                double r = 0;
                switch (_limitType)
                {
                case HRMS_Limit_Type.LeaveHours:
                    r = ((lmbyEmpHours == -1 ? 0 : lmbyEmpHours) + (lmbyYearHours == -1 ? 0 : lmbyYearHours) + (lmbyOtherHours == -1 ? 0 : lmbyOtherHours));
                    break;

                case HRMS_Limit_Type.LeaveCarryforwardHours:
                    r = ((lmbyEmpCarryHours == -1 ? 0 : lmbyEmpCarryHours) + (lmbyYearCarryHours == -1 ? 0 : lmbyYearCarryHours) + (lmbyOtherCarryHours == -1 ? 0 : lmbyOtherCarryHours));
                    break;

                default:
                    r = 0;
                    break;
                }

                return(r == 0 ? -1 : r);
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }
예제 #5
0
파일: otlimitDal.cs 프로젝트: zxlnet/hrms
 public double GetMonthlmbyEmp(vw_employment empInfo, string _otcd, HRMS_Limit_Type _limitType)
 {
     return(GetlmbyEmp(empInfo, _otcd, HRMS_Limit_Scope.Month, _limitType));
 }
예제 #6
0
 public double GetYearlmbyEmp(vw_employment empInfo, string _ltcd, HRMS_Limit_Type _limitType)
 {
     return(GetlmbyEmp(empInfo, _ltcd, HRMS_Limit_Scope.Year, _limitType));
 }
예제 #7
0
        public void CalculateOneByOne(vw_employment currentStaff, List <tprsalhi> lstCurrentSalaryHistory, List <tprbaalcr> lstCurrentAccountAllocateRule, List <tpsaccont> lstCurrentAccount)
        {
            for (int i = 0; i < lstCurrentSalaryHistory.Count; i++)
            {
                try
                {
                    log.LogInfoWithLevel("Salary Item[" + lstCurrentSalaryHistory[i].itcd + "].", Log_LoggingLevel.Admin);
                    List <tprbaalcr> lstRule = lstCurrentAccountAllocateRule.Where(p => p.itcd == lstCurrentSalaryHistory[i].itcd).ToList();
                    string           vtyp    = string.Empty;
                    double           valu    = 0;
                    string           acno    = string.Empty;
                    double           tmpSum  = 0;
                    int sqno = 0;

                    for (int j = 0; j < lstRule.Count; j++)
                    {
                        //有针对该itcd的分配规则
                        //如果定义了多套规则,则取第一套,其他忽略
                        vtyp = lstRule[j].vtyp;
                        valu = lstRule[j].valu.HasValue?lstRule[j].valu.Value:0;
                        acno = lstRule[j].acno;

                        log.LogInfoWithLevel("Rule definied at salary item [" + vtyp + "," + valu.ToString() + "," + acno + "].", Log_LoggingLevel.Admin);

                        sqno++;
                        tmpSum += HandleIt(currentStaff, lstCurrentSalaryHistory[i], vtyp, valu, acno, sqno);
                    }

                    if (lstRule.Count <= 0)
                    {
                        //无针对该itcd的分配规则
                        lstRule = lstCurrentAccountAllocateRule.Where(p => p.itcd == string.Empty).ToList();
                        for (int n = 0; n < lstRule.Count; n++)
                        {
                            //有针对所有itcd定义的分配规则
                            vtyp = lstRule[n].vtyp;
                            valu = lstRule[n].valu.HasValue ? lstRule[n].valu.Value : 0;
                            acno = lstRule[n].acno;

                            log.LogInfoWithLevel("Rule definied at all salary item [" + vtyp + "," + valu.ToString() + "," + acno + "].", Log_LoggingLevel.Admin);

                            sqno++;
                            tmpSum += HandleIt(currentStaff, lstCurrentSalaryHistory[i], vtyp, valu, acno, sqno);
                        }

                        if (lstRule.Count <= 0)
                        {
                            //无针对所有itcd定义的分配规则
                            if (lstCurrentAccount.Count > 0)
                            {
                                //有默认账号,100%分配到该账号
                                vtyp = "Percentage";
                                valu = 100;
                                acno = lstCurrentAccount[0].acno;

                                log.LogInfoWithLevel("Allocate 100% to default account[" + acno + "].", Log_LoggingLevel.Admin);

                                sqno++;
                                tmpSum += HandleIt(currentStaff, lstCurrentSalaryHistory[i], vtyp, valu, acno, sqno);
                            }
                            else
                            {
                                log.LogInfoWithLevel("No any setting(s) found,do not allocate it.", Log_LoggingLevel.Admin);
                                //无默认账号,不分配
                                vtyp = string.Empty;
                                valu = 0;
                                acno = string.Empty;
                            }
                        }
                    }

                    //余额分配到默认账号,如果没有定义,则不分配
                    if (tmpSum < lstCurrentSalaryHistory[i].valu)
                    {
                        if (lstCurrentAccount.Count > 0)
                        {
                            acno = lstCurrentAccount[0].acno;

                            log.LogInfoWithLevel("Left amount [" + (lstCurrentSalaryHistory[i].valu - tmpSum).ToString() + "] was allocate to default account[" + acno + "].", Log_LoggingLevel.Admin);

                            sqno++;
                            HandleLeft(currentStaff, lstCurrentSalaryHistory[i], (lstCurrentSalaryHistory[i].valu - tmpSum), acno, sqno);
                        }
                    }
                }
                catch (Exception ex)
                {
                    log.LogInfoWithLevel("Error found,ignore it. Error message:[" + ex.Message + ".", Log_LoggingLevel.Admin);
                }
            }
        }
예제 #8
0
        public void Publish(List <vw_employment> lstEmp, string trcd, string isEmail, string isBoard)
        {
            try
            {
                List <ColumnInfo> lstParameters = new List <ColumnInfo>()
                {
                    new ColumnInfo()
                    {
                        ColumnName = "trcd", ColumnValue = trcd
                    }
                };

                ttrtraing tra = new BaseBll().GetSelectedObject <ttrtraing>(lstParameters);

                if (tra == null)
                {
                    return;
                }

                using (TransactionScope scope = new TransactionScope())
                {
                    for (int i = 0; i < lstEmp.Count; i++)
                    {
                        vw_employment emp = lstEmp[i];

                        ttrtraatt att = new ttrtraatt();
                        att.emno = emp.emno;
                        att.isat = "N";
                        att.isrg = "N";
                        att.lmtm = DateTime.Now;
                        att.lmur = Function.GetCurrentUser();
                        att.trcd = trcd;

                        DoInsert <ttrtraatt>(att);

                        alarmBll alaBll = new alarmBll();
                        if (isEmail == "Y")
                        {
                            //发Email
                            tstalarm alarmMdl = alaBll.BuildAlarmMdl(Alarm_AlarmType.Email, "Training: " + tra.trnm,
                                                                     alaBll.BuildTrainingAlarmBody(tra, att.emno), emp.emno, string.Empty,
                                                                     "Training", DateTime.Now.AddDays(1), string.Empty);

                            DoInsert <tstalarm>(alarmMdl);
                        }

                        if (isBoard == "Y")
                        {
                            //发送Board
                            tstalarm alarmMdl = alaBll.BuildAlarmMdl(Alarm_AlarmType.Board, "Training: " + tra.trnm,
                                                                     alaBll.BuildTrainingAlarmBody(tra, att.emno), emp.emno, string.Empty,
                                                                     "Training", DateTime.Now.AddDays(1), string.Empty);

                            DoInsert <tstalarm>(alarmMdl);
                        }

                        //update ispb标识
                        tra.ispb = "Y";

                        DoUpdate <ttrtraing>(tra, lstParameters);
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #9
0
        public string GetRecipicientsEmail(string _emno)
        {
            List <string> lstRole = new List <string>();
            vw_employment emp     = GetSelectedObject <vw_employment>(new List <ColumnInfo>()
            {
                new ColumnInfo()
                {
                    ColumnName = "emno", ColumnValue = _emno
                }
            });

            if (emp != null)
            {
                for (int i = 0; i < lstAlarmSubs.Count; i++)
                {
                    PropertyInfo prop = emp.GetType().GetProperty(lstAlarmSubs[i].attr);
                    if (prop != null)
                    {
                        if (prop.GetValue(emp, null).ToString() == lstAlarmSubs[i].atva.Trim())
                        {
                            lstRole.Add("[" + lstAlarmSubs[i].alpf + "]");
                        }
                    }
                }
            }

            string strRole = lstRole.ToArray().ToString();

            StSystemConfig sysCfg = (StSystemConfig)Parameter.CURRENT_SYSTEM_CONFIG;

            string strReci = string.Empty;

            if (sysCfg.ScSBAD == "Y")
            {
                var q = (from p in lstUserRoleAD
                         where strRole.Contains("[" + p.alpf + "]") == true
                         select p).ToList();

                for (int i = 0; i < q.Count; i++)
                {
                    string email = q[i].cota1.Trim() == string.Empty ? q[i].cota2.Trim() : q[i].cota1.Trim();

                    if (email != string.Empty)
                    {
                        strReci += (strReci.Trim() == string.Empty) ? "" : "," + email;
                    }
                }
            }
            else
            {
                var q = (from p in lstUserRoleNonAD
                         where strRole.Contains("[" + p.alpf + "]") == true
                         select p).ToList();

                for (int i = 0; i < q.Count; i++)
                {
                    string email = q[i].cota1.Trim() == string.Empty ? q[i].cota2.Trim() : q[i].cota1.Trim();

                    if (email != string.Empty)
                    {
                        strReci += (strReci.Trim() == string.Empty) ? "" : "," + email;
                    }
                }
            }

            return(strReci);
        }
예제 #10
0
        public string GetRecipicientsBoard(string _emno)
        {
            //List<string> lstRole = new List<string>();
            vw_employment emp = GetSelectedObject <vw_employment>(new List <ColumnInfo>()
            {
                new ColumnInfo()
                {
                    ColumnName = "emno", ColumnValue = _emno
                }
            });
            string strRole = string.Empty;

            if (emp != null)
            {
                for (int i = 0; i < lstAlarmSubs.Count; i++)
                {
                    if (lstAlarmSubs[i].attr == "*")
                    {
                        //订阅全部员工的消息
                        strRole += (strRole == string.Empty ? "" : ",") + "[" + lstAlarmSubs[i].alpf + "]";
                    }
                    else
                    {
                        PropertyInfo prop = emp.GetType().GetProperty(lstAlarmSubs[i].attr);
                        if (prop != null)
                        {
                            object v = prop.GetValue(emp, null);
                            if (v != null)
                            {
                                if (v.ToString() == lstAlarmSubs[i].atva.Trim())
                                {
                                    strRole += (strRole == string.Empty ? "" : ",") + "[" + lstAlarmSubs[i].alpf + "]";
                                }
                            }
                        }
                    }
                }
            }

            StSystemConfig sysCfg = (StSystemConfig)Parameter.CURRENT_SYSTEM_CONFIG;

            string strReci = string.Empty;

            if (sysCfg.ScSBAD == "Y")
            {
                var q = (from p in lstUserRole
                         where strRole.Contains("[" + p.alpf + "]") == true
                         select p).ToList();

                for (int i = 0; i < q.Count; i++)
                {
                    if (q[i].sfid != null && q[i].sfid.Trim() != string.Empty)
                    {
                        strReci += (strReci.Trim() == string.Empty ? "" : ",") + q[i].sfid;
                    }
                }
            }
            else
            {
                var q = (from p in lstUser
                         where strRole.Contains("[" + p.alpf + "]") == true
                         select p).ToList();

                for (int i = 0; i < q.Count; i++)
                {
                    if (q[i].sfid != null && q[i].sfid.Trim() != string.Empty)
                    {
                        strReci += (strReci.Trim() == string.Empty ? "" : ",") + q[i].sfid;
                    }
                }
            }

            return(strReci);
        }
예제 #11
0
파일: lvcryfwdBll.cs 프로젝트: zxlnet/hrms
        public void DoCarryforward(vw_employment _emp, string _ltcd, int _yearToCarry)
        {
            try
            {
                #region get Standard Work Hours
                double stdWorkHours    = 0;
                string strStdWorkHours = ((StSystemConfig)Parameter.CURRENT_SYSTEM_CONFIG).PrSWHPD;

                try
                {
                    if (strStdWorkHours == string.Empty)
                    {
                        stdWorkHours = 8;
                    }
                    else
                    {
                        stdWorkHours = Convert.ToDouble(strStdWorkHours);
                    }
                }
                catch
                {
                    stdWorkHours = 8;
                }
                #endregion

                double        leaveEntitlement = 0;
                double        hoursToCarry     = 0;
                LvSettingInfo settingInfo      = new LvSettingInfo();
                settingInfo.emp = _emp;

                DateTime startDate = new DateTime(_yearToCarry, 1, 1);
                DateTime endDate   = new DateTime(_yearToCarry, 12, 31);

                //根据员工个人设定
                lvdfbyempDal empDal = new lvdfbyempDal();
                settingInfo.dfbyEmployment = empDal.getLeaveSettingsByEmp(_emp.emno, _ltcd, endDate);
                leaveEntitlement           = settingInfo.dfbyEmployment;

                //根据服务年数设定
                double         yearDiff = DateTime.Now.Year - _yearToCarry;
                lvdfbyyearsDal yearDal  = new lvdfbyyearsDal();
                settingInfo.dfbyYear = yearDal.getLeaveSettingsByYear(_ltcd, (settingInfo.emp.yearservice.Value - yearDiff) < 0 ? 0 : (settingInfo.emp.yearservice.Value - yearDiff));
                leaveEntitlement    += settingInfo.dfbyYear;

                //根据其他设定
                lvdfbyotDal      otherDay          = new lvdfbyotDal();
                List <tlvdfbyod> lstSettingByOther = otherDay.getLeaveSettingsByOther(settingInfo.emp, _ltcd);

                var q1 = (from p in lstSettingByOther
                          where p.tlvdfbyot.dfva == settingInfo.emp.GetType().GetProperty(p.tlvdfbyot.tstdefcfg.finm).GetValue(settingInfo.emp, null).ToString().Trim()
                          where p.fryr <= ((settingInfo.emp.yearservice - yearDiff) < 0 ? 0 : (settingInfo.emp.yearservice - yearDiff)) &&
                          p.toyr >= (((settingInfo.emp.yearservice - yearDiff) - 1) < 0 ? 0 : ((settingInfo.emp.yearservice - yearDiff) - 1)) &&
                          p.tlvdfbyot.ltcd == _ltcd
                          select p).ToList();

                for (int i = 0; i < q1.Count; i++)
                {
                    settingInfo.dfbyOthers += lstSettingByOther[i].days;
                    leaveEntitlement       += lstSettingByOther[i].days;
                }

                //取得上年结转
                lvcryfwdDal carryDal = new lvcryfwdDal();
                settingInfo.DaysCarry = carryDal.getCarryDaysByEmp(settingInfo.emp, _ltcd, startDate.Year);
                leaveEntitlement     += settingInfo.DaysCarry;

                //取得最大限制
                lvlealmtDal limitDal = new lvlealmtDal();
                settingInfo.YearLimit = limitDal.GetYearlmbyEmp(settingInfo.emp, _ltcd, HRMS_Limit_Type.LeaveCarryforwardHours);

                //取得已经休假小时数
                lvleaappDal appDal = new lvleaappDal();
                settingInfo.YearConsume = appDal.getYearConsumedByEmp(settingInfo.emp, _ltcd, startDate);

                if ((settingInfo.YearLimit != -1) && (Math.Round(settingInfo.YearLimit / stdWorkHours, 2) <= (leaveEntitlement - Math.Round(settingInfo.YearConsume / stdWorkHours, 2))))
                {
                    //settingInfo.YearBalance = Math.Round(settingInfo.YearLimit - settingInfo.YearConsume, 2);
                    hoursToCarry = settingInfo.YearLimit;
                }
                else
                {
                    hoursToCarry = leaveEntitlement * stdWorkHours - settingInfo.YearConsume;
                }

                #region 保存
                bool isNeedToSave = true;


                if (((StSystemConfig)Parameter.CURRENT_SYSTEM_CONFIG).LvINCV == "Y")
                {
                    if (hoursToCarry <= 0)
                    {
                        hoursToCarry = 0;
                    }
                }

                if (isNeedToSave &&
                    (settingInfo.YearConsume != 0 ||
                     leaveEntitlement != 0 || settingInfo.YearLimit != -1 || hoursToCarry != 0))
                {
                    tlvcryfwd carryForward = new tlvcryfwd();
                    carryForward.daro = null;
                    carryForward.days = Math.Round(hoursToCarry / stdWorkHours, 2);
                    carryForward.hrcs = 0;
                    carryForward.emno = _emp.emno;
                    carryForward.hors = hoursToCarry;
                    carryForward.ltcd = _ltcd;
                    carryForward.year = _yearToCarry.ToString();
                    carryForward.lmur = Function.GetCurrentUser();
                    carryForward.lmtm = DateTime.Now;
                    carryForward.cnsu = settingInfo.YearConsume;
                    carryForward.enti = leaveEntitlement;
                    carryForward.limt = settingInfo.YearLimit;

                    DoInsert <tlvcryfwd>(carryForward);
                }
                #endregion
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }