private void buttonRegister_Click(object sender, EventArgs e) { if (_isUsernameValid && _isRealNameValid && _isPasswordValid && _isPhoneNumberValid && _isEmailAddressValid) { try { if (SupplierDataAccess.IsUsernameExisted(_username)) { MessageBox.Show("用户名已存在"); return; } SupplierDataAccess.InsertSupplier(_username, _realName, _password, _phoneNumber, _emailAddress); MessageBox.Show("注册成功!"); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } Close(); } else { MessageBox.Show("请检查字符串是否匹配"); } }
private void InsertSupplier(Model.Supplier.Supplier supplier) { if (supplier == null) { throw new ArgumentNullException("supplier", "Supplier"); } //Insert Supplier _supplierDataAccess.InsertSupplier(supplier); //Updating Supplier code supplier.SupplierCode = StringHelper.Right("00" + DateTime.Now.Year, 2) + "-" + StringHelper.Right("00" + DateTime.Now.Month, 2) + "-" + supplier.SupplierId; UpdateSupplier(supplier); }