Exemplo n.º 1
0
 /// <summary>
 /// 检查是否重复
 /// </summary>
 /// <param name="Model.Piece"></param>
 /// <returns></returns>
 public static bool CheckRepeat(Model.Piece model)
 {
     try
     {
         string         sql  = "select * from Piece 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   = "检查是否重复-ForPiece";
         e.ErrorMsg  = ex.Message.ToString();
         ErrorLogService.AddErrorLog <Model.Piece>(e, model);
         return(true);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 根据id修改试件
 /// </summary>
 /// <param name="Model.Piece"></param>
 /// <returns></returns>
 public static bool ModifyPieceById(ref Model.Piece 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("@Number", model.Number),
             new SqlParameter("@Order", model.Order),
             new SqlParameter("@Count", model.Count),
             new SqlParameter("@PrintedCount", model.PrintedCount),
             new SqlParameter("@IsPrinted", model.IsPrinted),
             new SqlParameter("@Ots", model.Ots),
             new SqlParameter("@DelegateNumber", model.DelegateNumber),
             new SqlParameter("@AccessoryFactory", model.AccessoryFactory),
             new SqlParameter("@VehicleType", model.VehicleType),
             new SqlParameter("@TestContent", model.TestContent),
             new SqlParameter("@SendPerson", model.SendPerson),
             new SqlParameter("@ChargePerson", model.ChargePerson),
             new SqlParameter("@SendDate", model.SendDate),
             new SqlParameter("@Place", model.Place),
             new SqlParameter("@IsEnable", model.IsEnable),
             new SqlParameter("@Description", model.Description),
             new SqlParameter("@Modifier", model.Modifier),
             new SqlParameter("@ModifiedDate", model.ModifiedDate)
         };
         int i = DBHelper.ExecuteNonQuery(CommandType.StoredProcedure, "proc_PieceByIdUpdate", para);
         if (i > 0)
         {
             EventLog e = new EventLog();
             e.TargetIds = model.Id.ToString();
             e.CodeTag   = "ModifyPieceById";
             e.LogName   = "修改试件";
             EventLogService.AddEventLog <Model.Piece>(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   = "ModifyPieceById";
         e.LogName   = "修改试件";
         e.ErrorMsg  = ex.Message.ToString();
         ErrorLogService.AddErrorLog <Model.Piece>(e, model);
         return(false);
     }
 }
Exemplo n.º 3
0
        private bool tryPut(ref Model.Piece model, out string errMsg)
        {
            errMsg = "";
            bool re = false;

            model.Modifier     = this.auth.UserId;
            model.ModifiedDate = DateTime.Now;
            if (PieceManager.ModifyPieceById(ref model, out errMsg))
            {
                re = true;
            }
            return(re);
        }
Exemplo n.º 4
0
        private bool tryValidate(Model.Piece 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 && PieceManager.CheckRepeat(model))
            {
                errMsg = "不能重复";
                re     = false;
            }
            if (re && model.Modifier != auth.UserId)
            {
                errMsg = "登录信息异常,请刷新浏览器以重启应用(APP请退出应用后重新打开)";
                re     = false;
            }
            return(re);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 检查是否重复
 /// </summary>
 /// <param name="Model.Piece"></param>
 /// <returns></returns>
 public static bool CheckRepeat(Model.Piece model)
 {
     return(PieceService.CheckRepeat(model));
 }
Exemplo n.º 6
0
 /// <summary>
 /// 根据id修改试件
 /// </summary>
 /// <param name="Model.Piece"></param>
 /// <returns></returns>
 public static bool ModifyPieceById(ref Model.Piece model, out string errMsg)
 {
     return(PieceService.ModifyPieceById(ref model, out errMsg));
 }
Exemplo n.º 7
0
 /// <summary>
 /// 添加试件
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool AddPiece(ref Model.Piece model, out string errMsg)
 {
     return(PieceService.AddPiece(ref model, out errMsg));
 }
Exemplo n.º 8
0
 /// <summary>
 /// 添加试件
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool AddPiece(ref Model.Piece 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("@Number", model.Number),
             new SqlParameter("@Order", model.Order),
             new SqlParameter("@Count", model.Count),
             new SqlParameter("@PrintedCount", model.PrintedCount),
             new SqlParameter("@IsPrinted", model.IsPrinted),
             new SqlParameter("@Ots", model.Ots),
             new SqlParameter("@DelegateNumber", model.DelegateNumber),
             new SqlParameter("@AccessoryFactory", model.AccessoryFactory),
             new SqlParameter("@VehicleType", model.VehicleType),
             new SqlParameter("@TestContent", model.TestContent),
             new SqlParameter("@SendPerson", model.SendPerson),
             new SqlParameter("@ChargePerson", model.ChargePerson),
             new SqlParameter("@SendDate", model.SendDate),
             new SqlParameter("@Place", model.Place),
             new SqlParameter("@IsEnable", model.IsEnable),
             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[21].Direction = ParameterDirection.ReturnValue;
         int i = DBHelper.ExecuteNonQuery(CommandType.StoredProcedure, "proc_PieceInsert", para);
         if (i > 0)
         {
             model.Id = int.Parse(para[21].Value.ToString());
             EventLog e = new EventLog();
             e.TargetIds = para[21].Value.ToString();
             e.CodeTag   = "AddPiece";
             e.LogName   = "添加试件";
             EventLogService.AddEventLog <Model.Piece>(e, model);
             return(true);
         }
         else
         {
             errMsg = "添加记录失败,受影响行数为0";
             return(false);
         }
     }
     catch (Exception ex)
     {
         errMsg = ex.Message;
         ErrorLog e = new ErrorLog();
         e.TargetIds = "0";
         e.CodeTag   = "AddPiece";
         e.LogName   = "添加试件";
         e.ErrorMsg  = ex.Message.ToString();
         ErrorLogService.AddErrorLog <Model.Piece>(e, model);
         return(false);
     }
 }