Пример #1
0
        public string Chk_EmpWHRecords(TaskHoursEmp model)
        {
            string res = string.Empty;

            if (model.StartTime > DateTime.Now || model.EndTime > DateTime.Now)
            {
                res = "开始or结束时间 不能超过当前时间!";
            }
            else
            {
                string         procName = "Proc_WHEmp_ChkEmpWHRecord";
                string         tName    = "WHRecordA";
                SqlParameter[] prams    =
                {
                    db.MakeInParam("@Id",      SqlDbType.Int,      100, model.Id),
                    db.MakeInParam("@STime",   SqlDbType.DateTime, 100, model.StartTime),
                    db.MakeInParam("@ETime",   SqlDbType.DateTime, 100, model.EndTime),
                    db.MakeInParam("@EmpCode", SqlDbType.NVarChar, 100, model.EmpCode),
                };
                DataTable dt = db.RunProcReturn(procName, prams, tName).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    int ChkFlag = Convert.ToInt32(dt.Rows[0]["ChkFlag"]);
                    if (ChkFlag == 1)
                    {
                        res = "当前用户存在未分配结束的任务工时——\r\n";
                        for (var i = 0; i < dt.Rows.Count; i++)
                        {
                            var taskTypeName = dt.Rows[i]["TaskTypeName"].ToString();
                            var taskName     = dt.Rows[i]["TaskName"].ToString();
                            res = res + taskTypeName + ":" + taskName + ";\r\n";
                        }
                    }
                    else
                    {
                        res = "当前用户以下时间段工时与本次记录冲突——\r\n";
                        foreach (DataRow row in dt.Rows)
                        {
                            TaskHourEmpViewModel dbEntry = DtToList.FillModel <TaskHourEmpViewModel>(row);
                            res = res + dbEntry.StartTime + "~" + dbEntry.EndTime + ";\r\n";
                        }
                    }
                }
            }
            return(res);
        }
Пример #2
0
        public TaskHourEmpViewModel Get_EmpRecordById(int id)
        {
            string procName = "Proc_WHEmp_GetRecordById";
            string tName    = "WHRecordA";

            SqlParameter[] prams =
            {
                db.MakeInParam("@Id", SqlDbType.Int, 100, id),
            };
            DataTable dt = db.RunProcReturn(procName, prams, tName).Tables[0];

            if (dt.Rows.Count > 0)
            {
                TaskHourEmpViewModel dbEntry = DtToList.FillModel <TaskHourEmpViewModel>(dt.Rows[0]);
                return(dbEntry);
            }
            return(new TaskHourEmpViewModel());
        }