示例#1
0
        public override List <T> GetSelectedRecords <T>(List <ColumnInfo> _parameter, bool paging, int start, int num, ref int totalRecordCount)
        {
            try
            {
                string sSql1 = BuildWhereSql("otcd,from|apdt,to|apdt,from|lmtm,to|lmtm,lmur", _parameter);
                string sSql2 = BuildWhereSql("sfid,stfn,emno", _parameter);

                var q = from p in gDB.totaplctns.Where(sSql1)
                        join t in gDB.vw_employments.Where(sSql2) on p.emno equals t.emno
                        join s in gDB.tottypes on p.otcd equals s.otcd
                        select new
                {
                    p.emno,
                    t.sfid,
                    stfn = t.ntnm,
                    p.lmtm,
                    p.lmur,
                    p.remk,
                    p.apdt,
                    p.frtm,
                    p.apno,
                    p.othr,
                    p.othm,
                    p.otst,
                    p.otcd,
                    p.totm,
                    frtm_date = UtilDatetime.FormatDate1(p.frtm),
                    frtm_time = UtilDatetime.FormatTime1(p.frtm),
                    totm_date = UtilDatetime.FormatDate1(p.totm),
                    totm_time = UtilDatetime.FormatTime1(p.totm)
                };

                List <T> obj = q.Cast <T>().ToList();

                totalRecordCount = obj.Count;

                List <T> appList = null;

                if (paging)
                {
                    appList = obj.Skip(start).Take(num).ToList();
                }
                else
                {
                    appList = obj;
                }

                return(appList);
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }
示例#2
0
        public void ApplyTo(List <vw_employment> _emps, tatpricld obj)
        {
            try
            {
                for (int i = 0; i < _emps.Count; i++)
                {
                    if (_emps[i].emno != obj.emno)
                    {
                        List <ColumnInfo> parameters = new List <ColumnInfo>()
                        {
                            new ColumnInfo()
                            {
                                ColumnName = "emno", ColumnValue = _emps[i].emno
                            },
                            new ColumnInfo()
                            {
                                ColumnName = "cddt", ColumnValue = UtilDatetime.FormatDate1(obj.cddt), ColumnType = "datetime"
                            }
                        };

                        tatpricld oldobj = GetSelectedObject <tatpricld>(parameters);

                        if (oldobj == null)
                        {
                            //新增
                            tatpricld newobj = new tatpricld();
                            newobj.emno = _emps[i].emno;
                            newobj.cddt = obj.cddt;
                            newobj.htcd = obj.htcd;
                            newobj.otcd = obj.otcd;
                            newobj.lmtm = obj.lmtm;
                            newobj.lmur = obj.lmur;

                            DoInsert <tatpricld>(newobj);
                        }
                        else
                        {
                            //更新
                            oldobj.htcd = obj.htcd;
                            oldobj.otcd = obj.otcd;
                            oldobj.lmtm = obj.lmtm;
                            oldobj.lmur = obj.lmur;

                            DoUpdate <tatpricld>(oldobj);
                        }
                    }
                }
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }
示例#3
0
        public int DeleteDummyData(string _sStaffSql, DateTime _startDate, DateTime _endDate)
        {
            string sSql = @"delete from tatanarst from 
                           tatanarst b inner join vw_employment emp 
                           on b.emno=emp.emno and " + _sStaffSql + @"
                           where (b.iscf is null or b.iscf='N') and  
                           b.atdt >='" + UtilDatetime.FormatDate1(_startDate) + @"' 
                           and b.atdt<'" + UtilDatetime.FormatDate1(_endDate) + "'";

            object[] parameters = { };
            return(gDB.ExecuteCommand(sSql, parameters));
        }
示例#4
0
        public void SaveOTDetail(string _emno, string _ottype, DateTime _otdt,
                                 DateTime _sttm, DateTime _endtime,
                                 double _othr, double _othrr, double _othm)
        {
            List <ColumnInfo> parameters = new List <ColumnInfo>()
            {
                new ColumnInfo()
                {
                    ColumnName = "emno", ColumnValue = _emno
                },
                new ColumnInfo()
                {
                    ColumnName = "otdt", ColumnValue = UtilDatetime.FormatDate1(_otdt), ColumnType = "datetime"
                },
                new ColumnInfo()
                {
                    ColumnName = "sttm", ColumnValue = UtilDatetime.FormateDateTime1(_sttm), ColumnType = "datetime"
                },
            };

            List <totdetail> list = new BaseDal().GetSelectedRecords <totdetail>(parameters);


            if (list.Count <= 0)
            {
                totdetail otdetail = new totdetail();
                otdetail.emno = _emno;
                otdetail.edtm = _endtime;
                otdetail.otdt = _otdt;
                otdetail.oths = _othr;
                otdetail.othm = _othm;
                otdetail.othr = _othrr;
                otdetail.otcd = _ottype;
                otdetail.sttm = _sttm;
                otdetail.lmtm = DateTime.Now;
                otdetail.lmur = Function.GetCurrentUser();

                gDB.totdetails.InsertOnSubmit(otdetail);
            }
            else
            {
                totdetail otdetail = list.First();
                otdetail.edtm = _endtime;
                otdetail.otcd = _ottype;
                otdetail.othr = _othr;
                otdetail.othr = _othrr;
                otdetail.lmtm = DateTime.Now;
                otdetail.lmur = Function.GetCurrentUser();
            }

            gDB.SubmitChanges();
        }
示例#5
0
        public List <tatdatmnu> GetManualData(string _sStaffSql, DateTime _startDate, DateTime _endDate)
        {
            string sSql = @"select a.* 
                              from tatdatmnu a 
                              inner join vw_employment emp 
                              on a.emno = emp.emno 
                            where (" + _sStaffSql + @") 
                            and atdt>='" + UtilDatetime.FormatDate1(_startDate) + @"'  
                            and atdt <'" + UtilDatetime.FormatDate1(_endDate) + "'";

            List <tatdatmnu> obj = gDB.ExecuteQuery <tatdatmnu>(sSql).ToList();

            return(obj);
        }
示例#6
0
        public List <tatoridat> GetOriginalData(string _sStaffSql, DateTime _startDate, DateTime _endDate)
        {
            string sSql = @"select a.* 
                              from tatoridat a 
                              inner join vw_employment emp 
                              on a.sfid = emp.sfid 
                            where (" + _sStaffSql + @") 
                            and retm>='" + UtilDatetime.FormatDate1(_startDate) + @"'  
                            and retm <'" + UtilDatetime.FormatDate1(_endDate) + "'";

            List <tatoridat> obj = gDB.ExecuteQuery <tatoridat>(sSql).ToList();

            return(obj);
        }
示例#7
0
        public int DeleteDummyData(string _sStaffSql, DateTime _startDate, DateTime _endDate)
        {
            string sSql = @"delete from totdetail from totdetail a where 
                           (isnull(a.othm,0) <= 0)
                           and exists (select b.atdt,b.emno,b.iscf from 
                           tatanarst b inner join vw_employment emp 
                           on b.emno=emp.emno and " + _sStaffSql + @"
                           where b.emno=a.emno and b.atdt=a.otdt 
                           and (b.iscf is null or b.iscf='N')  and 
                           b.atdt >='" + UtilDatetime.FormatDate1(_startDate) + @"' 
                           and b.atdt<'" + UtilDatetime.FormatDate1(_endDate) + "')";

            object[] parameters = { };
            return(gDB.ExecuteCommand(sSql, parameters));
        }
示例#8
0
        public List <tatroshi> GetRosterHistory(string _sStaffSql, DateTime _startDate, DateTime _endDate)
        {
            string sSql = @"select a.* 
                              from tatroshis a inner join tatroster c 
                                   on a.rscd=c.rscd 
                              inner join vw_employment emp 
                              on a.emno = emp.emno 
                            where (isnull(a.exdt,'3000-01-01') > '" + UtilDatetime.FormatDate1(_startDate) +
                          @"' and isnull(a.efdt,'3000-01-01') <='" + UtilDatetime.FormatDate1(_endDate) +
                          @"') and (isnull(a.exdt,'3000-01-01') > '" + UtilDatetime.FormatDate1(_startDate) +
                          @"' and isnull(a.efdt,'3000-01-01') <='" + UtilDatetime.FormatDate1(_endDate) + @"') 
                            and a.iaod='Y' and (" + _sStaffSql + @") 
                            order by a.efdt";

            List <tatroshi> obj = gDB.ExecuteQuery <tatroshi>(sSql).ToList();

            return(obj);
        }
示例#9
0
        public List <tatanarst> GetAnalResult(List <ColumnInfo> _parameter, string _sSqlStaff, DateTime _startDate, DateTime _endDate)
        {
            try
            {
                string sSql = @"select a.* from tatanarst a,vw_employment emp
                                where a.emno = emp.emno
                                and   " + _sSqlStaff + @"
                                and a.atdt>='" + UtilDatetime.FormatDate1(_startDate) + @"' 
                                and a.atdt<'" + UtilDatetime.FormatDate1(_endDate) + @"'";

                List <tatanarst> obj = gDB.ExecuteQuery <tatanarst>(sSql).ToList();

                return(obj);
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }
示例#10
0
        public void AnalyzeOT(ref AtCalculationInfo _store, tatshift curShift, List <tatoridat> _lstOriAtData, bool _isSaveDetail)
        {
            DateTime effOTStart = DateTime.Parse(UtilDatetime.FormatDate1(_store.CurDay) + " " + curShift.eati); // analatBll.CompareTime(_store.CurDay, curShift.eati, curShift.tmin);
            //有效加班时间=第二日最早有效上班打卡时间之前
            DateTime         effOTEnd      = effOTStart.AddDays(1);                                              //analatBll.CompareTime(_store.CurDay, curShift.tmot, curShift.lato);
            DateTime         otStart       = analatBll.CompareTime(_store.CurDay, curShift.tmin, curShift.nots);
            double           othr          = 0;
            double           othrReal      = 0;
            double           totalOthr     = 0;
            double           totalOthrReal = 0;
            List <tatshfott> lstShiftOT    = new List <tatshfott>();

            if (lstOTType == null)
            {
                lstOTType = analatBll.GetOTType();
            }
            lstShiftOT = new BaseBll().GetSelectedRecords <tatshfott>(new List <ColumnInfo>()
            {
            }).OrderBy(p => p.otst).ToList();

            string otType = AnalyzeOTType(_store, lstOTType);

            string           sfid            = _store.EmpInfo.sfid;
            List <tatoridat> lstEmpOriAtData = _lstOriAtData.Where(p => p.sfid == sfid &&
                                                                   p.retm >= effOTStart &&
                                                                   p.retm < effOTEnd)
                                               .OrderBy(p => p.retm)
                                               .ToList();

            if (lstEmpOriAtData.Count < 1)
            {
                //没有加班打卡记录
                othr          = 0;
                othrReal      = 0;
                totalOthr     = 0;
                totalOthrReal = 0;
            }
            else
            {
                otdetailDal dal = new otdetailDal();

                //有上班前加班打卡记录
                //暂时不考虑上班打卡,2009-01-01 by Administrator
                //if (lstEmpOriAtData.First().retm < _store.StdTimeIn)
                //{
                //    TimeSpan diff = _store.StdTimeIn.Value - lstEmpOriAtData.First().retm;
                //    if (diff.TotalMinutes > curShift.miot)
                //    {
                //        othr = (diff.TotalMinutes % curShift.otun.Value) * curShift.otun.Value / 60;
                //        othrReal = diff.TotalMinutes / 60;
                //    }
                //    else
                //    {
                //        othr = 0;
                //        othrReal = 0;
                //    }

                //    if ((_isSaveDetail) && (othr!=0))
                //        dal.SaveOTDetail(_store.EmpInfo.emno, otType, _store.CurDay, lstEmpOriAtData.First().retm, _store.StdTimeIn.Value, othr, othrReal, 0.0);
                //}

                //有下班后加班打卡记录
                if (lstEmpOriAtData.Last().retm > otStart)
                {
                    if (lstShiftOT.Count > 0)
                    {
                        //定义了加班权重
                        DateTime        retm = lstEmpOriAtData.Last().retm;
                        DateTime        otst;
                        List <DateTime> lstDateTime    = new List <DateTime>();
                        List <string>   lstShiftOTType = new List <string>();
                        lstDateTime.Add(otStart);

                        for (int i = 0; i < lstShiftOT.Count; i++)
                        {
                            tatshfott shiftOT = lstShiftOT[i];
                            otst = analatBll.CompareTime(otStart, otStart.ToString("HH:mm:ss"), shiftOT.otst);
                            if (otst > retm)
                            {
                                lstDateTime.Add(retm);
                            }
                            else
                            {
                                if (i == (lstShiftOT.Count - 1))
                                {
                                    lstDateTime.Add(retm);
                                }
                                else
                                {
                                    lstDateTime.Add(otst);
                                }
                            }
                            lstShiftOTType.Add(shiftOT.otcd);
                        }

                        for (int i = 1; i < lstDateTime.Count; i++)
                        {
                            //如果下一个时段的比最小加班时间小,则累计到上一个区间
                            TimeSpan diff1 = new TimeSpan(0, 0, 0);
                            if ((i + 1) <= (lstDateTime.Count - 1))
                            {
                                diff1 = lstDateTime[i + 1] - lstDateTime[i];
                                if (diff1.TotalMinutes > curShift.miot)
                                {
                                    diff1 = new TimeSpan(0, 0, 0);
                                }
                            }

                            TimeSpan diff = lstDateTime[i] - lstDateTime[i - 1] + diff1;
                            if (diff.TotalMinutes > curShift.miot)
                            {
                                othr     = Math.Floor(diff.TotalMinutes / curShift.otun.Value) * curShift.otun.Value / 60;
                                othrReal = diff.TotalMinutes / 60;

                                totalOthr     += othr;
                                totalOthrReal += othrReal;

                                if ((_isSaveDetail) && (othr != 0))
                                {
                                    dal.SaveOTDetail(_store.EmpInfo.emno, lstShiftOTType[i - 1], _store.CurDay, lstDateTime[i - 1], lstDateTime[i], othr, othrReal, 0);
                                }
                            }
                        }
                    }
                    else
                    {
                        //没有定义加班权重
                        TimeSpan diff = lstEmpOriAtData.Last().retm - otStart;
                        if (diff.TotalMinutes > curShift.miot)
                        {
                            othr     = Math.Floor(diff.TotalMinutes / curShift.otun.Value) * curShift.otun.Value / 60;
                            othrReal = diff.TotalMinutes / 60;

                            totalOthr     += othr;
                            totalOthrReal += othrReal;

                            if ((_isSaveDetail) && (othr != 0))
                            {
                                dal.SaveOTDetail(_store.EmpInfo.emno, otType, _store.CurDay, otStart, lstEmpOriAtData.Last().retm, othr, othrReal, 0);
                            }
                        }
                    }
                }
            }

            otcd           = otType;
            _store.OTHours = totalOthr;
        }
示例#11
0
        public void UpdateOTDetail(totdetail obj, List <ColumnInfo> _parameters)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    List <ColumnInfo> parameters = new List <ColumnInfo>()
                    {
                        new ColumnInfo()
                        {
                            ColumnName = "emno", ColumnValue = obj.emno
                        },
                        new ColumnInfo()
                        {
                            ColumnName = "otdt", ColumnValue = UtilDatetime.FormatDate1(obj.otdt), ColumnType = "datetime"
                        },
                        new ColumnInfo()
                        {
                            ColumnName = "sttm", ColumnValue = UtilDatetime.FormatDate1(obj.sttm), ColumnType = "datetime"
                        }
                    };

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


                    //如果自动转换成休假,则新增lvdfbyemp
                    double hoursToTTLV = 0;
                    int    lvdefseq    = 0;

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

                    tottype otType = GetSelectedObject <tottype>(ottypeParameters);

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

                    //更新detail的ttlv信息
                    obj.istr = hoursToTTLV == 0 ? "N" : "Y";
                    obj.ttlv = hoursToTTLV == 0 ? "" : otType.otcd;
                    obj.tlhr = hoursToTTLV;
                    obj.tlrf = lvdefseq.ToString();
                    obj.lmur = Function.GetCurrentUser();
                    obj.lmtm = DateTime.Now;

                    DoUpdate <totdetail>(obj, _parameters);

                    scope.Complete();
                }
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
            finally
            {
            }
        }
示例#12
0
        public void ApplyTo(List <vw_employment> _emps, tprpbrhi obj)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    for (int i = 0; i < _emps.Count; i++)
                    {
                        if (_emps[i].emno != obj.emno)
                        {
                            List <ColumnInfo> parameters = new List <ColumnInfo>()
                            {
                                new ColumnInfo()
                                {
                                    ColumnName = "emno", ColumnValue = _emps[i].emno
                                },
                                new ColumnInfo()
                                {
                                    ColumnName = "rscd", ColumnValue = obj.rscd
                                },
                                new ColumnInfo()
                                {
                                    ColumnName = "efdt", ColumnValue = UtilDatetime.FormatDate1(obj.efdt), ColumnType = "datetime"
                                }
                            };

                            tprpbrhi oldobj = GetSelectedObject <tprpbrhi>(parameters);

                            if (oldobj == null)
                            {
                                //新增
                                tprpbrhi newobj = new tprpbrhi();
                                newobj.efdt = obj.efdt;
                                newobj.emno = _emps[i].emno;
                                newobj.exdt = obj.exdt;
                                newobj.lmtm = obj.lmtm;
                                newobj.lmur = obj.lmur;
                                newobj.rscd = obj.rscd;

                                DoInsert <tprpbrhi>(newobj);
                            }
                            else
                            {
                                //更新
                                oldobj.exdt = obj.exdt;
                                oldobj.lmtm = obj.lmtm;
                                oldobj.lmur = obj.lmur;

                                DoUpdate <tprpbrhi>(oldobj);
                            }
                        }
                    }

                    scope.Complete();
                }
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }
示例#13
0
        public void SaveDataManu(List <tatdatmnu> _parameters, List <List <ColumnInfo> > lstIscf)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    for (int i = 0; i < _parameters.Count; i++)
                    {
                        List <ColumnInfo> parameters = new List <ColumnInfo>()
                        {
                            new ColumnInfo()
                            {
                                ColumnName = "emno", ColumnValue = _parameters[i].emno
                            },
                            new ColumnInfo()
                            {
                                ColumnName = "atdt", ColumnValue = UtilDatetime.FormatDate1(_parameters[i].atdt), ColumnType = "datetime"
                            }
                        };

                        tatdatmnu obj = GetSelectedObject <tatdatmnu>(parameters);

                        if (obj != null)
                        {
                            DoDelete <tatdatmnu>(obj);
                        }

                        tatdatmnu newobj = new tatdatmnu();
                        newobj.adam = _parameters[i].adam;
                        newobj.ahrm = _parameters[i].ahrm;
                        newobj.atdt = _parameters[i].atdt;
                        newobj.betm = _parameters[i].betm;
                        newobj.bstm = _parameters[i].bstm;
                        newobj.ectm = _parameters[i].ectm;
                        newobj.emno = _parameters[i].emno;
                        newobj.ittm = _parameters[i].ittm;
                        newobj.lmtm = _parameters[i].lmtm;
                        newobj.lmur = _parameters[i].lmur;
                        newobj.lctm = _parameters[i].lctm;
                        newobj.ottm = _parameters[i].ottm;
                        newobj.remk = _parameters[i].remk;
                        newobj.scdm = _parameters[i].scdm;

                        DoInsert <tatdatmnu>(newobj);

                        tatanarst analResult = GetSelectedObject <tatanarst>(parameters);

                        if (analResult != null)
                        {
                            analResult.betm  = newobj.betm;
                            analResult.bstm  = newobj.bstm;
                            analResult.itmm  = newobj.ittm;
                            analResult.otmm  = newobj.ottm;
                            analResult.ifma  = "Y";
                            analResult.iscf  = "N";
                            analResult.remk += newobj.remk;

                            DoUpdate <tatanarst>(analResult);
                        }
                    }

                    for (int i = 0; i < lstIscf.Count; i++)
                    {
                        List <ColumnInfo> parameters = new List <ColumnInfo>()
                        {
                            new ColumnInfo()
                            {
                                ColumnName = "emno", ColumnValue = lstIscf[i][0].ColumnValue
                            },
                            new ColumnInfo()
                            {
                                ColumnName = "atdt", ColumnValue = lstIscf[i][1].ColumnValue, ColumnType = "datetime"
                            }
                        };

                        tatanarst analResult = GetSelectedObject <tatanarst>(parameters);

                        if (analResult != null)
                        {
                            analResult.iscf = lstIscf[i][2].ColumnValue == "True" ? "Y" : "N";

                            DoUpdate <tatanarst>(analResult);
                        }
                    }
                    scope.Complete();
                }
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }
示例#14
0
        public void UpdateCalendar(tatcaldar obj, List <tatclddtl> list, List <string> deleteddobj)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    //delete first
                    for (int i = 0; i < deleteddobj.Count; i++)
                    {
                        List <ColumnInfo> parameters = new List <ColumnInfo>()
                        {
                            new ColumnInfo()
                            {
                                ColumnName = "clcd", ColumnValue = obj.clcd
                            },
                            new ColumnInfo()
                            {
                                ColumnName = "cddt", ColumnValue = deleteddobj[i], ColumnType = "datetime"
                            }
                        };

                        DoMultiDelete <tatclddtl>(parameters);
                        //List<tatclddtl> oldList = GetSelectedRecords<tatclddtl>(parameters);

                        //for (int j = 0; j < oldList.Count; j++)
                        //{
                        //    dal.DoDelete<tatclddtl>(oldList[j]);
                        //}
                    }

                    for (int i = 0; i < list.Count; i++)
                    {
                        List <ColumnInfo> parameters = new List <ColumnInfo>()
                        {
                            new ColumnInfo()
                            {
                                ColumnName = "clcd", ColumnValue = obj.clcd
                            },
                            new ColumnInfo()
                            {
                                ColumnName = "cddt", ColumnValue = UtilDatetime.FormatDate1(list[i].cddt), ColumnType = "datetime"
                            }
                        };

                        DoMultiDelete <tatclddtl>(parameters);
                    }

                    List <ColumnInfo> cldParameters = new List <ColumnInfo>()
                    {
                        new ColumnInfo()
                        {
                            ColumnName = "clcd", ColumnValue = obj.clcd
                        }
                    };
                    //update
                    DoUpdate <tatcaldar>(obj, cldParameters);

                    for (int i = 0; i < list.Count; i++)
                    {
                        dal.DoInsert <tatclddtl>(list[i]);
                    }

                    scope.Complete();
                }
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }
示例#15
0
        public void ApplyTo(List <string> _emps, totdetail obj)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    for (int i = 0; i < _emps.Count; i++)
                    {
                        if (_emps[i] != obj.emno)
                        {
                            List <ColumnInfo> parameters = new List <ColumnInfo>()
                            {
                                new ColumnInfo()
                                {
                                    ColumnName = "emno", ColumnValue = _emps[i]
                                },
                                new ColumnInfo()
                                {
                                    ColumnName = "otdt", ColumnValue = UtilDatetime.FormatDate1(obj.otdt), ColumnType = "datetime"
                                },
                                new ColumnInfo()
                                {
                                    ColumnName = "sttm", ColumnValue = UtilDatetime.FormatDate1(obj.sttm), ColumnType = "datetime"
                                }
                            };

                            totdetail oldobj = GetSelectedObject <totdetail>(parameters);

                            if (oldobj == null)
                            {
                                //新增
                                totdetail newobj = new totdetail();
                                newobj.emno = _emps[i];
                                newobj.edtm = obj.edtm;
                                newobj.lmtm = obj.lmtm;
                                newobj.lmur = obj.lmur;
                                newobj.otdt = obj.otdt;
                                newobj.othr = obj.othr;
                                newobj.othm = obj.othm;
                                newobj.oths = obj.oths;
                                newobj.otcd = obj.otcd;
                                newobj.sttm = obj.sttm;

                                DoInsert <totdetail>(newobj);
                            }
                            else
                            {
                                //更新
                                oldobj.edtm = obj.edtm;
                                oldobj.lmtm = obj.lmtm;
                                oldobj.lmur = obj.lmur;
                                oldobj.othr = obj.othr;
                                oldobj.othm = obj.othm;
                                oldobj.oths = obj.oths;
                                oldobj.otcd = obj.otcd;
                                DoUpdate <totdetail>(oldobj);
                            }
                        }
                    }

                    scope.Complete();
                }
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }
示例#16
0
        public void DoAnalyze(tlvleaapp _leaveApp, bool _isSaveDetail)
        {
            for (int i = 0; i < lstStaff.Count; i++)
            {
                TotalLvHours = 0;
                TotalLvDays  = 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, _leaveApp, _isSaveDetail);

                            tmpStart = tmpEnd;
                        }
                        else
                        {
                            //如果没有定义轮班该如何计算????
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
示例#17
0
        public void ApplyTo(List <vw_employment> _emps, object _obj)
        {
            try
            {
                tatroshi obj = _obj as tatroshi;

                for (int i = 0; i < _emps.Count; i++)
                {
                    if (_emps[i].emno != obj.emno)
                    {
                        List <ColumnInfo> parameters = new List <ColumnInfo>()
                        {
                            new ColumnInfo()
                            {
                                ColumnName = "emno", ColumnValue = _emps[i].emno
                            },
                            new ColumnInfo()
                            {
                                ColumnName = "efdt", ColumnValue = UtilDatetime.FormatDate1(obj.efdt.Value), ColumnType = "datetime"
                            }
                        };

                        tatroshi oldobj = dal.GetSelectedObject(parameters);

                        if (oldobj == null)
                        {
                            //新增
                            tatroshi newobj = new tatroshi();
                            newobj.emno = _emps[i].emno;
                            newobj.efdt = obj.efdt;
                            newobj.exdt = obj.exdt;
                            newobj.iaod = obj.iaod;
                            newobj.rscd = obj.rscd;
                            newobj.sqno = GetMaxsqno("tatroshis", _emps[i].emno).Value + 1;
                            newobj.lmtm = obj.lmtm;
                            newobj.lmur = obj.lmur;

                            if (CheckRosterHistory(newobj))
                            {
                                DoInsert <tatroshi>(newobj);
                            }
                        }
                        else
                        {
                            //更新
                            oldobj.exdt = obj.exdt;
                            oldobj.iaod = obj.iaod;
                            oldobj.rscd = obj.rscd;
                            oldobj.lmtm = obj.lmtm;
                            oldobj.lmur = obj.lmur;

                            if (CheckRosterHistory(oldobj))
                            {
                                DoUpdate <tatroshi>(oldobj);
                            }
                        }
                    }
                }
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
        }