Пример #1
0
        private bool tryPost(ref Model.Tracenew model, out string errMsg)
        {
            errMsg = "";
            bool re = false;

            model.Creater     = this.auth.UserId;
            model.CreatedDate = DateTime.Now;
            if (InstanceManager.AddTrace(ref model, out errMsg))
            {
                re = true;
            }
            return(re);
        }
Пример #2
0
        private bool tryValidate(Model.Tracenew model, out string errMsg)
        {
            errMsg = "";
            bool re = true;

            if (model.Car == 0 || model.Project == 0 || model.Department == 0 ||
                model.UserName == null || model.UserName.Length == 0 || model.UserName.Length > 20 ||
                model.Oils == null || model.Oils.Count == 0 ||
                model.Goal.Length > 200 ||
                model.StartDate == null || model.EndDate == null ||
                model.StartInfo.Length > 200 ||
                model.Creater == 0)
            {
                errMsg = "输入数据不合法";
                re     = false;
            }
            if (re && model.Creater != auth.UserId)
            {
                errMsg = "登录信息异常,请刷新浏览器以重启应用(APP请退出应用后重新打开)";
                re     = false;
            }
            return(re);
        }
Пример #3
0
 /// <summary>
 /// 新建申请单履历
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool AddTrace(ref Model.Tracenew model, out string errMsg)
 {
     return(InstanceService.AddTrace(ref model, out errMsg));
 }
Пример #4
0
        /// <summary>
        /// 新建申请单履历
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool AddTrace(ref Model.Tracenew model, out string errMsg)
        {
            errMsg = "";
            try
            {
                model.Status    = model.Status.Trim();
                model.UserName  = model.UserName.Trim();
                model.Goal      = model.Goal.Trim();
                model.StartInfo = model.StartInfo.Trim();
                int[]          oils      = model.Oils.ToArray();
                string[]       arrayOils = Array.ConvertAll(oils, delegate(int s) { return(s.ToString()); });
                SqlParameter[] para      = new SqlParameter[]
                {
                    new SqlParameter("@Car", model.Car),
                    new SqlParameter("@Instance", model.Instance),
                    new SqlParameter("@PreviousTrace", model.PreviousTrace),
                    new SqlParameter("@Status", model.Status),
                    new SqlParameter("@Project", model.Project),
                    new SqlParameter("@Department", model.Department),
                    new SqlParameter("@UserName", model.UserName),
                    new SqlParameter("@Oils", string.Join(",", arrayOils)),
                    new SqlParameter("@Goal", model.Goal),
                    new SqlParameter("@StartDate", model.StartDate),
                    new SqlParameter("@EndDate", model.EndDate),
                    new SqlParameter("@StartInfo", model.StartInfo),
                    new SqlParameter("@Creater", model.Creater),
                    new SqlParameter("@CreatedDate", model.CreatedDate),
                    new SqlParameter("@OutState", SqlDbType.Int),
                    new SqlParameter("@return", SqlDbType.Int)
                };
                para[14].Direction = ParameterDirection.Output;
                para[15].Direction = ParameterDirection.ReturnValue;
                DBHelper.ExecuteNonQuery(CommandType.StoredProcedure, "proc_TraceInsert", para);
                int outState    = int.Parse(para[14].Value.ToString());
                int returnValue = int.Parse(para[15].Value.ToString());
                if (returnValue > 0)
                {
                    EventLog e = new EventLog();
                    e.TargetIds = returnValue.ToString();
                    e.CodeTag   = "AddTrace";
                    e.LogName   = "新建申请单履历";
                    EventLogService.AddEventLog <Model.Tracenew>(e, model);
                    return(true);
                }
                else
                {
                    switch (outState)
                    {
                    case -100:
                        errMsg = "该申请单已归档,不能修改";
                        break;

                    case -200:
                        errMsg = "该申请单处于待审核状态,不能修改申请单,如果需要修改,请先取回该申请单";
                        break;

                    case -300:
                        errMsg = "起止时间设置有误";
                        break;

                    case -1:
                        errMsg = "添加申请单履历失败";
                        break;

                    case -2:
                        errMsg = "更新(提交)申请单信息失败";
                        break;

                    case -3:
                        errMsg = "更新申请单履历结束状态失败";
                        break;

                    case -4:
                        errMsg = "更新申请单信息失败";
                        break;

                    case -5:
                        errMsg = "更新车辆信息失败";
                        break;

                    default:
                        errMsg = "异常错误";
                        break;
                    }
                    ErrorLog e = new ErrorLog();
                    e.TargetIds = model.Car.ToString();
                    e.CodeTag   = "AddTrace";
                    e.LogName   = "新建申请单履历";
                    e.ErrorMsg  = errMsg;
                    ErrorLogService.AddErrorLog <Model.Tracenew>(e, model);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                ErrorLog e = new ErrorLog();
                e.TargetIds = "0";
                e.CodeTag   = "AddTrace";
                e.LogName   = "新建申请单履历";
                e.ErrorMsg  = ex.Message.ToString();
                ErrorLogService.AddErrorLog <Model.Tracenew>(e, model);
                return(false);
            }
        }