public async Task TestAddUpdatDelete() { SupplierModule SupplierMod = new SupplierModule(); SupplierView view = new SupplierView() { SupplierId = 1, AddressId = 20, Identification = "test" }; NextNumber nnNextNumber = await SupplierMod.Supplier.Query().GetNextNumber(); view.SupplierNumber = nnNextNumber.NextNumberValue; Supplier supplier = await SupplierMod.Supplier.Query().MapToEntity(view); SupplierMod.Supplier.AddSupplier(supplier).Apply(); Supplier newSupplier = await SupplierMod.Supplier.Query().GetEntityByNumber(view.SupplierNumber); Assert.NotNull(newSupplier); newSupplier.Identification = "test update"; SupplierMod.Supplier.UpdateSupplier(newSupplier).Apply(); SupplierView updateView = await SupplierMod.Supplier.Query().GetViewById(newSupplier.SupplierId); Assert.Same(updateView.Identification, "test update"); SupplierMod.Supplier.DeleteSupplier(newSupplier).Apply(); Supplier lookupSupplier = await SupplierMod.Supplier.Query().GetEntityById(view.SupplierId); Assert.Null(lookupSupplier); }
private void supplierbarButtonItem_ItemClick_1(object sender, ItemClickEventArgs e) { var supplier = new SupplierView(); supplier.ShowList(); supplier.ShowDialog(); }
/// <summary> /// 根据ID获取供应商基本信息 /// </summary> /// <param name="id">编号</param> /// <returns></returns> public string Get(int id) { Supplier model = m_BLL.GetById(id); SupplierView viewModel = new SupplierView(); if (model != null) { Type t1 = typeof(Supplier); PropertyInfo[] propertys1 = t1.GetProperties(); Type t2 = typeof(SupplierView); PropertyInfo[] propertys2 = t2.GetProperties(); foreach (PropertyInfo pi in propertys2) { string[] arrField = new string[] { "Id", "Code", "Name", "OrganizationCode", "RegisterAddress", "OfficeAddress", "CustomerServiceId", "Status", "CreateTime", "CreateUserID", "CreateUserName" };//排除的字段 string name = pi.Name; if (arrField.Contains(name)) { object value = t1.GetProperty(name).GetValue(model, null); t2.GetProperty(name).SetValue(viewModel, value, null); } } string cityIDList = string.Empty; foreach (var city in model.SupplierNatureCity) { cityIDList += city.NatureCityId + ","; } viewModel.NatureCityId = cityIDList.Trim(','); } return(Newtonsoft.Json.JsonConvert.SerializeObject(viewModel)); }
public ActionResult Add(SupplierView supplierView) { string message = null; ViewBag.ActionName = "Add"; ViewBag.ButtonName = "Save"; ViewBag.Head = "Add"; Supplier supplier = Mapper.Map <Supplier>(supplierView); if (supplierView.Id != 0) { ViewBag.ActionName = "Show"; if (_supplierManager.Update(supplier)) { message = "Supplier is updated successfully"; } } else { message = _supplierManager.Add(supplier) ? "Supplier is saved successfully" : "Supplier is not saved"; } ViewBag.Message = message; ViewBag.Save = "save"; ModelState.Clear(); return(View(new SupplierView())); }
public static void Map(this Supplier destination, SupplierView source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (destination == null) { throw new ArgumentNullException(nameof(destination)); } var now = DateTime.UtcNow; if (destination.CreatedAt == null) { destination.CreatedAt = now; } destination.Name = source.Name; destination.Info = source.Info; destination.Logo = source.Logo; destination.ModifiedAt = now; destination.Active = source.Active; }
public async Task <bool> EditSupplier(SupplierView suppliers) { try { var ExistingSupplier = _context.ApSuppls.Where(x => x.ApSupplId == suppliers.ApSupplId).FirstOrDefault(); if (ExistingSupplier != null) { ExistingSupplier.NamaSup = suppliers.NamaSup; ExistingSupplier.Alamat = suppliers.Alamat; ExistingSupplier.Kota = suppliers.Kota; ExistingSupplier.Telpon = suppliers.Telpon; ExistingSupplier.NamaLengkap = suppliers.NamaLengkap; _context.ApSuppls.Update(ExistingSupplier); await _context.SaveChangesAsync(); return(true); } } catch (Exception ex) { throw ex; } return(false); }
public async Task <bool> AddSupplier(SupplierView suppliers) { string test = suppliers.Supplier.ToUpper(); var cekFirst = _context.ApSuppls.Where(x => x.Supplier == test).ToList(); if (cekFirst.Count == 0) { ApSuppl Supplier = new ApSuppl() { Supplier = suppliers.Supplier.ToUpper(), NamaSup = suppliers.NamaSup, Alamat = suppliers.Alamat, Kota = suppliers.Kota, Telpon = suppliers.Telpon, NamaLengkap = suppliers.NamaLengkap }; _context.ApSuppls.Add(Supplier); await _context.SaveChangesAsync(); return(true); } else { return(false); } }
public async Task TestGetSupplierBySupplierId() { int supplierId = 1; AddressBookModule abMod = new AddressBookModule(); SupplierView supplierView = await abMod.Supplier.Query().GetViewById(supplierId); Assert.True(supplierView != null); }
public async Task <IActionResult> GetSupplierView(long supplierId) { SupplierModule invMod = new SupplierModule(); SupplierView view = await invMod.Supplier.Query().GetViewById(supplierId); return(Ok(view)); }
public async Task <SupplierView> GetSupplierViewByEmail(EmailEntity emailEntity) { Supplier supplier = await _unitOfWork.supplierRepository.GetEntityByEmail(emailEntity); SupplierView view = await MapToSupplierView(supplier); return(view); }
public async Task <IActionResult> DeleteSupplier([FromBody] SupplierView view) { SupplierModule invMod = new SupplierModule(); Supplier supplier = await invMod.Supplier.Query().MapToEntity(view); invMod.Supplier.DeleteSupplier(supplier).Apply(); return(Ok(view)); }
public IHttpActionResult Add([FromBody] SupplierView supplier) { var supplierDTO = mapper.Map <SupplierView, SupplierDTO>(supplier); suppliersService.AddSupplier(supplierDTO); suppliersService.SaveChanges(); return(Ok()); }
public ActionResult Show() { SupplierView supplierView = new SupplierView { Suppliers = _supplierManager.GetAll() }; ViewBag.Show = "Show"; ViewBag.ActionName = "Add"; return(View(supplierView)); }
public IHttpActionResult Update([FromBody] SupplierView product) { var supplierDTO = mapper.Map <SupplierView, SupplierDTO>(product); suppliersService.UpdateSupplier(supplierDTO); suppliersService.SaveChanges(); return(Ok()); }
private void FormSupplierModify_Load(object sender, EventArgs e) { this.MaximizeBox = false; if (this.mode == FormMode.ALTER && this.supplierID == -1) { throw new Exception("未设置源供应商信息"); } Utilities.CreateEditPanel(this.tableLayoutPanel1, SupplierMetaData.KeyNames); //this.textBoxSupplierName = (TextBox)this.Controls.Find("textBoxSupplierName", true)[0]; //textBoxSupplierName.BackColor = Color.White; //textBoxSupplierName.MouseClick += textBoxSupplierName_MouseClick; ComboBox ComBoxContractState = (ComboBox)this.Controls.Find("comboBoxContractState", true)[0]; ComBoxContractState.BackColor = Color.White; if (this.mode == FormMode.ALTER) { SupplierView SupplierView = new SupplierView(); try { SupplierView = (from s in this.wmsEntities.SupplierView where s.ID == this.supplierID select s).Single(); } catch { MessageBox.Show("操作失败,请检查网络连接", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (SupplierView == null) { MessageBox.Show("修改失败,发货单不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } if (this.contractstate == "待审核") { ComBoxContractState.Enabled = false; TextBox textboxstartime = (TextBox)this.Controls.Find("textBoxStartingtime", true)[0]; textboxstartime.Enabled = false; TextBox textboxendtime = (TextBox)this.Controls.Find("textBoxEndingtime", true)[0]; textboxendtime.Enabled = false; } Utilities.CopyPropertiesToTextBoxes(SupplierView, this); Utilities.CopyPropertiesToComboBoxes(SupplierView, this); } }
private async Task <SupplierView> MapToSupplierView(Supplier inputObject) { Mapper mapper = new Mapper(); SupplierView outObject = mapper.Map <SupplierView>(inputObject); AddressBook addressBook = await _unitOfWork.addressBookRepository.GetEntityById(inputObject.AddressId); outObject.SupplierName = addressBook.Name; await Task.Yield(); return(outObject); }
public async Task <IActionResult> UpdateSupplier([FromBody] SupplierView view) { SupplierModule invMod = new SupplierModule(); Supplier supplier = await invMod.Supplier.Query().MapToEntity(view); invMod.Supplier.UpdateSupplier(supplier).Apply(); SupplierView retView = await invMod.Supplier.Query().GetViewById(supplier.SupplierId); return(Ok(retView)); }
private void btnDel_Click(object sender, RoutedEventArgs e) { try { MessageBoxResult result = MessageBox.Show("Are you sure you want to delete this supplier ?"); if (result == MessageBoxResult.OK) { SupplierView delSupplier = dgSuppliers.SelectedItem as SupplierView; suppliers.Remove(delSupplier); } } catch (Exception ex) { ((MainWindow)Application.Current.MainWindow).AddExceptionTextMsg(ex.ToString()); } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { try { SupplierView supAdditionOb = new SupplierView { FirstName = textBoxFirstName.Text.ToString(), LastName = textBoxLastName.Text.ToString(), Grs = textBoxGRS.Text.ToString(), Ids = textBoxIDS.Text.ToString(), Email = textBoxEmail.Text.ToString(), Tel1 = textBoxTelephone.Text.ToString(), Mob1 = textBoxMobile.Text.ToString(), LblPrintText = textBoxLabelText.Text.ToString() }; suppliers.Add(supAdditionOb); ((MainWindow)Application.Current.MainWindow).AddTextMsg("Supplier added succesful"); btnClear_Click(null, null); } catch (Exception ex) { ((MainWindow)Application.Current.MainWindow).AddExceptionTextMsg(ex.ToString()); } }
public async Task <IActionResult> AddSupplier([FromBody] SupplierView view) { SupplierModule invMod = new SupplierModule(); NextNumber nnSupplier = await invMod.Supplier.Query().GetNextNumber(); view.SupplierNumber = nnSupplier.NextNumberValue; Supplier supplier = await invMod.Supplier.Query().MapToEntity(view); invMod.Supplier.AddSupplier(supplier).Apply(); SupplierView newView = await invMod.Supplier.Query().GetViewByNumber(view.SupplierNumber); return(Ok(newView)); }
public JsonResult GetProductDataTable(System.Int32 id) { DataTableViewModel data; GetSupplierRequest request = new GetSupplierRequest(); request.SupplierID = id; SupplierView supplier = _supplierService.GetSupplier(request).Supplier; data = new DataTableViewModel(); data.draw = "1"; data.recordsTotal = supplier.Products.ToList().Count.ToString(); data.recordsFiltered = supplier.Products.ToList().Count.ToString(); data.data = supplier.Products.ConvertToDetailSupplierProductDetailViews().ToList <object>(); return(Json(data, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 修改供应商基本信息 /// </summary> /// <param name="viewModel">供应商</param> /// <returns></returns> public int EditSupplier(SupplierView viewModel) { using (SysEntities db = new SysEntities()) { using (var tran = db.Database.BeginTransaction()) { try { //基本信息 var entity = db.Supplier.Where(e => e.Id == viewModel.Id).FirstOrDefault(); entity.Code = viewModel.Code; entity.Name = viewModel.Name; entity.OfficeAddress = viewModel.OfficeAddress; entity.OrganizationCode = viewModel.OrganizationCode; entity.RegisterAddress = viewModel.RegisterAddress; //社保缴纳地 var oldCityList = db.SupplierNatureCity.Where(e => e.SupplierId == viewModel.Id).ToList(); string[] arrOldCity = new string[oldCityList.Count()];//旧城市ID数组 for (int i = 0; i < oldCityList.Count(); i++) { arrOldCity[i] = oldCityList[i].NatureCityId; } List <SupplierNatureCity> newCityList = GetCityList(viewModel.Id, viewModel.NatureCityId, arrOldCity); if (newCityList.Count > 0) { db.SupplierNatureCity.RemoveRange(oldCityList); db.SupplierNatureCity.AddRange(newCityList); } db.SaveChanges(); tran.Commit(); return(1); } catch (Exception ex) { tran.Rollback(); return(0); } } } }
public ActionResult Show(int id, string search) { SupplierView supplierView; ViewBag.Show = "Show"; ViewBag.ActionName = "Add"; if (search == null) { ViewBag.Message = _supplierManager.Delete(id) ? "Deleted" : "Not deleted"; supplierView = new SupplierView { Suppliers = _supplierManager.GetAll() }; } else { supplierView = new SupplierView { Suppliers = _supplierManager.SearchSuppliers(search) }; } return(View(supplierView)); }
public ActionResult Add(int id) { SupplierView supplierView = new SupplierView(); ViewBag.ActionName = "Show Supplier"; if (id != 0) { Supplier supplier = _supplierManager.GetById(id); supplierView = Mapper.Map <SupplierView>(supplier); ViewBag.Head = "Update"; ViewBag.ButtonName = "Update"; ViewBag.Message = null; } else { ViewBag.Message = null; ViewBag.Head = "Add"; ViewBag.ButtonName = "Save"; } return(View(supplierView)); }
public bool EditSupplier(ref ValidationErrors validationErrors, SupplierView model) { try { int result = repository.EditSupplier(model); if (result == 1) { return(true); } else { return(false); } } catch (Exception ex) { validationErrors.Add(ex.Message); ExceptionsHander.WriteExceptions(ex); return(false); } }
//得到Supplier Model private Supplier GetModel(SupplierView viewModel) { Supplier model = new Supplier(); if (viewModel != null) { string[] arrField = new string[] { "Code", "Name", "OrganizationCode", "RegisterAddress", "OfficeAddress", "CustomerServiceId", "Status", "CreateTime", "CreateUserID", "CreateUserName" };//排除的字段 Type t1 = typeof(SupplierView); PropertyInfo[] propertys1 = t1.GetProperties(); Type t2 = typeof(Supplier); PropertyInfo[] propertys2 = t2.GetProperties(); foreach (PropertyInfo pi in propertys2) { string name = pi.Name; if (arrField.Contains(name)) { object value = t1.GetProperty(name).GetValue(viewModel, null); t2.GetProperty(name).SetValue(model, value, null); } } } return(model); }
/// <summary> /// 修改供应商基本信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public Common.ClientResult.Result PutBasic([FromBody] SupplierView model) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (model != null && ModelState.IsValid) { string returnValue = string.Empty; if (m_BLL.EditSupplier(ref validationErrors, model)) { LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",供应商管理_供应商的Id为" + model.Id, "修改供应商管理基本信息" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.UpdateSucceed; return(result); //提示创建成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",供应商管理," + returnValue, "修改供应商管理基本信息" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.UpdateFail + returnValue; return(result); //提示插入失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.UpdateFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对 return(result); }
public static DetailSupplier_SupplierDetailView ConvertToDetailSupplier_SupplierDetailView( this SupplierView suppliers) { return(Mapper.Map <SupplierView, DetailSupplier_SupplierDetailView>(suppliers)); }
public static SupplierDetailView ConvertToSupplierDetailView( this SupplierView supplier) { return(Mapper.Map <SupplierView, SupplierDetailView>(supplier)); }
public static ModifySupplierRequest ConvertToModifySupplierRequest( this SupplierView suppliers) { return(Mapper.Map <SupplierView, ModifySupplierRequest>(suppliers)); }