void ButtonAddClick(object sender, EventArgs e) { using (PhysicalCountItemForm f = new PhysicalCountItemForm()) { if (WorkbenchSingleton.AddDialog(f) == DialogResult.OK) { PhysicalCountItem i = GetInDetails(f.Item); if (i != null) { i.AdjustedQty += f.Item.AdjustedQty; } else { count.AddItem(f.Item); } RefreshList(); PhysicalCountItem i3 = f.Item; if (i3.Item.IsFullCase()) { using (PhysicalCountItemForm f2 = new PhysicalCountItemForm()) { string suggestedCode = ItemSuggestionUtility.Suggest(i3.Item.Name.ToUpper().Replace("FC-", "MT-")); f2.FindCode(suggestedCode, i3.AdjustedQty); if (WorkbenchSingleton.AddDialog(f2) == DialogResult.OK) { PhysicalCountItem i2 = GetInDetails(f2.Item); if (i2 != null) { i2.AdjustedQty += f2.Item.AdjustedQty; } else { count.AddItem(f2.Item); } RefreshList(); } } } else if (i3.Item.IsSMBFullCase()) { using (PhysicalCountItemForm f2 = new PhysicalCountItemForm()) { string suggestedCode = ItemSuggestionUtility.Suggest(i3.Item.Name.ToUpper().Replace("SMBFC-", "SMBMT-")); f2.FindCode(suggestedCode, i3.AdjustedQty); if (WorkbenchSingleton.AddDialog(f2) == DialogResult.OK) { PhysicalCountItem i2 = GetInDetails(f2.Item); if (i2 != null) { i2.AdjustedQty += f2.Item.AdjustedQty; } else { count.AddItem(f2.Item); } RefreshList(); } } } } } }
void DeleteToolStripMenuItemClick(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { PhysicalCountItem i = count.Items[listView1.SelectedItems[0].Index]; count.Items.Remove(i); RefreshList(); } }
PhysicalCountItem GetInDetails(PhysicalCountItem item) { PhysicalCountItem dummy = null; foreach (var i in count.Items) { if (i.Item.Id == item.Item.Id) { return(i); } } return(dummy); }
void ListView1DoubleClick(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { PhysicalCountItem item = count.Items[listView1.SelectedItems[0].Index]; using (PhysicalCountItemForm f = new PhysicalCountItemForm(item)) { if (WorkbenchSingleton.AddDialog(f) == DialogResult.OK) { RefreshList(); } } } }
public ActionResult CreatePhysicalCountItems([Bind(Prefix = "updated")] List <PhysicalCountItemModel> updatedItems, [Bind(Prefix = "created")] List <PhysicalCountItemModel> createdItems, [Bind(Prefix = "deleted")] List <PhysicalCountItemModel> deletedItems) { if (ModelState.IsValid) { try { //Create PhysicalCountItems if (updatedItems != null) { //get the current physicalCount var physicalCountId = updatedItems.Count > 0 ? updatedItems[0].PhysicalCountId : 0; var physicalCountItems = _physicalCountItemRepository.GetAll().Where(r => r.PhysicalCountId == physicalCountId).ToList(); foreach (var model in updatedItems) { //we don't merge if the physicalCount item already existed //if (!physicalCountItems.Any(r => r.ItemId == model.Item.Id)) { //manually mapping here to set only foreign key //if used AutoMapper, the reference property will also be mapped //and EF will consider these properties as new and insert it //so db records will be duplicated //we can also ignore it in AutoMapper configuation instead of manually mapping var physicalCountItem = new PhysicalCountItem { PhysicalCountId = model.PhysicalCountId, ItemId = model.StoreLocatorItemBalance.ItemId, StoreLocatorId = model.StoreLocatorItemBalance.StoreLocatorId, CurrentQuantity = model.StoreLocatorItemBalance.TotalQuantity, Count = model.Count }; _physicalCountItemRepository.Insert(physicalCountItem); } } } _dbContext.SaveChanges(); SuccessNotification(_localizationService.GetResource("Record.Saved")); return(new NullJsonResult()); } catch (Exception e) { return(Json(new { Errors = e.Message })); } } else { return(Json(new { Errors = ModelState.SerializeErrors() })); } }
public PhysicalCountItemForm(PhysicalCountItem item) { InitializeComponent(); this.Item = item; }