/// <summary> /// 更新修改 /// </summary> /// <param name="model"></param> public void updateSupplier(Entities.Supplier model) { _sysSupplierRepository.DbContext.Entry(model).State = EntityState.Unchanged; _sysSupplierRepository.DbContext.Entry(model).Property("SupplierCode").IsModified = true; _sysSupplierRepository.DbContext.Entry(model).Property("Describe").IsModified = true; _sysSupplierRepository.DbContext.SaveChanges(); }
public ActionResult EditSupplier(Entities.Supplier model, string returnUrl = null) { ModelState.Remove("Id"); ViewBag.ReturnUrl = Url.IsLocalUrl(returnUrl) ? returnUrl : Url.RouteUrl("SupplierIndex"); if (!ModelState.IsValid) { return(View(model)); } if (!String.IsNullOrEmpty(model.SupplierCode)) { model.SupplierCode = model.SupplierCode; } if (!String.IsNullOrEmpty(model.Describe)) { model.Describe = model.Describe.Trim(); } // if (!String.IsNullOrEmpty(model.Description)) // model.Description = model.Description.Trim(); if (model.Id == 0) { var a = _sysSupplierService.existAccount(model.SupplierCode); if (a != true) { _sysSupplierService.insertSupplier(model); } else { Response.WriteAsync("<script>alert('供应商代码重复!');window.location.href ='SupplierIndex'</script>", Encoding.GetEncoding("GB2312")); } } else { var b = _sysSupplierService.getCount(model.SupplierCode, model.Id); if (b.Count < 1) { _sysSupplierService.updateSupplier(model); } else { Response.WriteAsync("<script>alert('供应商代码重复!');window.location.href ='SupplierIndex'</script>", Encoding.GetEncoding("GB2312")); } } return(Redirect(ViewBag.ReturnUrl)); }
private void BtnRegisterClient_Click(object sender, RoutedEventArgs e) { var errors = ""; if (string.IsNullOrWhiteSpace(TxtBoxFirstName.Text)) { errors += "Вы не ввели имя\r\n"; } if (string.IsNullOrWhiteSpace(TxtBoxLastName.Text)) { errors += "Вы не ввели фамилию\r\n"; } if (string.IsNullOrWhiteSpace(TxtBoxLogin.Text)) { errors += "Вы не ввели логин\r\n"; } if (string.IsNullOrWhiteSpace(PassBoxPass.Password)) { errors += "Вы не ввели пароль\r\n"; } if (AppData.Context.User.ToList().Where(p => p.Login == TxtBoxLogin.Text).FirstOrDefault() != null) { errors += "Пользователь с таким логином уже существует"; } if (ChkBoxSupplier.IsChecked == true) { if (string.IsNullOrWhiteSpace(TxtBoxSupplierName.Text)) { errors += "Вы не ввели название организации\r\n"; } if (string.IsNullOrWhiteSpace(TxtBoxINN.Text)) { errors += "Вы не ввели ИИН\r\n"; } if (string.IsNullOrWhiteSpace(TxtBoxORGN.Text)) { errors += "Вы не ввели ОРГН\r\n"; } if (CmbBoxCountry.SelectedItem == null) { errors += "Вы не выбрали страну\r\n"; } } if (errors.Length == 0) { var newUser = new User() { FirstName = TxtBoxFirstName.Text, LastName = TxtBoxLastName.Text, Patronymic = TxtBoxPatronymic.Text == "" ? null : TxtBoxPatronymic.Text, Login = TxtBoxLogin.Text, Password = PassBoxPass.Password, RoleId = ChkBoxSupplier.IsChecked == true ? 2 : 1, }; AppData.Context.User.Add(newUser); AppData.Context.SaveChanges(); if (ChkBoxSupplier.IsChecked == true) { var newSupplier = new Entities.Supplier() { Id = newUser.Id, Name = TxtBoxSupplierName.Text, INN = TxtBoxINN.Text, ORGN = TxtBoxORGN.Text, CountryId = (CmbBoxCountry.SelectedItem as Country).Id }; AppData.Context.Supplier.Add(newSupplier); AppData.Context.SaveChanges(); } MessageBox.Show("Вы успешо зарегистрировались", "Информация", MessageBoxButton.OK, MessageBoxImage.Information); NavigationService.GoBack(); } else { MessageBox.Show(errors, "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// 新增,插入 /// </summary> /// <param name="model"></param> public void insertSupplier(Entities.Supplier model) { //if (existAccount(model.Name)) // return; _sysSupplierRepository.insert(model); }
internal static Supplier GetSupplier(int id, int portalID, int languageID) { Supplier Supplier = null; using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString)) { SqlCommand sqlCommand = new SqlCommand(SN_SUPPLIER_GET_BY_ID, sqlConnection); sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter sqlParameter = null; sqlParameter = new SqlParameter(PN_SUPPLIER_ID, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = id; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_SUPPLIER_PORTAL_ID, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = portalID; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(ECommerceDataMapperBase.PN_MODULE_ID, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = (int)CMSEnums.ECommerceModule.Supplier; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(ECommerceDataMapperBase.PN_ECO_LAN_LAN_ID, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = languageID; sqlCommand.Parameters.Add(sqlParameter); sqlCommand.Connection.Open(); using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { while (sqlDataReader.Read()) { Supplier = new Entities.Supplier(); FillFromReader(Supplier, sqlDataReader); } sqlDataReader.Close(); sqlCommand.Connection.Close(); } } return Supplier; }