コード例 #1
0
ファイル: UserAction.cs プロジェクト: raindyi/BusinessReport
 public HandlingResult Add(UserModel model)
 {
     HandlingResult result=new HandlingResult();
     result.Successed = false;
     if (model != null)
     {
         String querysql =String.Format("SELECT COUNT(1) AS CNT FROM BPSYS_USER WHERE LOGINNAME='{0}'",model.LoginName);
         String sql =
             String.Format(
                 "INSERT INTO BPSYS_USER(ID, LOGINNAME, NAME, PASSWORD, PHONE, STOREID, STATUS, CREATOR, CREATORID, CREATEDTIME) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', {6}, '{7}', '{8}', '{9}')",
                 model.Id, model.LoginName, model.Name, model.Password, model.Phone, model.StoreId, 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("用户[{0}]已经存在", model.LoginName);
                 }
             }
         }
     }
     result.Successed = result.MsgNumber > 0;
     if (String.IsNullOrEmpty(result.Message))
     {
         result.Message = result.Successed ? "新增成功" : "新增失败";
     }
     return result;
 }
コード例 #2
0
ファイル: UserAction.cs プロジェクト: raindyi/BusinessReport
 public HandlingResult Modify(UserModel model)
 {
     HandlingResult result = new HandlingResult();
     result.Successed = false;
     if (model != null)
     {
         String sql =
             String.Format(
                 "UPDATE BPSYS_USER SET LOGINNAME='{0}', NAME='{1}', PHONE='{2}', STOREID='{3}' WHERE ID='{4}'",
                 model.LoginName,model.Name,model.Phone,model.StoreId,model.Id );
         using (DataBaseProcess process = new DataBaseProcess())
         {
             result.MsgNumber = process.Exec(sql);
         }
     }
     result.Successed = result.MsgNumber > 0;
     result.Message = result.Successed ? "修改成功" : "修改失败";
     return result;
 }
コード例 #3
0
 private HandlingResult ValidateBeforeSave()
 {
     HandlingResult result = new HandlingResult();
     result.Successed = true;
     UserModel model = new UserModel();
     model.Name = textBoxName.Text.TrimStart().TrimEnd();
     model.Phone = textBoxPhone.Text.TrimStart().TrimEnd();
     model.Password = textBoxPassword.Text;
     model.LoginName = textBoxLoginName.Text.TrimStart().TrimEnd();
     if (comboBoxStore.SelectedValue != null)
     {
         model.StoreId = Guid.Parse(comboBoxStore.SelectedValue.ToString());
     }
     if (String.IsNullOrEmpty(model.LoginName))
     {
         result.Message += "\r\n请录入登录名";
         result.Successed = false;
     }
     if (String.IsNullOrEmpty(model.Name))
     {
         result.Message += "\r\n请录入姓名";
         result.Successed = false;
     }
     if (String.IsNullOrEmpty(model.Password))
     {
         result.Message += "\r\n请录入登录密码";
         result.Successed = false;
     }
     else
     {
         model.Password = Md5Helper.GetMD5String(model.Password);
     }
     if (model.StoreId == null || model.StoreId == Guid.Empty)
     {
         result.Message += "\r\n请选择门店";
         result.Successed = false;
     }
     model.Id = Guid.NewGuid();
     result.Result = model;
     return result;
 }