Exemple #1
0
        public void AnalyzeOvertime(List <ColumnInfo> _atdtParameters,
                                    List <ColumnInfo> _personalParameters, totaplctn _otApp, bool _isSaveDetail)
        {
            try
            {
                AnalStartDate = Convert.ToDateTime(_atdtParameters[0].ColumnValue);
                AnalEndDate   = Convert.ToDateTime(_atdtParameters[1].ColumnValue);

                analatBll.GetPersonals(_personalParameters, ref lstStaff, ref sSqlStaff, AnalStartDate);

                lstPriCalendar     = analatBll.GetPrivateCalendar(_personalParameters, sSqlStaff, AnalStartDate, AnalEndDate);
                lstCalendarDetails = analatBll.GetCalendar(AnalStartDate, AnalEndDate);
                lstRosterDetails   = analatBll.GetRosterDetails(AnalStartDate, AnalEndDate);
                lstRosterHistory   = analatBll.GetRosterHistory(sSqlStaff, AnalStartDate, AnalEndDate);
                lstOTType          = analatBll.GetOTType();
                lstOriAtData       = analatBll.GetOriginalData(sSqlStaff, AnalStartDate, AnalEndDate);

                DoAnalyze(_otApp, _isSaveDetail);
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }
Exemple #2
0
        public void Edit()
        {
            string message = "{}";

            try
            {
                string    record = this.Request["record"];
                Hashtable ht     = JavaScriptConvert.DeserializeObject <Hashtable>(record);

                List <ColumnInfo> parameters = JavaScriptConvert.DeserializeObject <List <ColumnInfo> >(ht["keycolumns"].ToString());

                totaplctn obj = JavaScriptConvert.DeserializeObject <totaplctn>(ht["params"].ToString());

                //new BaseBll().DoInsert<T>(obj);

                otaplctnBll bll = new otaplctnBll();
                bll.UpdateOTApplication(obj);

                message = "{status:'success',msg:'" + HRMSRes.Public_Message_EditWell + "'}";
            }
            catch (Exception ex)
            {
                message = "{status:'failure',msg:'" + ExceptionPaser.Parse(HRMSRes.Public_Message_EditBad, ex, true) + "'}";
            }
            Response.Write(message);
        }
Exemple #3
0
        public void CalcOTTime()
        {
            string message = "{}";

            try
            {
                string    record = this.Request["record"];
                Hashtable ht     = JavaScriptConvert.DeserializeObject <Hashtable>(record);

                totaplctn obj = new totaplctn();
                obj.emno = ht["emno"].ToString();
                obj.frtm = Convert.ToDateTime(ht["fromdate"].ToString());
                obj.totm = Convert.ToDateTime(ht["todate"].ToString());

                otaplctnBll bll  = new otaplctnBll();
                string      json = bll.CalcOTTime(obj);

                message = "{status:'success'," + json + "}";
            }
            catch (Exception ex)
            {
                message = "{status:'failure',msg:'" + ExceptionPaser.Parse(HRMSRes.Public_Message_EditBad, ex, true) + "'}";
            }
            Response.Write(message);
        }
Exemple #4
0
        public void SaveOTApplication(totaplctn _overtimeApp)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    //分析请假并保存
                    otaplctnBll bll = new otaplctnBll();

                    if (_overtimeApp.otst == "Approved")
                    {
                        //如果自动转换成休假,则新增lvdfbyemp
                        double hoursToTTLV = 0;
                        int    lvdefseq    = 0;

                        List <ColumnInfo> ottypeParameters = new List <ColumnInfo>()
                        {
                            new ColumnInfo()
                            {
                                ColumnName = "otcd", ColumnValue = _overtimeApp.otcd
                            }
                        };

                        tottype otType = GetSelectedObject <tottype>(ottypeParameters);

                        if (otType.autr == "Y")
                        {
                            otttlvBll ttlvBll = new otttlvBll();
                            hoursToTTLV = ttlvBll.TransferToLeave(_overtimeApp, otType, ref lvdefseq);
                        }

                        //如果审核,则更新otdetail
                        SaveToOvertimeDetail(_overtimeApp, hoursToTTLV, lvdefseq);
                    }

                    DoInsert <totaplctn>(_overtimeApp);

                    scope.Complete();
                }
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }
Exemple #5
0
        public double TransferToLeave(totaplctn _overtimeApp, tottype _ottype, ref int lvdefseq)
        {
            //自动转换成休假,会检查limit
            otanaovtBll   bll         = new otanaovtBll();
            LvSettingInfo settingInfo = bll.GetEmpOTSettings(_overtimeApp.emno, _overtimeApp.otcd, _overtimeApp.frtm);

            double hoursToTTLV  = 0;
            double hoursForTTLV = (((_overtimeApp.othm == 0) || (_overtimeApp.othm.HasValue == false)) ? _overtimeApp.othr : _overtimeApp.othm).Value;

            if (settingInfo.MinBalance >= hoursForTTLV)
            {
                hoursToTTLV = hoursForTTLV;
            }
            else
            {
                hoursToTTLV = settingInfo.MinBalance;
            }

            if (hoursToTTLV > 0)
            {
                tlvdfbyem lvemp = new tlvdfbyem();
                //problem here,转换成天数后怎么统计
                lvemp.days = settingInfo.MinBalance;
                lvemp.emno = _overtimeApp.emno;
                lvemp.exdt = _overtimeApp.frtm.AddYears(1); //default 1 year later
                lvemp.lmtm = DateTime.Now;
                lvemp.lmur = Constant.SYSTEM_USER_ID;
                lvemp.ltcd = _ottype.ttlv;
                lvemp.remk = "Transfer from overtime[appno:" + _overtimeApp.apno + ",frtm:" + UtilDatetime.FormateDateTime1(_overtimeApp.frtm)
                             + ",totm:" + UtilDatetime.FormateDateTime1(_overtimeApp.totm) + "]";
                lvemp.sqno = GetMaxsqno("tlvdfbyem", _overtimeApp.emno).Value;

                DoInsert <tlvdfbyem>(lvemp);

                lvdefseq = lvemp.sqno;
            }

            return(hoursToTTLV);
        }
Exemple #6
0
        private void SaveToOvertimeDetail(totaplctn _overtimeApp, double _hoursToTTLV, int _lvdefseq)
        {
            //如果OT申请审核了话,则插入otdetail
            totdetail dtl = new totdetail();

            dtl.emno = _overtimeApp.emno;
            dtl.edtm = _overtimeApp.totm;
            dtl.lmtm = _overtimeApp.lmtm;
            dtl.lmur = _overtimeApp.lmur;
            dtl.otdt = _overtimeApp.frtm;
            dtl.othr = _overtimeApp.othr;
            dtl.othm = _overtimeApp.othm;
            dtl.othr = 0;
            dtl.otcd = _overtimeApp.otcd;
            dtl.rfno = _overtimeApp.apno;
            dtl.sttm = _overtimeApp.frtm;
            dtl.istr = _hoursToTTLV == 0 ? "N" : "Y";
            dtl.ttlv = _hoursToTTLV == 0 ? "" : _overtimeApp.tottype.otcd;
            dtl.tlhr = _hoursToTTLV;
            dtl.tlrf = _lvdefseq.ToString();

            DoInsert <totdetail>(dtl);
        }
Exemple #7
0
        public string CalcOTTime(totaplctn _otApp)
        {
            try
            {
                //只分析请假
                otanaovtBll bll = new otanaovtBll();

                List <ColumnInfo> dateParameters = new List <ColumnInfo>();
                dateParameters.Add(new ColumnInfo()
                {
                    ColumnName = "otstart", ColumnValue = UtilDatetime.FormateDateTime1(_otApp.frtm), ColumnType = "datetime"
                });
                dateParameters.Add(new ColumnInfo()
                {
                    ColumnName = "otend", ColumnValue = UtilDatetime.FormateDateTime1(_otApp.totm), ColumnType = "datetime"
                });

                List <ColumnInfo> personParameters = new List <ColumnInfo>();
                personParameters.Add(new ColumnInfo()
                {
                    ColumnName = "emp.emno", ColumnValue = _otApp.emno
                });

                bll.AnalyzeOvertime(dateParameters, personParameters, null, false);

                return("totalothr:'" + bll.TotalOTHours.ToString() + "',otcd:'" + bll.otcd + "'");
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }
Exemple #8
0
        public void UpdateOTApplication(totaplctn _overtimeApp)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    otaplctnBll bll = new otaplctnBll();

                    List <ColumnInfo> apnoParameters = new List <ColumnInfo>()
                    {
                        new ColumnInfo()
                        {
                            ColumnName = "apno", ColumnValue = _overtimeApp.apno
                        }
                    };
                    List <ColumnInfo> dtlParameters = new List <ColumnInfo>()
                    {
                        new ColumnInfo()
                        {
                            ColumnName = "refno", ColumnValue = _overtimeApp.apno
                        }
                    };
                    totdetail dtl = GetSelectedObject <totdetail>(dtlParameters);
                    if (dtl != null)
                    {
                        //删除lvdfbyemp
                        //如果转换成的休假已经被申请了,则无法控制
                        List <ColumnInfo> lvdefempParameters = new List <ColumnInfo>()
                        {
                            new ColumnInfo()
                            {
                                ColumnName = "emno", ColumnValue = dtl.emno
                            },
                            new ColumnInfo()
                            {
                                ColumnName = "sqno", ColumnValue = dtl.tlrf.ToString(), ColumnType = "int"
                            }
                        };
                        DoDelete <tlvdfbyem>(lvdefempParameters);

                        //删除otdetail
                        dal.DeleteOTDtl(dtlParameters);
                    }

                    if (_overtimeApp.otst == "Approved")
                    {
                        //如果自动转换成休假,则新增lvdfbyemp
                        double hoursToTTLV = 0;
                        int    lvdefseq    = 0;

                        List <ColumnInfo> ottypeParameters = new List <ColumnInfo>()
                        {
                            new ColumnInfo()
                            {
                                ColumnName = "otcd", ColumnValue = _overtimeApp.otcd
                            }
                        };

                        tottype otType = GetSelectedObject <tottype>(ottypeParameters);

                        if (otType.autr == "Y")
                        {
                            otttlvBll ttlvBll = new otttlvBll();
                            hoursToTTLV = ttlvBll.TransferToLeave(_overtimeApp, otType, ref lvdefseq);
                        }

                        //如果审核,则更新otdetail
                        SaveToOvertimeDetail(_overtimeApp, hoursToTTLV, lvdefseq);
                    }

                    DoUpdate <totaplctn>(_overtimeApp, apnoParameters);

                    scope.Complete();
                }
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }
Exemple #9
0
        public void DoAnalyze(totaplctn _otApp, bool _isSaveDetail)
        {
            for (int i = 0; i < lstStaff.Count; i++)
            {
                TotalOTHours = 0;

                try
                {
                    DateTime calcStart = AnalStartDate;
                    DateTime calcEnd   = AnalEndDate;
                    DateTime tmpStart  = calcStart;
                    DateTime tmpEnd;

                    //如果加班跨天,需要拆分成多条数据
                    for (float k = 0; k < (calcEnd - calcStart).TotalDays; k++)
                    {
                        if ((calcEnd - tmpStart).TotalDays > 1)
                        {
                            tmpEnd = Convert.ToDateTime(UtilDatetime.FormatDate1(tmpStart.AddDays(1)) + " 00:00:00");
                        }
                        else
                        {
                            tmpEnd = calcEnd;
                        }

                        //取轮班历史
                        List <tatroshi> lstEmpRosterHistory = lstRosterHistory.Where(p => p.emno == lstStaff[i].emno &&
                                                                                     ((p.exdt.HasValue == false) ||
                                                                                      (p.exdt.Value > tmpEnd)) &&
                                                                                     (p.efdt <= tmpStart)
                                                                                     ).ToList();
                        //确定轮班和班次
                        if (lstEmpRosterHistory.Count > 0)
                        {
                            //如果发现多条,则只取第一条
                            tatroshi curRosterHistory = lstEmpRosterHistory[0];

                            List <tatrosdtl> lstEmpRosterDtl = lstRosterDetails.Where(p => p.rscd == curRosterHistory.rscd).ToList();

                            //确定轮班明细和班次
                            tatrosdtl curRosterDtl = getCurrentRoster(curRosterHistory, lstEmpRosterDtl, tmpStart);

                            tatshift curShift = curRosterDtl.tatshift;

                            //分析此天的加班
                            AnalyzeOneDay(lstStaff[i], curRosterDtl, curShift, curRosterHistory, tmpStart, tmpEnd, _otApp, _isSaveDetail);

                            tmpStart = tmpEnd;
                        }
                        else
                        {
                            //如果没有定义轮班该如何计算????
                        }
                    }
                }
                catch (Exception ex)
                {
                    string x = ex.Message;
                }
            }
        }
Exemple #10
0
        private void AnalyzeOneDay(vw_employment _emp, tatrosdtl curRosterDtl, tatshift curShift, tatroshi curRosterHistory, DateTime _calcStart, DateTime _calcEnd, totaplctn _otApp, 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);

            AnalyzeOT(ref store, curShift, lstOriAtData, _isSaveDetail);

            TotalOTHours += store.OTHours;
        }