private void dgvItems_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } if (e.ColumnIndex == 19) { InventoryRecord ir = (dgvItems.DataSource as List <InventoryRecord>)[e.RowIndex]; frmViewOrder frm = new frmViewOrder(); frm.IsCreatePO = true; frm.OrderNumber = ir.OrderNumber; frm.StartPosition = FormStartPosition.CenterParent; frm.PONumber = 0; frm.PODate = DateTime.MinValue; frm.ShowDialog(); frm.IsCreatePO = false; } }
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; } }