예제 #1
0
 /// <summary>
 /// 检查是否重复
 /// </summary>
 /// <param name="Model.Oil"></param>
 /// <returns></returns>
 public static bool CheckRepeat(Model.Oil model)
 {
     try
     {
         string         sql  = "select * from Oil where Name = @Name and Id <> @Id";
         SqlParameter[] para = new SqlParameter[]
         {
             new SqlParameter("@Name", model.Name.Trim()),
             new SqlParameter("@Id", model.Id)
         };
         DataTable temp = DBHelper.ExecuteGetDataTable(CommandType.Text, sql, para);
         if (temp.Rows.Count > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         ErrorLog e = new ErrorLog();
         e.TargetIds = model.Id.ToString();
         e.CodeTag   = "CheckRepeat";
         e.LogName   = "检查是否重复-ForOil";
         e.ErrorMsg  = ex.Message.ToString();
         ErrorLogService.AddErrorLog <Model.Oil>(e, model);
         return(true);
     }
 }
예제 #2
0
        private bool tryPut(ref Model.Oil model, out string errMsg)
        {
            errMsg = "";
            bool re = false;

            model.Modifier     = this.auth.UserId;
            model.ModifiedDate = DateTime.Now;
            if (OilManager.ModifyOilById(ref model, out errMsg))
            {
                re = true;
            }
            return(re);
        }
예제 #3
0
 /// <summary>
 /// 添加油品
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool AddOil(ref Model.Oil model, out string errMsg)
 {
     errMsg = "";
     try
     {
         model.Name        = model.Name.Trim();
         model.Description = model.Description.Trim();
         SqlParameter[] para = new SqlParameter[]
         {
             new SqlParameter("@Name", model.Name),
             new SqlParameter("@YellowRate", model.YellowRate),
             new SqlParameter("@RedRate", model.RedRate),
             new SqlParameter("@Description", model.Description),
             new SqlParameter("@Creater", model.Creater),
             new SqlParameter("@CreatedDate", model.CreatedDate),
             new SqlParameter("@Modifier", model.Modifier),
             new SqlParameter("@ModifiedDate", model.ModifiedDate),
             new SqlParameter("@return", SqlDbType.Int)
         };
         para[8].Direction = ParameterDirection.ReturnValue;
         int i = DBHelper.ExecuteNonQuery(CommandType.StoredProcedure, "proc_OilInsert", para);
         if (i > 0)
         {
             model.Id = int.Parse(para[8].Value.ToString());
             EventLog e = new EventLog();
             e.TargetIds = para[8].Value.ToString();
             e.CodeTag   = "AddOil";
             e.LogName   = "添加油品";
             EventLogService.AddEventLog <Model.Oil>(e, model);
             return(true);
         }
         else
         {
             errMsg = "添加记录失败,受影响行数为0";
             return(false);
         }
     }
     catch (Exception ex)
     {
         errMsg = ex.Message;
         ErrorLog e = new ErrorLog();
         e.TargetIds = "0";
         e.CodeTag   = "AddOil";
         e.LogName   = "添加油品";
         e.ErrorMsg  = ex.Message.ToString();
         ErrorLogService.AddErrorLog <Model.Oil>(e, model);
         return(false);
     }
 }
예제 #4
0
 /// <summary>
 /// 根据id修改油品
 /// </summary>
 /// <param name="Model.Oil"></param>
 /// <returns></returns>
 public static bool ModifyOilById(ref Model.Oil model, out string errMsg)
 {
     errMsg = "";
     try
     {
         model.Name        = model.Name.Trim();
         model.Description = model.Description.Trim();
         SqlParameter[] para = new SqlParameter[]
         {
             new SqlParameter("@Id", model.Id),
             new SqlParameter("@Name", model.Name),
             new SqlParameter("@YellowRate", model.YellowRate),
             new SqlParameter("@RedRate", model.RedRate),
             new SqlParameter("@Description", model.Description),
             new SqlParameter("@Modifier", model.Modifier),
             new SqlParameter("@ModifiedDate", model.ModifiedDate)
         };
         int i = DBHelper.ExecuteNonQuery(CommandType.StoredProcedure, "proc_OilByIdUpdate", para);
         if (i > 0)
         {
             EventLog e = new EventLog();
             e.TargetIds = model.Id.ToString();
             e.CodeTag   = "ModifyOilById";
             e.LogName   = "修改油品";
             EventLogService.AddEventLog <Model.Oil>(e, model);
             return(true);
         }
         else
         {
             errMsg = "该记录已被删除,不能修改!";
             return(false);
         }
     }
     catch (Exception ex)
     {
         errMsg = ex.Message;
         ErrorLog e = new ErrorLog();
         e.TargetIds = model.Id.ToString();
         e.CodeTag   = "ModifyOilById";
         e.LogName   = "修改油品";
         e.ErrorMsg  = ex.Message.ToString();
         ErrorLogService.AddErrorLog <Model.Oil>(e, model);
         return(false);
     }
 }
예제 #5
0
        private bool tryValidate(Model.Oil model, out string errMsg)
        {
            errMsg = "";
            bool re = true;

            if (model.Name == null || model.Name.Length == 0 || model.Name.Length > 20 ||
                model.Description.Length > 200)
            {
                errMsg = "输入数据不合法";
                re     = false;
            }
            if (re && OilManager.CheckRepeat(model))
            {
                errMsg = "不能重复";
                re     = false;
            }
            if (re && model.Modifier != auth.UserId)
            {
                errMsg = "登录信息异常,请刷新浏览器以重启应用(APP请退出应用后重新打开)";
                re     = false;
            }
            return(re);
        }
예제 #6
0
 /// <summary>
 /// 检查是否重复
 /// </summary>
 /// <param name="Model.Oil"></param>
 /// <returns></returns>
 public static bool CheckRepeat(Model.Oil model)
 {
     return(OilService.CheckRepeat(model));
 }
예제 #7
0
 /// <summary>
 /// 根据id修改油品
 /// </summary>
 /// <param name="Model.Oil"></param>
 /// <returns></returns>
 public static bool ModifyOilById(ref Model.Oil model, out string errMsg)
 {
     return(OilService.ModifyOilById(ref model, out errMsg));
 }
예제 #8
0
 /// <summary>
 /// 添加油品
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool AddOil(ref Model.Oil model, out string errMsg)
 {
     return(OilService.AddOil(ref model, out errMsg));
 }