Example #1
0
        public void SaveOTDetail(totdetail obj)
        {
            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    //如果自动转换成休假,则新增lvdfbyemp
                    double hoursToTTLV = 0;
                    int    lvdefseq    = 0;

                    List <ColumnInfo> ottypeParameters = new List <ColumnInfo>()
                    {
                        new ColumnInfo()
                        {
                            ColumnName = "otcd", ColumnValue = obj.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 ? "" : obj.tottype.otcd;
                    obj.tlhr = hoursToTTLV;
                    obj.tlrf = lvdefseq.ToString();
                    obj.lmur = Function.GetCurrentUser();
                    obj.lmtm = DateTime.Now;

                    baseDal.DoInsert <totdetail>(obj);

                    scope.Complete();
                }
            }
            catch (UtilException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new UtilException(ex.Message, ex);
            }
            finally
            {
            }
        }
Example #2
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);
            }
        }
Example #3
0
        public double TransferToLeave(totdetail _otdetail, tottype _ottype, ref int lvdefseq)
        {
            otanaovtBll   bll         = new otanaovtBll();
            LvSettingInfo settingInfo = bll.GetEmpOTSettings(_otdetail.emno, _otdetail.otcd, _otdetail.sttm);

            double hoursToTTLV  = 0;
            double hoursForTTLV = (((_otdetail.othm == 0)) ? _otdetail.othr : _otdetail.othm).Value;

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

            if (hoursToTTLV > 0)
            {
                tlvdfbyem lvemp = new tlvdfbyem();
                //problem here,转换成天数后怎么统计
                lvemp.days = hoursToTTLV;
                lvemp.emno = _otdetail.emno;
                lvemp.exdt = _otdetail.sttm.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[" + "frtm:" + UtilDatetime.FormateDateTime1(_otdetail.sttm)
                             + ",totm:" + UtilDatetime.FormateDateTime1(_otdetail.edtm) + "]";
                int?maxsqno = GetMaxsqno("tlvdfbyem", _otdetail.emno);
                maxsqno    = maxsqno.HasValue == false ? 0 : maxsqno.Value;
                lvemp.sqno = maxsqno.Value + 1;

                DoInsert <tlvdfbyem>(lvemp);

                lvdefseq = lvemp.sqno;
            }

            return(hoursToTTLV);
        }
Example #4
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);
        }
Example #5
0
        public List <object> GetCalendarDetails(List <ColumnInfo> _parameter)
        {
            List <tatclddtl> result    = new List <tatclddtl>();
            DateTime         startDate = DateTime.Now;
            DateTime         endDate   = DateTime.Now;
            string           otcd      = string.Empty;
            string           htcd      = string.Empty;

            var q = from p in _parameter
                    where p.ColumnName == "stdt"
                    select p.ColumnValue;

            startDate = Convert.ToDateTime(q.Single());

            q = from p in _parameter
                where p.ColumnName == "endt"
                select p.ColumnValue;

            endDate = Convert.ToDateTime(q.Single());

            q = from p in _parameter
                where p.ColumnName == "otcd"
                select p.ColumnValue;

            otcd = q.Single();

            q = from p in _parameter
                where p.ColumnName == "htcd"
                select p.ColumnValue;

            htcd = q.Single();

            //tbssyscfgBll syscfgBll = new tbssyscfgBll();
            int  weekday   = Convert.ToUInt16(((StSystemConfig)Parameter.CURRENT_SYSTEM_CONFIG).AtWDPW);//syscfgBll.GetSysParameter_Weekwkdas();
            bool isHoliday = false;

            while (startDate <= endDate)
            {
                if (weekday == 5)
                {
                    if ((startDate.DayOfWeek == DayOfWeek.Saturday) || (startDate.DayOfWeek == DayOfWeek.Sunday))
                    {
                        isHoliday = true;
                    }
                    else
                    {
                        isHoliday = false;
                    }
                }
                else if (weekday == 6)
                {
                    if ((startDate.DayOfWeek == DayOfWeek.Sunday))
                    {
                        isHoliday = true;
                    }
                    else
                    {
                        isHoliday = false;
                    }
                }

                if (isHoliday)
                {
                    tatclddtl dtl = new tatclddtl()
                    {
                        cddt = startDate,
                        htcd = htcd,
                        otcd = otcd,
                        remk = "auto generation",
                        lmtm = DateTime.Now,
                        lmur = "System"
                    };
                    result.Add(dtl);
                }

                startDate = startDate.AddDays(1);
            }

            string  htnm    = string.Empty;
            string  otnm    = string.Empty;
            BaseBll baseBll = new BaseBll();

            tathldtyp ht = baseBll.GetSelectedObject <tathldtyp>(new List <ColumnInfo>()
            {
                new ColumnInfo()
                {
                    ColumnName = "htcd", ColumnValue = htcd
                }
            });

            htnm = ht.htnm;
            tottype ottype = baseBll.GetSelectedObject <tottype>(new List <ColumnInfo>()
            {
                new ColumnInfo()
                {
                    ColumnName = "otcd", ColumnValue = otcd
                }
            });

            otnm = ottype.otnm;

            var q1 = from p in result
                     select new
            {
                p.cddt,
                p.htcd,
                p.otcd,
                p.remk,
                p.lmtm,
                p.lmur,
                htnm = htnm,
                otnm = otnm
            };

            return(q1.Cast <object>().ToList());
        }
Example #6
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);
            }
        }
Example #7
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
            {
            }
        }