Ejemplo n.º 1
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     string userName = this.txtUserName.Text.Trim();
     string password = this.txtPassword.Text.Trim();
     if (userName.Length == 0)
     {
         MessageBox.ShowServerBusyTip(this, "用户名不能为空!");
     }
     else
     {
         User user = new User();
         if (user.HasUserByUserName(userName))
         {
             MessageBox.ShowServerBusyTip(this, Site.TooltipUserExist);
         }
         else if (password.Length == 0)
         {
             MessageBox.ShowServerBusyTip(this, "密码不能为空!");
         }
         else if (password.Length > 0x10)
         {
             MessageBox.ShowServerBusyTip(this, "密码不能超过16个字符!");
         }
         else
         {
             string name = this.txtName.Text.Trim();
             if (name.Length == 0)
             {
                 MessageBox.ShowServerBusyTip(this, "供应商名称不能为空!");
             }
             else if (name.Length > 100)
             {
                 MessageBox.ShowServerBusyTip(this, "供应商名称请控制在1~100字符!");
             }
             else if (this.bll.Exists(name))
             {
                 MessageBox.ShowServerBusyTip(this, "该供应商名称已经被注册,请更换供应商名称再操作!");
             }
             else
             {
                 int supplierId = 0;
                 try
                 {
                     Maticsoft.Model.Shop.Supplier.SupplierInfo model = new Maticsoft.Model.Shop.Supplier.SupplierInfo {
                         Name = name,
                         Introduction = this.txtIntroduction.Text,
                         RegisteredCapital = new int?(Globals.SafeInt(this.txtRegisteredCapital.Text, 0)),
                         TelPhone = this.txtTelPhone.Text,
                         CellPhone = this.txtCellPhone.Text,
                         ContactMail = this.txtContactMail.Text,
                         RegionId = new int?(this.RegionID.Region_iID),
                         Address = this.txtAddress.Text,
                         Remark = this.txtRemark.Text,
                         Contact = this.txtContact.Text,
                         UserName = this.txtUserName.Text
                     };
                     string text = this.txtEstablishedDate.Text;
                     if (PageValidate.IsDateTime(text))
                     {
                         model.EstablishedDate = new DateTime?(Globals.SafeDateTime(text, DateTime.Now));
                     }
                     else
                     {
                         model.EstablishedDate = null;
                     }
                     model.EstablishedCity = new int?(this.RegionEstablishedCity.Region_iID);
                     model.LOGO = this.txtLOGO.Text;
                     model.Fax = this.txtFax.Text;
                     model.PostCode = this.txtPostCode.Text;
                     model.HomePage = this.txtHomePage.Text;
                     model.ArtiPerson = this.txtArtiPerson.Text;
                     model.Rank = Globals.SafeInt(this.dropEnteRank.SelectedValue, 0);
                     model.CategoryId = Globals.SafeInt(this.dropEnteClassID.SelectedValue, 0);
                     model.CompanyType = new int?(Globals.SafeInt(this.dropCompanyType.SelectedValue, 0));
                     model.BusinessLicense = this.txtBusinessLicense.Text;
                     model.TaxNumber = this.txtTaxNumber.Text;
                     model.AccountBank = this.txtAccountBank.Text;
                     model.AccountInfo = this.txtAccountInfo.Text;
                     model.ServicePhone = this.txtServicePhone.Text;
                     model.QQ = this.txtQQ.Text;
                     model.MSN = this.txtMSN.Text;
                     model.Status = Globals.SafeInt(this.radlStatus.SelectedValue, 0);
                     model.CreatedDate = DateTime.Now;
                     model.CreatedUserId = base.CurrentUser.UserID;
                     model.UpdatedDate = new DateTime?(DateTime.Now);
                     model.UpdatedUserId = new int?(base.CurrentUser.UserID);
                     model.Balance = Globals.SafeDecimal(this.txtBalance.Text, (decimal) 0M);
                     model.AgentId = Globals.SafeInt(this.txtAgentID.Text, 0);
                     supplierId = this.bll.Add(model);
                     if (supplierId > 0)
                     {
                         user.UserName = userName;
                         user.NickName = this.txtName.Text;
                         user.Password = AccountsPrincipal.EncryptPassword(password);
                         user.TrueName = "";
                         user.Sex = "1";
                         user.Phone = this.txtCellPhone.Text;
                         user.Email = this.txtContactMail.Text;
                         user.EmployeeID = 0;
                         user.DepartmentID = supplierId.ToString();
                         user.Activity = true;
                         user.UserType = "SP";
                         user.Style = 1;
                         user.User_dateCreate = DateTime.Now;
                         user.User_iCreator = base.CurrentUser.UserID;
                         user.User_dateValid = DateTime.Now;
                         user.User_cLang = "zh-CN";
                         user.UserID = user.Create();
                         if (user.UserID == -100)
                         {
                             this.bll.Delete(supplierId);
                             MessageBox.ShowServerBusyTip(this, Site.TooltipUserExist);
                         }
                         else
                         {
                             model.UserId = user.UserID;
                             this.bll.Update(model);
                             int intValueByCache = ConfigSystem.GetIntValueByCache("DefaultSuppRoleID");
                             if (intValueByCache > 0)
                             {
                                 user.AddToRole(intValueByCache);
                             }
                             UsersExp exp = new UsersExp {
                                 UserID = user.UserID,
                                 BirthdayVisible = 0,
                                 BirthdayIndexVisible = false,
                                 ConstellationVisible = 0,
                                 ConstellationIndexVisible = false,
                                 NativePlaceVisible = 0,
                                 NativePlaceIndexVisible = false,
                                 RegionId = 0,
                                 AddressVisible = 0,
                                 AddressIndexVisible = false,
                                 BodilyFormVisible = 0,
                                 BodilyFormIndexVisible = false,
                                 BloodTypeVisible = 0,
                                 BloodTypeIndexVisible = false,
                                 MarriagedVisible = 0,
                                 MarriagedIndexVisible = false,
                                 PersonalStatusVisible = 0,
                                 PersonalStatusIndexVisible = false,
                                 LastAccessIP = "",
                                 LastAccessTime = new DateTime?(DateTime.Now),
                                 LastLoginTime = DateTime.Now,
                                 LastPostTime = new DateTime?(DateTime.Now)
                             };
                             if (exp.AddUsersExp(exp))
                             {
                                 MessageBox.ShowSuccessTip(this, "添加成功!", "List.aspx");
                             }
                             else
                             {
                                 user.Delete();
                                 exp.DeleteUsersExp(user.UserID);
                                 this.bll.Delete(supplierId);
                                 MessageBox.ShowFailTip(this, "添加失败!");
                             }
                         }
                     }
                     else
                     {
                         this.bll.Delete(supplierId);
                         MessageBox.ShowFailTip(this, "添加失败!");
                     }
                 }
                 catch (Exception exception)
                 {
                     this.bll.Delete(supplierId);
                     throw exception;
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 public Maticsoft.Model.Shop.Supplier.SupplierInfo DataRowToModel(DataRow row)
 {
     Maticsoft.Model.Shop.Supplier.SupplierInfo info = new Maticsoft.Model.Shop.Supplier.SupplierInfo();
     if (row != null)
     {
         if ((row["SupplierId"] != null) && (row["SupplierId"].ToString() != ""))
         {
             info.SupplierId = int.Parse(row["SupplierId"].ToString());
         }
         if (row["Name"] != null)
         {
             info.Name = row["Name"].ToString();
         }
         if ((row["CategoryId"] != null) && (row["CategoryId"].ToString() != ""))
         {
             info.CategoryId = int.Parse(row["CategoryId"].ToString());
         }
         if ((row["Rank"] != null) && (row["Rank"].ToString() != ""))
         {
             info.Rank = int.Parse(row["Rank"].ToString());
         }
         if ((row["UserId"] != null) && (row["UserId"].ToString() != ""))
         {
             info.UserId = int.Parse(row["UserId"].ToString());
         }
         if (row["UserName"] != null)
         {
             info.UserName = row["UserName"].ToString();
         }
         if (row["TelPhone"] != null)
         {
             info.TelPhone = row["TelPhone"].ToString();
         }
         if (row["CellPhone"] != null)
         {
             info.CellPhone = row["CellPhone"].ToString();
         }
         if (row["ContactMail"] != null)
         {
             info.ContactMail = row["ContactMail"].ToString();
         }
         if (row["Introduction"] != null)
         {
             info.Introduction = row["Introduction"].ToString();
         }
         if ((row["RegisteredCapital"] != null) && (row["RegisteredCapital"].ToString() != ""))
         {
             info.RegisteredCapital = new int?(int.Parse(row["RegisteredCapital"].ToString()));
         }
         if ((row["RegionId"] != null) && (row["RegionId"].ToString() != ""))
         {
             info.RegionId = new int?(int.Parse(row["RegionId"].ToString()));
         }
         if (row["Address"] != null)
         {
             info.Address = row["Address"].ToString();
         }
         if (row["Contact"] != null)
         {
             info.Contact = row["Contact"].ToString();
         }
         if ((row["EstablishedDate"] != null) && (row["EstablishedDate"].ToString() != ""))
         {
             info.EstablishedDate = new DateTime?(DateTime.Parse(row["EstablishedDate"].ToString()));
         }
         if ((row["EstablishedCity"] != null) && (row["EstablishedCity"].ToString() != ""))
         {
             info.EstablishedCity = new int?(int.Parse(row["EstablishedCity"].ToString()));
         }
         if (row["LOGO"] != null)
         {
             info.LOGO = row["LOGO"].ToString();
         }
         if (row["Fax"] != null)
         {
             info.Fax = row["Fax"].ToString();
         }
         if (row["PostCode"] != null)
         {
             info.PostCode = row["PostCode"].ToString();
         }
         if (row["HomePage"] != null)
         {
             info.HomePage = row["HomePage"].ToString();
         }
         if (row["ArtiPerson"] != null)
         {
             info.ArtiPerson = row["ArtiPerson"].ToString();
         }
         if ((row["CompanyType"] != null) && (row["CompanyType"].ToString() != ""))
         {
             info.CompanyType = new int?(int.Parse(row["CompanyType"].ToString()));
         }
         if (row["BusinessLicense"] != null)
         {
             info.BusinessLicense = row["BusinessLicense"].ToString();
         }
         if (row["TaxNumber"] != null)
         {
             info.TaxNumber = row["TaxNumber"].ToString();
         }
         if (row["AccountBank"] != null)
         {
             info.AccountBank = row["AccountBank"].ToString();
         }
         if (row["AccountInfo"] != null)
         {
             info.AccountInfo = row["AccountInfo"].ToString();
         }
         if (row["ServicePhone"] != null)
         {
             info.ServicePhone = row["ServicePhone"].ToString();
         }
         if (row["QQ"] != null)
         {
             info.QQ = row["QQ"].ToString();
         }
         if (row["MSN"] != null)
         {
             info.MSN = row["MSN"].ToString();
         }
         if ((row["Status"] != null) && (row["Status"].ToString() != ""))
         {
             info.Status = int.Parse(row["Status"].ToString());
         }
         if ((row["CreatedDate"] != null) && (row["CreatedDate"].ToString() != ""))
         {
             info.CreatedDate = DateTime.Parse(row["CreatedDate"].ToString());
         }
         if ((row["CreatedUserId"] != null) && (row["CreatedUserId"].ToString() != ""))
         {
             info.CreatedUserId = int.Parse(row["CreatedUserId"].ToString());
         }
         if ((row["UpdatedDate"] != null) && (row["UpdatedDate"].ToString() != ""))
         {
             info.UpdatedDate = new DateTime?(DateTime.Parse(row["UpdatedDate"].ToString()));
         }
         if ((row["UpdatedUserId"] != null) && (row["UpdatedUserId"].ToString() != ""))
         {
             info.UpdatedUserId = new int?(int.Parse(row["UpdatedUserId"].ToString()));
         }
         if ((row["ExpirationDate"] != null) && (row["ExpirationDate"].ToString() != ""))
         {
             info.ExpirationDate = new DateTime?(DateTime.Parse(row["ExpirationDate"].ToString()));
         }
         if ((row["Balance"] != null) && (row["Balance"].ToString() != ""))
         {
             info.Balance = decimal.Parse(row["Balance"].ToString());
         }
         if ((row["IsUserApprove"] != null) && (row["IsUserApprove"].ToString() != ""))
         {
             if ((row["IsUserApprove"].ToString() == "1") || (row["IsUserApprove"].ToString().ToLower() == "true"))
             {
                 info.IsUserApprove = true;
             }
             else
             {
                 info.IsUserApprove = false;
             }
         }
         if ((row["IsSuppApprove"] != null) && (row["IsSuppApprove"].ToString() != ""))
         {
             if ((row["IsSuppApprove"].ToString() == "1") || (row["IsSuppApprove"].ToString().ToLower() == "true"))
             {
                 info.IsSuppApprove = true;
             }
             else
             {
                 info.IsSuppApprove = false;
             }
         }
         if ((row["ScoreDesc"] != null) && (row["ScoreDesc"].ToString() != ""))
         {
             info.ScoreDesc = decimal.Parse(row["ScoreDesc"].ToString());
         }
         if ((row["ScoreService"] != null) && (row["ScoreService"].ToString() != ""))
         {
             info.ScoreService = decimal.Parse(row["ScoreService"].ToString());
         }
         if ((row["ScoreSpeed"] != null) && (row["ScoreSpeed"].ToString() != ""))
         {
             info.ScoreSpeed = decimal.Parse(row["ScoreSpeed"].ToString());
         }
         if ((row["Recomend"] != null) && (row["Recomend"].ToString() != ""))
         {
             info.Recomend = int.Parse(row["Recomend"].ToString());
         }
         if ((row["Sequence"] != null) && (row["Sequence"].ToString() != ""))
         {
             info.Sequence = int.Parse(row["Sequence"].ToString());
         }
         if ((row["ProductCount"] != null) && (row["ProductCount"].ToString() != ""))
         {
             info.ProductCount = int.Parse(row["ProductCount"].ToString());
         }
         if ((row["PhotoCount"] != null) && (row["PhotoCount"].ToString() != ""))
         {
             info.PhotoCount = int.Parse(row["PhotoCount"].ToString());
         }
         if ((row["ThemeId"] != null) && (row["ThemeId"].ToString() != ""))
         {
             info.ThemeId = int.Parse(row["ThemeId"].ToString());
         }
         if (row["Remark"] != null)
         {
             info.Remark = row["Remark"].ToString();
         }
         if ((row["AgentId"] != null) && (row["AgentId"].ToString() != ""))
         {
             info.AgentId = int.Parse(row["AgentId"].ToString());
         }
     }
     return info;
 }