Пример #1
0
        /// <summary>
        /// 生成考勤信息集合List
        /// </summary>
        /// <param name="AttendanceXml">考勤信息XML</param>
        /// <returns></returns>
        private IList <EyouSoft.Model.GovStructure.MGovAttendance> GetAttendanceList(string AttendanceXml)
        {
            if (string.IsNullOrEmpty(AttendanceXml))
            {
                return(null);
            }
            IList <EyouSoft.Model.GovStructure.MGovAttendance> ResultList = null;

            ResultList = new List <EyouSoft.Model.GovStructure.MGovAttendance>();
            XElement root = XElement.Parse(AttendanceXml);
            IEnumerable <XElement> xRow = root.Elements("row");

            foreach (XElement tmp1 in xRow)
            {
                EyouSoft.Model.GovStructure.MGovAttendance model = new EyouSoft.Model.GovStructure.MGovAttendance()
                {
                    AttendanceTime = DateTime.Parse(tmp1.Attribute("AttendanceTime").Value),
                    StaffId        = tmp1.Attribute("StaffId").Value,
                    Subject        = tmp1.Attribute("Subject").Value,
                    TimeCount      = (tmp1.Attribute("TimeCount") != null && tmp1.Attribute("TimeCount").Value.Trim() != "") ? Convert.ToDecimal(tmp1.Attribute("TimeCount").Value.Trim()) : 0,
                    AttendanceType = (EyouSoft.Model.EnumType.GovStructure.AttendanceType)Enum.Parse(typeof(EyouSoft.Model.EnumType.GovStructure.AttendanceType), tmp1.Attribute("AttendanceType").Value)
                };
                ResultList.Add(model);
                model = null;
            }
            return(ResultList);
        }
Пример #2
0
 /// <summary>
 /// 根据考勤编号获取单个考勤实体
 /// </summary>
 /// <param name="AttendanceId">考勤ID</param>
 /// <param name="CompanyId">公司编号</param>
 /// <returns></returns>
 public EyouSoft.Model.GovStructure.MGovAttendance GetGovAttendanceModel(string AttendanceId, string CompanyId)
 {
     EyouSoft.Model.GovStructure.MGovAttendance model = null;
     if (!string.IsNullOrEmpty(AttendanceId) && !string.IsNullOrEmpty(CompanyId))
     {
         model = new EyouSoft.Model.GovStructure.MGovAttendance();
         model = dal.GetGovAttendanceModel(AttendanceId, CompanyId);
     }
     return(model);
 }
Пример #3
0
        /// <summary>
        /// 按考勤时间获取员工考勤信息集合
        /// </summary>
        /// <param name="CompanyId">公司编号</param>
        /// <param name="StaffId">员工编号</param>
        /// <param name="AttendanceTime">考勤的时间</param>
        /// <returns></returns>
        public IList <EyouSoft.Model.GovStructure.MGovAttendance> GetList(string CompanyId, string StaffId, DateTime AttendanceTime)
        {
            EyouSoft.Model.GovStructure.MGovAttendance         model      = null;
            IList <EyouSoft.Model.GovStructure.MGovAttendance> ResultList = null;
            DbCommand dc = this._db.GetSqlStringCommand("SELECT AttendanceId,CompanyId,StaffId,AttendanceTime,AttendanceType,Subject,StartTime,EndTime,TimeCount,OperatorId,IssueTime FROM tbl_GovAttendance WHERE StaffId=@StaffId AND CompanyId=@CompanyId AND datediff(dd, @AttendanceTime, AttendanceTime) = 0");

            this._db.AddInParameter(dc, "CompanyId", DbType.AnsiStringFixedLength, CompanyId);
            this._db.AddInParameter(dc, "StaffId", DbType.AnsiStringFixedLength, StaffId);
            this._db.AddInParameter(dc, "AttendanceTime", DbType.DateTime, AttendanceTime);
            using (IDataReader dr = EyouSoft.Toolkit.DAL.DbHelper.ExecuteReader(dc, this._db))
            {
                ResultList = new List <EyouSoft.Model.GovStructure.MGovAttendance>();
                while (dr.Read())
                {
                    model = new EyouSoft.Model.GovStructure.MGovAttendance();
                    model.AttendanceId   = dr["AttendanceId"].ToString();
                    model.CompanyId      = dr["CompanyId"].ToString();
                    model.StaffId        = dr["StaffId"].ToString();
                    model.AttendanceTime = dr.GetDateTime(dr.GetOrdinal("AttendanceTime"));
                    model.AttendanceType = (EyouSoft.Model.EnumType.GovStructure.AttendanceType)dr.GetByte(dr.GetOrdinal("AttendanceType"));
                    model.OperatorId     = dr["OperatorId"].ToString();
                    model.IssueTime      = dr.GetDateTime(dr.GetOrdinal("IssueTime"));
                    model.Subject        = dr.IsDBNull(dr.GetOrdinal("Subject")) ? "" : dr["Subject"].ToString();
                    if (!dr.IsDBNull(dr.GetOrdinal("StartTime")))
                    {
                        model.StartTime = dr.GetDateTime(dr.GetOrdinal("StartTime"));
                    }
                    if (!dr.IsDBNull(dr.GetOrdinal("EndTime")))
                    {
                        model.EndTime = dr.GetDateTime(dr.GetOrdinal("EndTime"));
                    }
                    if (dr.IsDBNull(dr.GetOrdinal("TimeCount")) && !dr.IsDBNull(dr.GetOrdinal("StartTime")) && !dr.IsDBNull(dr.GetOrdinal("EndTime")))
                    {
                        //if (dr.GetByte(dr.GetOrdinal("AttendanceType")) == 4 || dr.GetByte(dr.GetOrdinal("AttendanceType")) == 6 || dr.GetByte(dr.GetOrdinal("AttendanceType")) == 7 || dr.GetByte(dr.GetOrdinal("AttendanceType")) == 8)
                        //Vacation请假=4,OverTime加班=5,Travel出差=6,Rest休假=7,Suspension停职=8
                        if (model.AttendanceType.ToString() == "请假" || model.AttendanceType.ToString() == "出差" || model.AttendanceType.ToString() == "休假" || model.AttendanceType.ToString() == "停职")
                        {
                            model.TimeCount = (dr.GetDateTime(dr.GetOrdinal("EndTime")) - dr.GetDateTime(dr.GetOrdinal("StartTime"))).Days;
                        }
                        //if (dr.GetByte(dr.GetOrdinal("AttendanceType")) == 5)
                        if (model.AttendanceType.ToString() == "加班")
                        {
                            model.TimeCount = (dr.GetDateTime(dr.GetOrdinal("EndTime")) - dr.GetDateTime(dr.GetOrdinal("StartTime"))).Hours;
                        }
                    }
                    else
                    {
                        model.TimeCount = dr.IsDBNull(dr.GetOrdinal("TimeCount")) ? 0 : dr.GetDecimal(dr.GetOrdinal("TimeCount"));
                    }
                    ResultList.Add(model);
                    model = null;
                }
            }
            return(ResultList);
        }