示例#1
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            SupplierInfo supplierInfo = new SupplierInfo();

            supplierInfo.SupplierName      = this.txtSupplierName.Text.Trim();
            supplierInfo.ShopName          = this.txtShopName.Text.Trim();
            supplierInfo.SupplierCode      = this.txtSupplierCode.Text.Trim();
            supplierInfo.ShipWarehouseName = this.txtWarehouseName.Text.Trim();
            if (!this.ddlReggion.GetSelectedRegionId().HasValue)
            {
                this.ShowMsg("请选择地区", false);
                return;
            }
            supplierInfo.County      = this.ddlReggion.GetSelectedRegionId().Value;
            supplierInfo.Address     = this.txtAddress.Text.Trim();
            supplierInfo.Phone       = this.txtPhone.Text.Trim();
            supplierInfo.Mobile      = this.txtMobile.Text.Trim();
            supplierInfo.Description = this.txtDescription.Text.Trim();
            supplierInfo.ApproveKey  = this.ckbApproveKey.Checked;

            supplierInfo.ShopOwner   = this.txtSupplierOwnerName.Text.Trim();
            supplierInfo.Logo        = this.fmSrc1.Value;
            supplierInfo.PCImage     = this.fmSrc2.Value;
            supplierInfo.MobileImage = this.fmSrc3.Value;

            supplierInfo.Contact         = txtContact.Text.Trim();
            supplierInfo.Email           = txtEmail.Text.Trim();
            supplierInfo.Fax             = txtFax.Text.Trim();
            supplierInfo.Category        = txtCategory.Text.Trim();
            supplierInfo.BeneficiaryName = txtBeneficiaryName.Text.Trim();
            supplierInfo.SwiftCode       = txtSwiftCode.Text.Trim();
            supplierInfo.BankAccount     = txtBankAccount.Text.Trim();
            supplierInfo.BankName        = txtBankName.Text.Trim();
            supplierInfo.BankAddress     = txtBankAddress.Text.Trim();
            supplierInfo.IBAN            = txtIBAN.Text.Trim();
            supplierInfo.Remark          = TtxtRemark.Text.Trim();

            if (string.IsNullOrEmpty(supplierInfo.Phone) && string.IsNullOrEmpty(supplierInfo.Mobile))
            {
                this.ShowMsg("手机号码和电话号码必填其一", false);
                return;
            }
            int issucess = SupplierHelper.AddSupplier(supplierInfo);

            if (issucess > 0)
            {
                this.txtSupplierName.Text      = "";
                this.txtSupplierCode.Text      = "";
                this.txtWarehouseName.Text     = "";
                this.txtAddress.Text           = "";
                this.txtPhone.Text             = "";
                this.txtMobile.Text            = "";
                this.txtDescription.Text       = "";
                this.txtShopName.Text          = "";
                this.txtSupplierOwnerName.Text = "";

                this.txtContact.Text         = "";
                this.txtEmail.Text           = "";
                this.txtFax.Text             = "";
                this.txtCategory.Text        = "";
                this.txtBeneficiaryName.Text = "";
                this.txtSwiftCode.Text       = "";
                this.txtBankAccount.Text     = "";
                this.txtBankName.Text        = "";
                this.txtBankAddress.Text     = "";
                this.txtIBAN.Text            = "";
                this.TtxtRemark.Text         = "";

                this.ShowMsg("添加成功", true);
                return;
            }
            this.ShowMsg("添加失败", false);
        }
示例#2
0
        private void SaveSupplier(out int userId)
        {
            userId = 0;
            SupplierInfo supplierInfo = new SupplierInfo();
            string       userName     = DataHelper.CleanSearchString(this.txtUserName.Text.Trim());
            string       supplierName = Globals.StripAllTags(this.txtSupplierName.Text.Trim());
            string       address      = Globals.StripAllTags(this.txtAddress.Text);
            string       text         = this.txtTel.Text;
            string       text2        = Globals.StripAllTags(this.txtContactMan.Text);

            if (SupplierHelper.ExistSupplierName(0, supplierName))
            {
                this.ShowMsg("供应商名称已经存在,请重新输入!", false);
            }
            else if (!this.dropRegion.GetSelectedRegionId().HasValue)
            {
                this.ShowMsg("请选择供应商所在区域!", false);
            }
            else if (text2.Length > 8 || text2.Length < 2)
            {
                this.ShowMsg("请输入联系人,联系人长度必须是2-8位!", false);
            }
            else if (address.Length > 50 || address.Length < 2)
            {
                this.ShowMsg("请输入地址,长度必须为2-50个字符!", false);
            }
            else if (text == "" || !DataHelper.IsTel(text))
            {
                this.ShowMsg("请输入正确的联系电话(手机或者固定电话)!", false);
            }
            else if (ManagerHelper.FindManagerByUsername(userName) != null)
            {
                this.ShowMsg("用户名已经存在,请重新输入!", false);
            }
            else if (this.txtUserPwd.Text.Length < 6 || this.txtUserPwd.Text.Length > 20)
            {
                this.ShowMsg("密码不能为空,用户密码长度必须为6-20个字符!", false);
            }
            else if (string.Compare(this.txtUserPwd.Text, this.txtUserRePwd.Text) != 0)
            {
                this.ShowMsg("请确保两次输入的密码相同", false);
            }
            else
            {
                supplierInfo.Introduce    = this.editDescription.Text;
                supplierInfo.SupplierName = supplierName;
                supplierInfo.Picture      = this.UploadImage();
                supplierInfo.Status       = 1;
                supplierInfo.RegionId     = this.dropRegion.GetSelectedRegionId().Value;
                supplierInfo.Tel          = text;
                List <string> list = RegionHelper.GetFullRegion(this.dropRegion.GetSelectedRegionId().Value, ",", true, 0).Split(',').Take(3)
                                     .ToList();
                list.ForEach(delegate(string c)
                {
                    address = address.Replace(c, string.Empty);
                });
                supplierInfo.Address        = address;
                supplierInfo.ContactMan     = text2;
                supplierInfo.FullRegionPath = RegionHelper.GetFullPath(supplierInfo.RegionId, true);
                int num = SupplierHelper.AddSupplier(supplierInfo);
                if (num > 0)
                {
                    ManagerInfo managerInfo = new ManagerInfo();
                    managerInfo.RoleId   = -2;
                    managerInfo.UserName = this.txtUserName.Text.Trim();
                    string text3 = this.txtUserPwd.Text;
                    managerInfo.CreateDate = DateTime.Now;
                    string text4 = Globals.RndStr(128, true);
                    text3 = (managerInfo.Password = Users.EncodePassword(text3, text4));
                    managerInfo.PasswordSalt = text4;
                    managerInfo.StoreId      = num;
                    userId = ManagerHelper.Create(managerInfo);
                }
            }
        }