/// <summary> /// This Recieves an order and needs serious refactoring /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRecieveOrderItems_Click(object sender, EventArgs e) { OrderReciept receipt = null; // if the selected order is valid then process the order if (selectedOrder != null) { receipt = ordersService.RecievedOrder(selectedOrder, Globals.CurrentLoggedUserID); } if (receipt.OrderReceiptId != default(int)) { string notifyTO = selectedOrder.Employee.EmployeeEmail.ToString(); var frm = Application.OpenForms.Cast <Form>().Where(x => x.Name == "Main").FirstOrDefault(); TabPage orderTab = new TabPage(); OrderReceiptControl control = new OrderReceiptControl(receipt, _context); orderTab.Controls.Add(control); orderTab.Text = "Receive : " + receipt.OrderReceiptId.ToString(); ((Main)frm).MainTabControl.TabPages.Add(orderTab); ((Main)frm).MainTabControl.SelectedTab = orderTab; //// new Thread(() => NotificationService.SendNotificaion(notifyTO, selectedOrder)).Start(); } }
//Open Dialog modal editor to process LineItems to Inventory private void btnRecieve_Click(object sender, EventArgs e) { // Create an OrderReceipt-Get ID OrderReciept oReciept = new OrderReciept(); oReciept.EmployeeID = recieverID; oReciept.ReceiptDate = DateTime.Today; oReciept.OrderNum = selectedOrder.OrderNum; _context.OrderReciepts.Add(oReciept); _context.SaveChanges(); // Cycle though all the lineitems foreach (PurchaseLineItem item in items) { Inventory inv = new Inventory(); inv.Qnty = item.Qnty.Value; inv.DateStamp = DateTime.Today; inv.LineID = item.LineID; inv.JobID = selectedOrder.Job_id.Value; inv.OrderReceiptID = oReciept.OrderReceiptID; if (item.PartID.HasValue) { inv.PartID = item.PartID.Value; } inv.Qnty = item.Qnty.Value; inv.Description = item.Description; inv.UnitOfMeasure = (item.Uom.HasValue) ? inv.UnitOfMeasure = item.Uom : inv.UnitOfMeasure = -1; _context.Inventories.Add(inv); } _context.SaveChanges(); }
public InventoryLookupItem(Inventory inventory, BadgerDataModel ctx) { if (inventory == null) { return; } _context = ctx; jobService = new JobsService(_context); orderService = new OrdersService(_context); recieptService = new OrderRecieptService(_context); employeeService = new EmployeeService(_context); po = orderService.GetOrderByID(recieptService.GetOrderReciept (inventory.OrderReceiptID.Value).OrderNum.Value); job = jobService.Find(inventory.JobId.Value); receipt = recieptService.GetOrderReciept(inventory.OrderReceiptID.Value); emp = employeeService.Find(receipt.EmployeeId.Value); orderNum = po.OrderNum.ToString(); orderDate = po.OrderDate.Value.ToShortDateString(); jobName = job.Jobname.ToString(); quantity = inventory.Qnty.ToString(); unitCost = "0.0"; itemDescription = inventory.Description; supplierName = po.Supplier.SupplierName.ToString(); receivedDate = receipt.ReceiptDate.Value.ToShortDateString(); receivedBy = emp.Firstname + " " + emp.Lastname; orderedBy = po.Employee.Firstname.ToString() + " " + po.Employee.Lastname.ToString(); }
private void BlowNGo(int option) { // Create an OrderReceipt-Get ID OrderReciept oReciept = new OrderReciept(); oReciept.EmployeeID = recieverID; oReciept.ReceiptDate = DateTime.Today; oReciept.OrderNum = selectedOrder.OrderNum; _context.OrderReciepts.Add(oReciept); _context.SaveChanges(); //----- Consume Items No impact on inventory if (option == 0) { // Cycle though all the lineitems foreach (PurchaseLineItem item in items) { Inventory inv = new Inventory(); inv.Qnty = item.Qnty.Value; inv.DateStamp = DateTime.Today; inv.LineID = item.LineID; inv.JobID = selectedOrder.Job_id.Value; inv.OrderReceiptID = oReciept.OrderReceiptID; if (item.PartID.HasValue) { inv.PartID = item.PartID.Value; } inv.Qnty = item.Qnty.Value; inv.Description = item.Description; inv.UnitOfMeasure = (item.Uom.HasValue) ? inv.UnitOfMeasure = item.Uom : inv.UnitOfMeasure = -1; _context.Inventories.Add(inv); } } // ----Push the item qntys to inventory if (option == 1) { // Cycle though all the lineitems foreach (PurchaseLineItem item in items) { Inventory inv = new Inventory(); inv.Qnty = item.Qnty.Value; inv.DateStamp = DateTime.Today; inv.LineID = item.LineID; inv.JobID = selectedOrder.Job_id.Value; inv.OrderReceiptID = oReciept.OrderReceiptID; if (item.PartID.HasValue) { inv.PartID = item.PartID.Value; } inv.Qnty = item.Qnty.Value; inv.Description = item.Description; inv.UnitOfMeasure = (item.Uom.HasValue) ? inv.UnitOfMeasure = item.Uom : inv.UnitOfMeasure = -1; _context.Inventories.Add(inv); } } _context.SaveChanges(); }
public OrderReceiptControl(OrderReciept receipt, BadgerDataModel ctx) { InitializeComponent(); this._context = ctx; _receipt = receipt; jService = new JobsService(ctx); oService = new OrdersService(ctx); }
public void InsertOrUpdate(OrderReciept orderReciept) { if (orderReciept.OrderReceiptId == default(int)) { context.OrderReciept.Add(orderReciept); } else { context.Entry(orderReciept).State = EntityState.Modified; } }
public void TaxCalculationForBasket3() { OrderBasket order = new OrderBasket(); GetOrderBasket3Items(order); ITaxCalculator obj = new TaxCalculator(); OrderReciept response = obj.TaxCalculation(order); Assert.IsNotNull(response); Assert.AreNotSame(response.IsTaxCalculationDone, true); Assert.AreNotSame(response.TotalPrice, 0.00); }
private void button1_Click(object sender, EventArgs e) { int item = comboBox1.SelectedIndex; OrderBasket order = new OrderBasket(); switch (item) { case 1: GetOrderItems(order); break; case 2: GetOrderBasket2Items(order); break; case 3: GetOrderBasket3Items(order); break; default: break; } OrderReciept response = m_TaxCalculator.TaxCalculation(order); DataTable dtResult = new DataTable(); dtResult.Columns.Add("Item", typeof(string)); dtResult.Columns.Add("Item qty", typeof(string)); dtResult.Columns.Add("Item price", typeof(string)); if (response.IsTaxCalculationDone) { DataRow row; foreach (TaxRequestItem taxitem in response.TaxRequestItems) { row = dtResult.NewRow(); row["Item"] = taxitem.Item; row["Item qty"] = taxitem.ItemQuantity; row["Item price"] = taxitem.Price; dtResult.Rows.Add(row); } row = dtResult.NewRow(); row["Item qty"] = "sales tax"; row["Item price"] = response.SalesTax; dtResult.Rows.Add(row); row = dtResult.NewRow(); row["Item qty"] = "Total Price"; row["Item price"] = response.TotalPrice; dtResult.Rows.Add(row); } dataGridView1.DataSource = dtResult; }
public OrderReciept Create(int employeeID, int purchaseOrderID = 0) { var result = new OrderReciept { ReceiptDate = DateTime.Now, EmployeeId = employeeID, OrderNum = purchaseOrderID, }; context.OrderReciept.Add(result); context.SaveChanges(); return(result); }
/// <summary> /// Bind the Control and Grid to reciept Object /// </summary> /// <param name="reciept"></param> private void BindOrderReceiptItems(OrderReciept reciept) { inventoryItems = (from c in _context.Inventory where c.OrderReceiptID == reciept.OrderReceiptId select c).ToList(); Employee employee = (from c in _context.Employee where c.EmployeeId == reciept.EmployeeId select c).FirstOrDefault(); this.txtOrderReceiptID.Text = reciept.OrderReceiptId.ToString(); this.txtOrderNo.Text = reciept.OrderNum.ToString(); this.txtReciptDate.Text = reciept.ReceiptDate.Value.ToShortDateString(); this.txtReceivedBy.Text = employee.Firstname.ToString() + " " + employee.Lastname.ToString(); // Bind to Binding source and set source this.dgOrderReceiptItems.DataSource = bsOrderReceiptItems; bsOrderReceiptItems.DataSource = inventoryItems; }
public static void RecieveOrder(PurchaseOrder order, BadgerDataModel ctx) { OrderReciept receipt = new OrderReciept(); receipt.OrderNum = order.OrderNum; receipt.ReceiptDate = DateTime.Today; receipt.EmployeeId = 8; ctx.OrderReciept.Add(receipt); ctx.SaveChanges(); foreach (PurchaseLineItem item in order.PurchaseLineItem) { Inventory inv = new Inventory(); inv.OrderReceiptID = receipt.OrderReceiptId; inv.LineID = item.LineID; if (item.PartID.HasValue) { inv.PartID = item.PartID.Value; } inv.JobId = item.PurchaseOrderId.Value; inv.DateStamp = DateTime.Today; if (item.AmountReceived.HasValue) { inv.Qnty = item.AmountReceived.Value; } //inv.Note = item.N inv.Description = item.Description.ToString(); if (inv.UnitOfMeasure.HasValue) { inv.UnitOfMeasure = item.Uom; } receipt.Inventory.Add(inv); } order.Recieved = true; order.RecievedDate = DateTime.Today; ctx.SaveChanges(); //// Push the new Order Receipt to The New Tab //MainFrm f = (MainFrm)Application.OpenForms["MainFrm"]; //TabControl.TabPageCollection col = f.tabMain.TabPages; //TabPage orderReceiptPage = new TabPage(); //orderReceiptPage.Text = "Order Receipt -> " + receipt.OrderReceiptID.ToString(); //OrderReceiptControl control = new OrderReceiptControl(receipt,ctx); //control.Dock = DockStyle.Fill; //orderReceiptPage.Controls.Add(control); //col.Add(orderReceiptPage); //f.tabMain.SelectedTab = orderReceiptPage; }
private void lbOrderRecieptList_SelectedIndexChanged(object sender, EventArgs e) { ListBox lb = (ListBox)sender; OrderReciept jReciept = (OrderReciept)lb.SelectedItem; if (lb.DataSource != null) { if (lb.SelectedItems.Count > 0) { dgRecieptItems.DataSource = inventoryService.GetOrderRecieptItems(jReciept.OrderReceiptId); } BindRecieptDetails(jReciept); } }
/// <summary> /// Select a Job OrderReciept to show the items /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lvJobReciepts_SelectedIndexChanged(object sender, EventArgs e) { ListView lb = (ListView)sender; if (lb.Items.Count > 0) { if (lb.SelectedItems.Count > 0) { OrderReciept reciept = (OrderReciept)lb.SelectedItems[0].Tag; bsRecieptItemBindingSource.DataSource = reciept.Inventory.ToList(); dgRecieptItems.DataSource = bsRecieptItemBindingSource; BindRecieptDetails(reciept); } } }
private void BindRecieptDetails(OrderReciept reciept) { var order = poService.GetOrderByID(reciept.OrderNum.Value); if (order.Job != null) { this.txtJobName.Text = order.Job.Jobname.ToString(); } this.txtOrderDate.Text = order.OrderDate.Value.ToShortDateString(); this.txtPoNumber.Text = order.OrderNum.ToString(); this.txtPurchaser.Text = order.Employee.Firstname.ToString() + " " + order.Employee.Lastname.ToString(); this.txtRecievedDate.Text = reciept.ReceiptDate.Value.ToShortDateString(); this.txtSupplier.Text = order.Supplier.SupplierName; this.txtReciever.Text = empService.Find(reciept.EmployeeId.Value).Lastname.ToString(); }
//Recieve Order -- public OrderReciept RecievedOrder(PurchaseOrder order, int employeeID) { // Build and save OrderReceipt -- OrderReciept oreciept = new OrderReciept(); oreciept.OrderNum = order.OrderNum; oreciept.EmployeeId = employeeID; oreciept.ReceiptDate = DateTime.Now; context.OrderReciept.Add(oreciept); context.SaveChanges(); List <ClaimItem> claimItems = new List <ClaimItem>(); foreach (PurchaseLineItem item in order.PurchaseLineItem) { Inventory inv = new Inventory(); inv.DateStamp = DateTime.Now; inv.Description = item.Description.ToString().TrimEnd(); inv.JobId = order.JobId; inv.LineID = item.LineID; inv.Location = string.Empty; inv.Note = item.Note; inv.OrderReceiptID = oreciept.OrderReceiptId; inv.UnitOfMeasure = item.Uom ?? 1; inv.Qnty = item.Qnty ?? 0; item.Recieved = true; item.OrderReceiptId = oreciept.OrderReceiptId; inv.PartID = item.PartID ?? null; if (!(item.Description.Length == 0) && !(item.Qnty == default(decimal))) { context.Entry(inv).State = EntityState.Added; context.Inventory.Add(inv); context.Entry(item).State = EntityState.Modified; if (item.Rejected == true) { var c = new ClaimItem { LineID = item.LineID, Description = item.Description, Bcode = item.Bcode, PartID = item.PartID }; claimItems.Add(c); } } } order.Recieved = true; order.RecievedDate = DateTime.Today; if (claimItems.Count > 0) { //ClaimService claimService = new ClaimService(context); //var newClaim = claimService.NewClaim(order.OrderNum, Globals.CurrentLoggedUserID); //foreach (ClaimItem clm in claimItems) //{ // newClaim.ClaimItem.Add(clm); //} context.SaveChanges(); } try { context.SaveChanges(); } catch (DbUpdateException ex) { string err = ex.InnerException.ToString(); Console.Write(err); throw; } return(oreciept); }
public void SetDataSource(OrderReciept orderReceipt) { _receipt = orderReceipt; }