Beispiel #1
0
 public HandlingResult Add(SnModel model)
 {
     HandlingResult result = new HandlingResult();
      String querysql = String.Format("SELECT COUNT(1) AS CNT FROM BPSYS_STORESN WHERE CODE='{0}'", model.Code);
      String sql =
          "INSERT INTO BPSYS_STORESN(ID, STOREID, NAME, CODE, STATUS, CREATOR, CREATORID, CREATEDTIME) VALUES ('{0}', '{1}', '{2}', '{3}', {4}, '{5}', '{6}', '{7}')";
      sql = String.Format(sql, model.Id, model.StoreId, model.Name, model.Code, 1,
          UserInformationContext.LoginName,
          UserInformationContext.ID, DateTime.Now.ToString(ConfigImformationContext.TIME_FORMAT_FULL));
      using (DataBaseProcess process = new DataBaseProcess())
      {
          DataTable dt = process.Query(querysql);
          if (dt != null && dt.Rows.Count > 0)
          {
              result.MsgNumber = Int32.Parse(dt.Rows[0]["CNT"].ToString());
              if (result.MsgNumber == 0)
              {
                  result.MsgNumber = process.Exec(sql);
              }
              else
              {
                  result.MsgNumber = 0;
                  result.Message = String.Format("SN[{0}]已经存在", model.Code);
              }
          }
      }
      result.Successed = result.MsgNumber > 0;
      result.Message = result.Successed ? "新增成功" : "新增失败";
      return result;
 }
Beispiel #2
0
        public HandlingResult Update(SnModel model)
        {
            HandlingResult result = new HandlingResult();
             String sql = String.Format("UPDATE BPSYS_STORESN SET NAME='{0}',CODE='{1}' WHERE ID='{2}'", model.Name,
                 model.Code, model.Id);
             String querysql = String.Format("SELECT ID FROM BPSYS_STORESN WHERE CODE='{0}'", model.Code);

             using (DataBaseProcess process = new DataBaseProcess())
             {
                 DataTable dt = process.Query(querysql);
                 if (dt != null && dt.Rows.Count > 0)
                 {
                     Guid id = Guid.Parse(dt.Rows[0]["ID"].ToString());
                     if (id != model.Id)
                     {

                         result.MsgNumber = 0;
                         result.Message = String.Format("SN[{0}]已经存在", model.Code);
                     }
                     else
                     {
                         result.MsgNumber = process.Exec(sql);
                     }
                 }
             }
             result.Successed = result.MsgNumber > 0;
             result.Message = result.Message.Length > 0 ? result.Message : result.Successed ? "更新成功" : "更新失败";
             return result;
        }
 private HandlingResult ValidateSNSave()
 {
     HandlingResult result = new HandlingResult();
     SnModel model = new SnModel();
     model.Name = textBoxSnName.Text.TrimStart().TrimEnd();
     model.Code = textBoxSnCode.Text.TrimStart().TrimEnd();
     model.StoreId = _selStoreId;
     if (String.IsNullOrEmpty(model.Name))
     {
         result.Successed = false;
         result.Message += "\r\n请填写SN别名";
     }
     if (String.IsNullOrEmpty(model.Code))
     {
         result.Successed = false;
         result.Message += "\r\n请填写SN";
     }
     if (model.StoreId==null || model.StoreId.Equals(Guid.Empty))
     {
         result.Successed = false;
         result.Message += "\r\n请选择门店";
     }
     model.Id = Guid.NewGuid();
     result.Result = model;
     return result;
 }