private void btnUpdate_Click(object sender, EventArgs e) { int x = 1; int q = 0; frmMain.receivedreport.ReportDataSet.Clear(); for (int i = 0; i < dgvReceiving.Rows.Count; i++) { POHistoryobj poh = new POHistoryobj(); ReceiveObj rcv = ReceivingList[i]; poh.Cost = rcv.Cost; poh.EnteredBy = txtOperationName.Text; poh.ItemNumber = rcv.ItemNumber; poh.LocalSKU = rcv.LocalSKU; poh.PONumber = rcv.PONumber; poh.Quantity = rcv.QtyReceived; poh.SuppliersSKU = rcv.SupplierSKU; POHistory.Insert(poh); Inv.UpdatePrice(rcv.LocalSKU, rcv.Price, rcv.Price2, rcv.Price3, rcv.QtyReceived); string res = ""; InventoryRecord ir = Inv.GetData(rcv.LocalSKU, rcv.LocalSKU, ref res); ReportDataSet.InventoryRow r = frmMain.receivedreport.ReportDataSet.Inventory.NewInventoryRow(); r.Barcode = ir.Barcode; r.BarcodeImage = "file:///" + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//SIO//BI//" + ir.Barcode + ".jpg"; r.ID = x; r.ItemName = ir.ProductName; r.Location = ir.Location; r.Price = "$" + Math.Round(ir.Price, 2).ToString(); r.Price3 = "$" + Math.Round(ir.Price3, 2).ToString(); r.Qty = rcv.QtyReceived; q += rcv.QtyReceived; r.SKU = ir.SKU; r.OrderNumber = rcv.OrderNumber.ToString(); frmMain.receivedreport.ReportDataSet.Tables[0].Rows.Add(r); if (checkBox1.Checked) { dgvReceiving_CellContentClick(dgvReceiving, new DataGridViewCellEventArgs(dgvReceiving.Columns["clm2QuickPrint"].Index, i)); } } frmMain.receivedreport.WindowState = FormWindowState.Normal; frmMain.receivedreport.StartPosition = FormStartPosition.CenterScreen; frmMain.receivedreport.reportViewer1.RefreshReport(); foreach (POLogObj item in pologlist) { POLog.Update(item.POLogID); } frmMain.receivedreport.ShowDialog(); ResetAll((Control)cbSupplier); }
private void btnCancelLastItem_Click(object sender, EventArgs e) { if (ReceivingList.Count == 0) { return; } ReceiveObj rcv = ReceivingList.Last(); if (rcv == null) { return; } if (rcv.PONumber == 0) { rbs.Remove(rcv); dgvReceiving.Refresh(); } else { PurchaseOrderDetailsObj pod = purchaseorderdetailslist.FirstOrDefault(m => m.PONumber == rcv.PONumber && m.LocalSKU == rcv.LocalSKU); if (pod != null) { pod.QuantityRemaining += rcv.QtyReceived; rbs.Remove(rcv); dgvReceiving.Refresh(); dgvEcpected.Refresh(); } else { pod = PurchaseOrderDetails.GetByPONumber(rcv.PONumber).FirstOrDefault(m => m.LocalSKU == rcv.LocalSKU); if (pod != null) { bs.Add(pod); rbs.Remove(rcv); dgvReceiving.Refresh(); dgvEcpected.Refresh(); } } } }
private void dgvReceiving_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && dgvReceiving.Columns["clm2QuickPrint"].Index == e.ColumnIndex) { string res = ""; InventoryRecord ir = Inv.GetData(dgvReceiving.Rows[e.RowIndex].Cells["clm2SKU"].Value.ToString(), dgvReceiving.Rows[e.RowIndex].Cells["clm2SKU"].Value.ToString(), ref res); string Barcode = ir.Barcode; string SKU = ir.SKU; string Price = "$" + Math.Round(ir.Price, 2); string ItemName = ir.ProductName; switch (dgvReceiving.Rows[e.RowIndex].Cells["clmPrintFormat"].Value.ToString()) { case "BarcodeNOPrice": Price = " "; break; case "BarcodePrice3": Price = "$" + Math.Round(ir.Price3, 2).ToString(); break; case "BarcodePrice4": Price = "$" + Math.Round(ir.Price4, 2).ToString(); break; } printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 225, 125); PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog(); printDocument1.DocumentName = SKU + "," + Barcode + "," + ItemName + "," + Price; FileInfo fr = new FileInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//SIO//DPB.txt"); if (fr.Exists) { StreamReader sr = new StreamReader(fr.FullName); string xx = sr.ReadToEnd(); sr.Close(); printDocument1.DefaultPageSettings.PrinterSettings.PrinterName = xx.Trim(); } int Width = 225; int hieght = 125; FileInfo frW = new FileInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//SIO//DPBW.txt"); if (frW.Exists) { StreamReader sr = new StreamReader(frW.FullName); string xx = sr.ReadToEnd(); sr.Close(); Width = Convert.ToInt16(Convert.ToDecimal(xx) * 100); } FileInfo frH = new FileInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//SIO//DPBH.txt"); if (frH.Exists) { StreamReader sr = new StreamReader(frH.FullName); string xx = sr.ReadToEnd(); sr.Close(); hieght = Convert.ToInt16(Convert.ToDecimal(xx) * 100); } printDocument1.DefaultPageSettings.PrinterSettings.Copies = Convert.ToInt16(dgvReceiving.Rows[e.RowIndex].Cells["clm2QtyReceived"].Value.ToString()); printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", Width, hieght); printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDocument1_PrintPage); //printPreviewDialog.Document = printDocument1; //printPreviewDialog.Shown += new EventHandler(printPreviewDialog_Shown); //printPreviewDialog.ShowDialog(); printDocument1.Print(); } if (e.ColumnIndex == dgvReceiving.Columns["clm2Cost"].Index || e.ColumnIndex == dgvReceiving.Columns["clm2Price"].Index || e.ColumnIndex == dgvReceiving.Columns["clm2Price2"].Index || e.ColumnIndex == dgvReceiving.Columns["clm2Price3"].Index) { dgvReceiving.BeginEdit(true); return; } if (e.RowIndex >= 0 && dgvReceiving.Columns["clm2ViewOrder"].Index == e.ColumnIndex) { frmViewOrder f = new frmViewOrder(); f.PONumber = Convert.ToInt32(dgvReceiving.Rows[e.RowIndex].Cells["clm2PONum"].Value); f.PODate = PurchaseOrders.GetByID(f.PONumber).PODate; f.OrderNumber = Convert.ToInt32(dgvReceiving.Rows[e.RowIndex].Cells["clm2OrderNumber"].Value); f.ShowDialog(); } if (e.RowIndex >= 0 && dgvReceiving.Columns["clm2Cancel"].Index == e.ColumnIndex) { ReceiveObj rcv = (ReceiveObj)rbs[e.RowIndex]; if (rcv.PONumber == 0) { rbs.RemoveAt(e.RowIndex); dgvReceiving.Refresh(); } else { PurchaseOrderDetailsObj pod = purchaseorderdetailslist.FirstOrDefault(m => m.PONumber == rcv.PONumber && m.LocalSKU == rcv.LocalSKU); if (pod != null) { pod.QuantityRemaining += rcv.QtyReceived; rbs.RemoveAt(e.RowIndex); dgvReceiving.Refresh(); dgvEcpected.Refresh(); } else { pod = PurchaseOrderDetails.GetByPONumber(rcv.PONumber).FirstOrDefault(m => m.LocalSKU == rcv.LocalSKU); if (pod != null) { bs.Add(pod); rbs.RemoveAt(e.RowIndex); dgvReceiving.Refresh(); dgvEcpected.Refresh(); } } } return; } }
public void Receive(string SKU, int Quantity, int PONumber = 0) { PurchaseOrderDetailsObj pod; if (PONumber == 0) { pod = purchaseorderdetailslist.FirstOrDefault(m => m.LocalSKU.ToLower() == SKU.ToLower()); } else { pod = purchaseorderdetailslist.FirstOrDefault(m => m.LocalSKU.ToLower() == SKU.ToLower() && m.PONumber == PONumber); } if (pod != null) { ReceiveObj rcv = ReceivingList.FirstOrDefault(m => m.PONumber == pod.PONumber && m.LocalSKU.ToLower() == pod.LocalSKU.ToLower()); if (rcv == null) { string res = ""; InventoryRecord InvR = Inv.GetData(SKU, SKU, ref res); ReceiveObj Newrcv = new ReceiveObj(); Newrcv.ItemName = pod.ItemName; Newrcv.ItemNumber = pod.ItemNumber; Newrcv.Cost = Math.Round(pod.ExpectedCost, 4); Newrcv.LocalSKU = pod.LocalSKU; Newrcv.Location = InvR.Location; Newrcv.OrderNumber = InvR.OrderNumber; Newrcv.PONumber = pod.PONumber; Newrcv.Price = InvR.Price; Newrcv.Price2 = InvR.Price2; Newrcv.Price3 = InvR.Price3; if (Quantity > pod.QuantityRemaining) { Console.Beep(3800, 500); if (MessageBox.Show("The Selected Quantity is bigger than that expected. Do you want to receive more?", "Scan In&Out", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No) { return; } Newrcv.QtyReceived = Quantity; } else { Newrcv.QtyReceived = Quantity; } Newrcv.SupplierSKU = pod.SuppliersSKU; rbs.Add(Newrcv); #region LOG POLogObj l = new POLogObj(); l.Cost = Newrcv.Cost; l.IsUpdated = false; l.ItemName = Newrcv.ItemName; l.ItemNumber = Newrcv.ItemNumber; l.Location = Newrcv.Location; l.OrderNumber = Newrcv.OrderNumber; l.PONumber = Newrcv.PONumber; l.Price = Newrcv.Price; l.Price2 = Newrcv.Price2; l.Price3 = Newrcv.Price3; l.QtyOrdered = pod.Ordered; l.QtyReceived = Newrcv.QtyReceived; l.QtyRemaining = pod.QuantityRemaining; l.SKU = Newrcv.LocalSKU; l.SupplierID = Convert.ToInt32(cbSupplier.SelectedValue); l.SupplierName = cbSupplier.Text; l.SupplierSKU = Newrcv.SupplierSKU; if (!RestoreMode) { POLog.Insert(l); } pologlist.Add(l); #endregion dgvReceiving.Refresh(); LastItem = Newrcv.PONumber.ToString() + "," + Newrcv.LocalSKU + "," + Quantity.ToString(); FileInfo fi = new FileInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//SIO//BI//" + InvR.Barcode + ".jpg"); if (!fi.Exists) { Image i = Code128Rendering.MakeBarcodeImage(InvR.Barcode, 1, true); i.Save(fi.FullName); } } else { rcv.QtyReceived += Quantity; LastItem = rcv.PONumber.ToString() + "," + rcv.LocalSKU + "," + Quantity.ToString(); #region LOG POLogObj l = new POLogObj(); l.Cost = rcv.Cost; l.IsUpdated = false; l.ItemName = rcv.ItemName; l.ItemNumber = rcv.ItemNumber; l.Location = rcv.Location; l.OrderNumber = rcv.OrderNumber; l.PONumber = rcv.PONumber; l.Price = rcv.Price; l.Price2 = rcv.Price2; l.Price3 = rcv.Price3; l.QtyOrdered = pod.Ordered; l.QtyReceived = rcv.QtyReceived; l.QtyRemaining = pod.QuantityRemaining; l.SKU = rcv.LocalSKU; l.SupplierID = Convert.ToInt32(cbSupplier.SelectedValue); l.SupplierName = cbSupplier.Text; l.SupplierSKU = rcv.SupplierSKU; if (!RestoreMode) { POLog.Insert(l); } pologlist.Add(l); #endregion } Console.Beep(); dgvReceiving.Refresh(); if (pod.QuantityRemaining < Quantity) { pod.QuantityRemaining = 0; } else { pod.QuantityRemaining -= Quantity; } } else { Console.Beep(3800, 500); ReceiveObj rcv = ReceivingList.FirstOrDefault(m => m.LocalSKU.ToLower() == SKU.ToLower() && m.PONumber != 0); if (rcv != null) { if (MessageBox.Show(@"You have received the full quantity ordered for this item." + Environment.NewLine + "Do you want to receive more?", "Scan IN&OUT", MessageBoxButtons.YesNo) == DialogResult.Yes) { rcv.QtyReceived += Quantity; LastItem = rcv.PONumber.ToString() + "," + rcv.LocalSKU + "," + Quantity.ToString(); #region LOG POLogObj l = new POLogObj(); l.Cost = rcv.Cost; l.IsUpdated = false; l.ItemName = rcv.ItemName; l.ItemNumber = rcv.ItemNumber; l.Location = rcv.Location; l.OrderNumber = rcv.OrderNumber; l.PONumber = rcv.PONumber; l.Price = rcv.Price; l.Price2 = rcv.Price2; l.Price3 = rcv.Price3; l.QtyOrdered = rcv.QtyReceived; l.QtyReceived = rcv.QtyReceived; l.QtyRemaining = 0; l.SKU = rcv.LocalSKU; l.SupplierID = Convert.ToInt32(cbSupplier.SelectedValue); l.SupplierName = cbSupplier.Text; l.SupplierSKU = rcv.SupplierSKU; if (!RestoreMode) { POLog.Insert(l); } pologlist.Add(l); #endregion } } else { string res = ""; InventoryRecord InvR = Inv.GetData(SKU, SKU, ref res); if (InvR == null || string.IsNullOrWhiteSpace(InvR.SKU)) { MessageBox.Show("Item Not Found!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } rcv = ReceivingList.FirstOrDefault(m => m.LocalSKU.ToLower() == SKU.ToLower() && m.PONumber == 0); if (MessageBox.Show(@"This item is not listed on the selected PO(s)." + Environment.NewLine + "Do you want to receive it?", "Scan IN&OUT", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (rcv == null) { rcv = new ReceiveObj(); rcv.Cost = 0; rcv.ItemName = InvR.ProductName; rcv.ItemNumber = ReceivingList.FindAll(m => m.PONumber == 0).Count + 1; rcv.LocalSKU = InvR.SKU; rcv.Location = InvR.Location; rcv.OrderNumber = 0; rcv.PONumber = 0; rcv.Price = InvR.Price; rcv.Price2 = InvR.Price2; rcv.Price3 = InvR.Price3; rcv.QtyReceived = Quantity; rcv.SupplierSKU = InvR.SupplierSKU; rbs.Add(rcv); LastItem = rcv.PONumber.ToString() + "," + rcv.LocalSKU + "," + Quantity.ToString(); FileInfo fi = new FileInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "//SIO//BI//" + InvR.Barcode + ".jpg"); if (!fi.Exists) { Image i = Code128Rendering.MakeBarcodeImage(InvR.Barcode, 1, true); i.Save(fi.FullName); } } else { rcv.QtyReceived += Quantity; LastItem = rcv.PONumber.ToString() + "," + rcv.LocalSKU + "," + Quantity.ToString(); } #region LOG POLogObj l = new POLogObj(); l.Cost = rcv.Cost; l.IsUpdated = false; l.ItemName = rcv.ItemName; l.ItemNumber = rcv.ItemNumber; l.Location = rcv.Location; l.OrderNumber = rcv.OrderNumber; l.PONumber = rcv.PONumber; l.Price = rcv.Price; l.Price2 = rcv.Price2; l.Price3 = rcv.Price3; l.QtyOrdered = 0; l.QtyReceived = rcv.QtyReceived; l.QtyRemaining = 0; l.SKU = rcv.LocalSKU; l.SupplierID = Convert.ToInt32(cbSupplier.SelectedValue); l.SupplierName = cbSupplier.Text; l.SupplierSKU = rcv.SupplierSKU; if (!RestoreMode) { POLog.Insert(l); } pologlist.Add(l); #endregion } } dgvReceiving.Refresh(); } purchaseorderdetailslist.RemoveAll(m => m.QuantityRemaining == 0); bs.ResetBindings(false); dgvEcpected.Refresh(); }