示例#1
0
        public int Save_EmpWHRecords(TaskHoursEmp model)
        {
            string   procName      = "Proc_WHEmp_SaveWHRecord";
            DateTime _sTime        = model.StartTime;
            DateTime _eTime        = model.EndTime == new DateTime(1, 1, 1) ? new DateTime(1900, 1, 1) : model.EndTime;
            DateTime _approvalTime = model.ApprovalTime == new DateTime(1, 1, 1) ? new DateTime(1900, 1, 1) : model.ApprovalTime;
            DateTime _docDate      = DateTime.Parse(_sTime.ToString("yyyy-MM-dd"));

            //User user = (_userRepository.GetUserByCode(model.EmpCode) ?? new TechnikSys.MoldManager.Domain.Entity.User());
            SqlParameter[] prams =
            {
                db.MakeInParam("@Id",           SqlDbType.Int,      100, model.Id),
                db.MakeInParam("@EmpCode",      SqlDbType.NVarChar, 100, model.EmpCode),
                db.MakeInParam("@EmpName",      SqlDbType.NVarChar, 100, model.EmpName ?? ""),
                db.MakeInParam("@DepID",        SqlDbType.Int,      100, model.DepID),
                db.MakeInParam("@DocDate",      SqlDbType.DateTime, 100, _docDate),
                db.MakeInParam("@StartTime",    SqlDbType.DateTime, 100, model.StartTime),
                db.MakeInParam("@EndTime",      SqlDbType.DateTime, 100, _eTime),
                db.MakeInParam("@CreateTime",   SqlDbType.DateTime, 100, DateTime.Now),
                db.MakeInParam("@Enable",       SqlDbType.Bit,      100, model.Enable),
                db.MakeInParam("@MoldNumber",   SqlDbType.NVarChar, 100, model.MoldNumber),
                db.MakeInParam("@WorkType",     SqlDbType.NVarChar, 100, model.WorkType),
                db.MakeInParam("@BC",           SqlDbType.NVarChar, 100, model.BC ?? ""),
                db.MakeInParam("@MachineCode",  SqlDbType.NVarChar, 100, model.MachineCode ?? ""),
                db.MakeInParam("@Status",       SqlDbType.Int,      100, model.Status),
                db.MakeInParam("@Time",         SqlDbType.Float,    100, model.Time),
                db.MakeInParam("@ApprovalUser", SqlDbType.Int,      100, model.ApprovalUser),
                db.MakeInParam("@ApprovalTime", SqlDbType.DateTime, 100, _approvalTime),
            };
            int r = db.RunProc(procName, prams);

            return(r);
        }
示例#2
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);
        }
        public string Service_WH_SaveEmpWHRecords(TaskHoursEmp model)
        {
            User user = (_userRepository.GetUserByCode(model.EmpCode) ?? new TechnikSys.MoldManager.Domain.Entity.User());

            model.DepID = user.DepartmentID;
            string res = dal.Chk_EmpWHRecords(model);

            if (string.IsNullOrEmpty(res))
            {
                try
                {
                    dal.Save_EmpWHRecords(model);
                }
                catch { }
            }
            return(res);
        }