private void btnNav_Click(object sender, EventArgs e) { if (pSchedule.Visible && !pVehicle.Visible && !pOverview.Visible) { if (dtStart.Value.Date > dtEnd.Value.Date) { MessageBox.Show("End Date can't be lower than Start Date"); } else { var param = new Dictionary <string, object>(); param.Add("@start", dtStart.Value); param.Add("@end", dtEnd.Value); //grd.DataSource = Connection.GetTMSConnection.ExecuteStoredProcedure("SP_AvailableVehicle", param); //grd.ClearSelection(); lb.DataSource = Connection.GetTMSConnection.ExecuteStoredProcedure("SP_AvailableVehicle", param); lb.DisplayMember = "Vehicle"; lb.ValueMember = "Vehicle"; pSchedule.Visible = false; pVehicle.Visible = true; btnBack.Visible = true; } } else if (!pSchedule.Visible && pVehicle.Visible && !pOverview.Visible) // Available Vehicle { //if (grd.SelectedRows.Count == 0) //{ // MessageBox.Show("Select a vehicle."); //} lblExpStart.Text = dtStart.Value.Date.ToShortDateString(); lblExpEnd.Text = dtEnd.Value.Date.ToShortDateString(); lblIncharge.Text = txtIncharge.Text; lblVehicle.Text = lb.SelectedValue.ToString(); pVehicle.Visible = false; pOverview.Visible = true; btnNav.Text = "Save"; } else if (!pSchedule.Visible && !pVehicle.Visible && pOverview.Visible) { var unit = new TripUnit(); var manager = new TripManager(); unit.TripId = DataSupport.GetNextMenuCodeInt("TR"); unit.ExpectedStart = lblExpStart.Text; unit.ExpectedEnd = lblExpEnd.Text; unit.Incharge = lblIncharge.Text; unit.VehicleId = lblVehicle.Text; unit.RouteId = ""; unit.ActualStart = ""; unit.ActualEnd = ""; unit.Cost = ""; unit.LastUpdated = ""; manager.InsertTrip(unit); manager.RunScript(); MessageBox.Show("Successfully saved!"); DialogResult = DialogResult.OK; } }
private void btnAdd_Click(object sender, EventArgs e) { string message = ""; if (FAQ.IsDatesBlocked(txtVehicle.Text, DateTime.Parse(txtStart.Value.ToShortDateString()), DateTime.Parse(txtEnd.Value.ToShortDateString()), ref message)) { MessageBox.Show(message); return; } if (txtStart.Value > txtEnd.Value) { MessageBox.Show("End Date can't be lower than Start Date"); return; } String trip_id = DataSupport.GetNextMenuCodeInt("TR"); Dictionary <String, Object> dict = new Dictionary <string, object>(); dict.Add("trip_id", trip_id); dict.Add("vehicle", txtVehicle.Text); dict.Add("in_charge", txtInCharge.Text); dict.Add("expected_start", txtStart.Value.ToShortDateString()); dict.Add("expected_end", txtEnd.Value.ToShortDateString()); String sql = DataSupport.GetInsert("Trips", dict); DataSupport.RunNonQuery(sql, IsolationLevel.ReadCommitted); MessageBox.Show("Success"); DialogResult = DialogResult.OK; }
private void btnLoad_Click(object sender, EventArgs e) { var header = JSONSupport.DeserializeObject(textBox1.Text); var details = JSONSupport.DeserializeToDataTable(header["details"].ToString()); details.Columns.Add("release_order"); header.Remove("details"); String order_id = DataSupport.GetNextMenuCodeInt("ORD"); header.Add("order_id", order_id); foreach (DataRow row in details.Rows) { row["release_order"] = order_id; } String sql = DataSupport.GetInsert("ReleaseOrders", header); foreach (DataRow row in details.Rows) { var detail = row.AsDictionary <String, Object>(); sql += DataSupport.GetInsert("ReleaseOrderDetails", detail); } DataSupport.RunNonQuery(sql, IsolationLevel.ReadCommitted); MessageBox.Show("Success"); }
private void save() { try { String DRID = DataSupport.GetNextMenuCodeInt("DR"); StringBuilder sql = new StringBuilder(); Dictionary <String, Object> header = new Dictionary <string, object>(); header.Add("dr_Id", DRID); header.Add("drNo", txtDRNo.Text); header.Add("drDate", txtDRDate.Text); header.Add("poNo", txtREf.Text); header.Add("terms", txtTerms.Text); header.Add("typeOfStock", txtTypeOfStocks.Text); header.Add("custCode", txtCustCode.Text); header.Add("custName", txtCustName.Text); header.Add("address", txtaddress.Text); sql.Append(DataSupport.GetInsert("Global_drTrans", header)); foreach (DataGridViewRow row in dataGridView1.Rows) { if (dataGridView1.Rows.IndexOf(row) == dataGridView1.Rows.Count - 1) { break; } Dictionary <String, Object> detail = new Dictionary <String, Object>(); detail.Add("dr_Id", DRID); detail.Add("product_code", row.Cells[colCode.Name].Value.ToString()); detail.Add("description", row.Cells[coldescription.Name].Value.ToString()); if (string.IsNullOrEmpty(row.Cells[colbatch.Name].Value as string)) { detail.Add("batchno", ""); } else { detail.Add("batchno", row.Cells[colbatch.Name].Value.ToString()); } if (row.Cells[colExdate.Name].Value == null) { detail.Add("expiryDate", DBNull.Value); } else { detail.Add("expiryDate", row.Cells[colExdate.Name].Value.ToString()); } detail.Add("packSize", row.Cells[colPack.Name].Value.ToString()); detail.Add("pcs", row.Cells[colpcs.Name].Value.ToString()); detail.Add("cases", row.Cells[colcases.Name].Value.ToString()); sql.Append(DataSupport.GetInsert("Global_drTransDetails", detail)); } DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted); MessageBox.Show("Saved"); DialogResult = DialogResult.OK; } catch { } }
private void SaveData() { String id = DataSupport.GetNextMenuCodeInt("PL"); DateTime now = DateTime.Now; // Save Transaction String sql = ""; foreach (DataGridViewRow row in parent.header_grid.SelectedRows) { sql += DataSupport.GetInsert("ForDisposals", Utils.ToDict( "trans_id", id , "product", row.Cells["Product"].Value.ToString() , "qty", row.Cells["Qty"].Value.ToString() , "uom", row.Cells["Uom"].Value.ToString() , "lot_no", row.Cells["Lot No"].Value.ToString() , "expiry", row.Cells["Expiry"].Value.ToString() , "reason", row.Cells["Days To Expiry"].Value.ToString() )); // Update Transaction Ledger { DataTable insDT = LedgerSupport.GetLocationLedgerDT(); insDT.Rows.Add("STAGING-OUT", now, "IN", "CANCEL_ORDER", id); sql += LedgerSupport.UpdateLocationLedger(insDT); DataTable outsDT = LedgerSupport.GetLocationLedgerDT(); outsDT.Rows.Add(row.Cells["Location"].Value.ToString(), now, "OUT", "CANCEL_ORDER", id); sql += LedgerSupport.UpdateLocationLedger(outsDT); } // Update Location Products Ledger { DataTable insDT = LedgerSupport.GetLocationProductsLedgerDT(); insDT.Rows.Add("STAGING-OUT", row.Cells["Product"].Value, row.Cells["Qty"].Value, row.Cells["Uom"].Value, row.Cells["Lot No"].Value, row.Cells["Expiry"].Value); sql += LedgerSupport.UpdateLocationProductsLedger(insDT); DataTable outsDT = LedgerSupport.GetLocationProductsLedgerDT(); outsDT.Rows.Add(row.Cells["Location"].Value.ToString(), row.Cells["Product"].Value, int.Parse(row.Cells["Qty"].Value.ToString()) * -1, row.Cells["Uom"].Value, row.Cells["Lot No"].Value, row.Cells["Expiry"].Value, int.Parse(row.Cells["qty"].Value.ToString()) * -1, int.Parse(row.Cells["Qty"].Value.ToString()) * -1); sql += LedgerSupport.UpdateLocationProductsLedger(outsDT); } } DataSupport.RunNonQuery(sql, IsolationLevel.ReadCommitted); MessageBox.Show("Success"); webBrowser1.DocumentText = webBrowser1.DocumentText.Replace("(issued on save)", id); btnPrintPreview.Text = "Print"; btnCancel.Visible = false; }
private void btnDeclare_Click(object sender, EventArgs e) { String outgoing_id = DataSupport.GetNextMenuCodeInt("DR"); StringBuilder sql = new StringBuilder(); Dictionary <String, Object> header = new Dictionary <string, object>(); header.Add("out_shipment_id", outgoing_id); header.Add("warehouse", txtWarehouse.Text); header.Add("datetime", DateTime.Now); header.Add("document_reference", txtReference.Text); header.Add("client", txtClient.Text); header.Add("authorized_tms", txtTransportProvider.Text); header.Add("customer_id", txtCustomer.Text); header.Add("remarks", txtRemarks.Text); header.Add("outgoing_type", txOutgoingType.Text); header.Add("document_reference_date", txtDocDate.Text); header.Add("status", "FOR STOCK CHECKING"); sql.Append(DataSupport.GetInsert("OutgoingShipmentRequests", header)); foreach (DataGridViewRow row in headerGrid.Rows) { if (headerGrid.Rows.IndexOf(row) == headerGrid.Rows.Count - 1) { break; } Dictionary <String, Object> detail = new Dictionary <string, object>(); detail.Add("out_shipment", outgoing_id); detail.Add("product", row.Cells[product.Name].Value.ToString()); detail.Add("uom", row.Cells[uom.Name].Value.ToString()); detail.Add("expected_qty", row.Cells[qty.Name].Value.ToString()); sql.Append(DataSupport.GetInsert("OutgoingShipmentRequestDetails", detail)); } if (string.IsNullOrEmpty(txtWarehouse.Text) || string.IsNullOrEmpty(txtReference.Text)) { MessageBox.Show("Please input all fields"); } else { if (FAQ.OutDocumentReferenceExist(txtReference.Text)) { MessageBox.Show("Exist Document Reference"); } else { DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted); MessageBox.Show("Success"); this.Close(); } } }
private void saved() { MessageBox.Show(WhsID.ToString()); String transID = DataSupport.GetNextMenuCodeInt("STR-OUT"); StringBuilder sql = new StringBuilder(); Dictionary <String, Object> header = new Dictionary <string, object>(); header.Add("shipment_id", transID); header.Add("warehouse", WhsID); header.Add("document_reference", txtRefNR.Text); header.Add("document_reference_date", txtDateRef.Text); //header.Add("client", "Null"); //header.Add("authorized_shipper", "Null"); header.Add("remarks", txtReason.Text); header.Add("incoming_type", "STOCK TRANSFER"); header.Add("typeStocks", txtTypeStocks.Text); header.Add("received", txtReceived.Text); header.Add("received_on", txtDateRe.Text); header.Add("status", "FOR RECEIVING"); header.Add("custName", cbxReceived.Text); header.Add("issued", txtIssued.Text); header.Add("dateIssued", txtDateI.Text); header.Add("pickUp", txtPickUp.Text); header.Add("datePick", txtDateP.Text); sql.Append(DataSupport.GetInsert("IncomingShipmentRequests", header)); foreach (DataGridViewRow row in dataGridView1.Rows) { if (dataGridView1.Rows.IndexOf(row) == dataGridView1.Rows.Count - 1) { break; } Dictionary <String, Object> detail = new Dictionary <string, object>(); detail.Add("shipment", transID); detail.Add("product", row.Cells[colCode.Name].Value.ToString()); detail.Add("uom", row.Cells[colUnit.Name].Value.ToString()); detail.Add("expected_qty", row.Cells[colQuantity.Name].Value.ToString()); detail.Add("lot_no", "Null"); detail.Add("expiry", "12-12-2000"); sql.Append(DataSupport.GetInsert("IncomingShipmentRequestDetails", detail)); } DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted); MessageBox.Show("Success"); DialogResult = DialogResult.OK; }
private void saved() { try { String siId = DataSupport.GetNextMenuCodeInt("INVOICE"); StringBuilder sql = new StringBuilder(); Dictionary <String, Object> header = new Dictionary <string, object>(); header.Add("outgoing_Id", siId); header.Add("siNo", txtSI.Text); header.Add("sidate", txtSiDate.Text); header.Add("poNo", txtPO.Text); header.Add("typeOfStock", cbxTypeOfSTocks.Text); header.Add("custCode", cbxCustCode.Text); header.Add("custName", txtCustName.Text); header.Add("terms", txtTerms.Text); header.Add("priceType", cbxPriceType.Text); header.Add("totalAmount", Details[2]); header.Add("discount", Details[3]); header.Add("vat", Details[1]); header.Add("AmountDue", Details[0]); sql.Append(DataSupport.GetInsert("Global_ProductTrans", header)); foreach (DataGridViewRow row in dataGridView1.Rows) { if (dataGridView1.Rows.IndexOf(row) == dataGridView1.Rows.Count - 1) { break; } Dictionary <String, Object> detail = new Dictionary <String, Object>(); detail.Add("outgoing_Id", siId); detail.Add("product_code", row.Cells[colCode.Name].Value.ToString()); detail.Add("description", row.Cells[colDescription.Name].Value.ToString()); detail.Add("qty", row.Cells[colQty.Name].Value.ToString()); detail.Add("uom", row.Cells[colUnit.Name].Value.ToString()); detail.Add("price", row.Cells[colPrice.Name].Value.ToString()); detail.Add("dics", row.Cells[colDisc.Name].Value.ToString()); detail.Add("amount", row.Cells[colAmount.Name].Value.ToString()); sql.Append(DataSupport.GetInsert("Global_ProductTransDetails", detail)); } DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted); MessageBox.Show("Saved"); DialogResult = DialogResult.OK; } catch { } }
private void SaveData() { String id = DataSupport.GetNextMenuCodeInt("PL"); // Save Transaction String sql = DataSupport.GetInsert("Picklists", Utils.ToDict( "picklist_id", id , "status", "TO BE PICKED" )); foreach (DataGridViewRow row in parent.picklist_grid.Rows) { sql += DataSupport.GetInsert("PicklistDetails", Utils.ToDict( "picklist", id , "line", parent.picklist_grid.Rows.IndexOf(row) + 1 , "order_id", row.Cells["order_id"].Value.ToString() , "product", row.Cells["product"].Value.ToString() , "qty", row.Cells["qty"].Value.ToString() , "uom", row.Cells["uom"].Value.ToString() , "lot_no", row.Cells["lot_no"].Value.ToString() , "expiry", row.Cells["expiry"].Value.ToString() , "location", row.Cells["location"].Value.ToString() )); } foreach (DataGridViewRow row in parent.picklist_grid.Rows) { sql += " UPDATE LocationProductsLedger SET to_be_picked_qty = to_be_picked_qty + " + row.Cells["qty"].Value.ToString() + " WHERE location='" + row.Cells["location"].Value.ToString() + "' AND product='" + row.Cells["product"].Value.ToString() + "' AND uom='" + row.Cells["uom"].Value.ToString() + "' AND lot_no='" + row.Cells["lot_no"].Value.ToString() + "' AND expiry='" + row.Cells["expiry"].Value.ToString() + "'; "; } foreach (DataGridViewRow row in parent.picklist_grid.Rows) { sql += " UPDATE ReleaseOrders SET status='FOR PICKING' WHERE order_id='" + row.Cells["order_id"].Value.ToString() + "'; "; } DataSupport.RunNonQuery(sql, IsolationLevel.ReadCommitted); MessageBox.Show("Success"); webBrowser1.DocumentText = webBrowser1.DocumentText.Replace("(issued on save)", id); btnPrintPreview.Text = "Print"; btnCancel.Visible = false; }
private void SaveData() { String id = DataSupport.GetNextMenuCodeInt("PC"); // Save Transaction String sql = DataSupport.GetInsert("PhysicalCounts", Utils.ToDict( "phcount_id", id , "created_on", DateTime.Now , "cycle", parent.txtCycle.Value.ToString() , "cycle_year", parent.txtYear.Text , "counted_by", parent.txtCountedBy.Text )); foreach (String location in locations) { sql += DataSupport.GetInsert("PhysicalCountDetails", Utils.ToDict( "phcount", id , "location", location.Replace("'", "") )); } foreach (DataRow row in dt.Rows) { sql += DataSupport.GetInsert("PhysicalCountDetailItems", Utils.ToDict( "phcount", id , "location", row["Location"] , "product", row["Product"] , "uom", row["Uom"] , "lot_no", row["Lot No"] , "expiry", row["Expiry"] , "expected_qty", row["qty"] , "line", dt.Rows.IndexOf(row) + 1 )); } DataSupport.RunNonQuery(sql, IsolationLevel.ReadCommitted); MessageBox.Show("Success"); webBrowser1.DocumentText = webBrowser1.DocumentText.Replace("(issued on save)", id); btnPrintPreview.Text = "Print"; btnCancel.Visible = false; }
private void SaveData() { String id = DataSupport.GetNextMenuCodeInt("CBPL"); // Save Transaction String sql = DataSupport.GetInsert("CaseBreak", Utils.ToDict( "casebreak_id", id , "approved_on", parent.txtReceivedOn.Value.ToShortDateString() , "encoded_on", DateTime.Now , "approved_by", parent.cboReceivedBy.SelectedValue , "status", "TO BE PICKED" )); foreach (DataGridViewRow row in parent.picklist_grid.Rows) { sql += DataSupport.GetInsert("CaseBreakDetails", Utils.ToDict( "casebreak", id , "line", parent.picklist_grid.Rows.IndexOf(row) + 1 , "product", row.Cells["product"].Value.ToString() , "qty", row.Cells["qty"].Value.ToString() , "uom", row.Cells["uom"].Value.ToString() , "lot_no", row.Cells["lot_no"].Value.ToString() , "expiry", row.Cells["expiry"].Value.ToString() , "location", row.Cells["location"].Value.ToString() , "breakto_uom", row.Cells["breakto_uom"].Value.ToString() )); } foreach (DataGridViewRow row in parent.picklist_grid.Rows) { sql += " UPDATE LocationProductsLedger SET [reserved_qty] = [reserved_qty] + " + row.Cells["qty"].Value.ToString() + ", to_be_picked_qty = to_be_picked_qty + " + row.Cells["qty"].Value.ToString() + " WHERE location='" + row.Cells["location"].Value.ToString() + "' AND product='" + row.Cells["product"].Value.ToString() + "' AND uom='" + row.Cells["uom"].Value.ToString() + "' AND lot_no='" + row.Cells["lot_no"].Value.ToString() + "' AND expiry='" + row.Cells["expiry"].Value.ToString() + "'; "; } DataSupport.RunNonQuery(sql, IsolationLevel.ReadCommitted); MessageBox.Show("Success"); webBrowser1.DocumentText = webBrowser1.DocumentText.Replace("(issued on save)", id); btnPrintPreview.Text = "Print"; btnCancel.Visible = false; }
private void SaveData() { DateTime now = DateTime.Now; String putaway_id = DataSupport.GetNextMenuCodeInt("PA"); // Save Transaction String sql = DataSupport.GetInsert("Putaways", Utils.ToDict( "putaway_id", putaway_id , "container", "CANCELLED_PALLET" , "encoded_on", now , "completed", now )); foreach (DataGridViewRow row in parent.items_grid.Rows) { sql += DataSupport.GetInsert("PutawayDetails", Utils.ToDict( "putaway", putaway_id , "product", row.Cells["Product"].Value.ToString() , "expected_qty", row.Cells["Qty"].Value.ToString() , "uom", row.Cells["Uom"].Value.ToString() , "lot_no", row.Cells["Lot No"].Value.ToString() , "expiry", row.Cells["Expiry"].Value.ToString() , "location", row.Cells["Putaway To"].Value.ToString() , "actual_qty", row.Cells["Qty"].Value.ToString() )); } // Update Transaction Ledger { // Out with the cancelled pallet DataTable outsDT = LedgerSupport.GetLocationLedgerDT(); outsDT.Rows.Add("CANCELLED_PALLET", now, "OUT", "CANCELLED_PUTAWAY", putaway_id); sql += LedgerSupport.UpdateLocationLedger(outsDT); // In with the location DataTable insDT = LedgerSupport.GetLocationLedgerDT(); foreach (DataGridViewRow row in parent.items_grid.Rows) { insDT.Rows.Add(row.Cells["Putaway To"].Value.ToString(), now, "IN", "CANCELLED_PUTAWAY", putaway_id); } sql += LedgerSupport.UpdateLocationLedger(insDT); } // Update Location Products Ledger { // Out with the cancelled pallet DataTable outsDT = LedgerSupport.GetLocationProductsLedgerDT(); foreach (DataGridViewRow row in parent.items_grid.Rows) { outsDT.Rows.Add("CANCELLED_PALLET", row.Cells["Product"].Value, int.Parse(row.Cells["Qty"].Value.ToString()) * -1, row.Cells["Uom"].Value, row.Cells["Lot No"].Value, row.Cells["Expiry"].Value); } sql += LedgerSupport.UpdateLocationProductsLedger(outsDT); // In with the location DataTable insDT = LedgerSupport.GetLocationProductsLedgerDT(); foreach (DataGridViewRow row in parent.items_grid.Rows) { insDT.Rows.Add(row.Cells["Putaway To"].Value.ToString(), row.Cells["Product"].Value, row.Cells["Qty"].Value, row.Cells["Uom"].Value, row.Cells["Lot No"].Value, row.Cells["Expiry"].Value); } sql += LedgerSupport.UpdateLocationProductsLedger(insDT); } DataSupport.RunNonQuery(sql, IsolationLevel.ReadCommitted); MessageBox.Show("Success"); webBrowser1.DocumentText = webBrowser1.DocumentText.Replace("(issued on save)", putaway_id); btnPrintPreview.Text = "Print"; btnCancel.Visible = false; }
private void saved() { String incoming_id = ""; StringBuilder sql = new StringBuilder(); if (txtIncomingType.Text.ToLower().Trim() == "replenishment") { incoming_id = DataSupport.GetNextMenuCodeInt("INCOMING"); } else if (txtIncomingType.Text.ToLower().Trim() == "return from trade") { incoming_id = DataSupport.GetNextMenuCodeInt("RETURNS"); } else if (txtIncomingType.Text.ToLower().Trim() == "return from delivery") { incoming_id = DataSupport.GetNextMenuCodeInt("RETURNS"); } else if (txtIncomingType.Text.ToLower().Trim() == "stock transfer") { incoming_id = DataSupport.GetNextMenuCodeInt("STR-OUT"); } Dictionary <String, Object> header = new Dictionary <string, object>(); header.Add("shipment_id", incoming_id); header.Add("typeStocks", txtTypeStocks.Text); header.Add("wrrNo", txtwrrNo.Text); header.Add("warehouse", txtWarehouse.Text); header.Add("authorized_shipper", txtShipper.Text); header.Add("codeS", txtCodeS.Text); header.Add("address", txtAddressS.Text); header.Add("datetime", DateTime.Now); header.Add("document_reference", txtReference.Text); header.Add("document_reference_date", txtDocDate.Text); header.Add("incoming_type", txtIncomingType.Text); header.Add("client", "Comark"); header.Add("received", txtReceived.Text); header.Add("shippedVia", txtShipped.Text); header.Add("status", "FOR RECEIVING"); sql.Append(DataSupport.GetInsert("IncomingShipmentRequests", header)); foreach (DataGridViewRow row in headerGrid.Rows) { if (headerGrid.Rows.IndexOf(row) == headerGrid.Rows.Count - 1) { break; } Dictionary <String, Object> detail = new Dictionary <string, object>(); detail.Add("shipment", incoming_id); detail.Add("product", row.Cells[colCode.Name].Value.ToString()); detail.Add("uom", row.Cells[uom.Name].Value.ToString()); detail.Add("lot_no", row.Cells[lot_no.Name].Value.ToString()); detail.Add("expiry", row.Cells[expiry.Name].Value.ToString()); detail.Add("expected_qty", row.Cells[qty.Name].Value.ToString()); sql.Append(DataSupport.GetInsert("IncomingShipmentRequestDetails", detail)); } if (FAQ.INWrrNoExist(txtwrrNo.Text)) { MessageBox.Show("WRR NO Exist"); } else { DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted); MessageBox.Show("Success"); this.DialogResult = DialogResult.OK; } }
private void SaveData() { String putaway_id = DataSupport.GetNextMenuCodeInt("PA"); DateTime now = DateTime.Now; // Save Transaction String sql = DataSupport.GetInsert("Putaways", Utils.ToDict( "putaway_id", putaway_id , "container", parent.cboContainer.SelectedValue.ToStringNull() , "encoded_on", now )); foreach (DataGridViewRow row in parent.headerGrid.Rows) { sql += DataSupport.GetInsert("PutawayDetails", Utils.ToDict( "putaway", putaway_id , "product", row.Cells["product"].Value.ToString() , "expected_qty", row.Cells["Quantity"].Value.ToString() , "uom", row.Cells["uom"].Value.ToString() , "lot_no", row.Cells["lot"].Value.ToString() , "expiry", row.Cells["expiry"].Value.ToString() , "location", row.Cells["location"].Value.ToString() )); } // Update Transaction Ledger { // Out with the staging in DataTable outsDT = LedgerSupport.GetLocationLedgerDT(); outsDT.Rows.Add("STAGING-IN", now, "OUT", "PUTAWAY", putaway_id); sql += LedgerSupport.UpdateLocationLedger(outsDT); // In with the container DataTable insDT = LedgerSupport.GetLocationLedgerDT(); foreach (DataGridViewRow row in parent.headerGrid.Rows) { insDT.Rows.Add(parent.cboContainer.SelectedValue.ToStringNull(), now, "IN", "PUTAWAY", putaway_id); } sql += LedgerSupport.UpdateLocationLedger(insDT); } // Update Location Products Ledger { // Out with the staging in DataTable outsDT = LedgerSupport.GetLocationProductsLedgerDT(); foreach (DataGridViewRow row in parent.headerGrid.Rows) { outsDT.Rows.Add("STAGING-IN", row.Cells["product"].Value, int.Parse(row.Cells["Quantity"].Value.ToString()) * -1, row.Cells["uom"].Value, row.Cells["lot"].Value, row.Cells["expiry"].Value); } sql += LedgerSupport.UpdateLocationProductsLedger(outsDT); // In with the container DataTable insDT = LedgerSupport.GetLocationProductsLedgerDT(); foreach (DataGridViewRow row in parent.headerGrid.Rows) { insDT.Rows.Add(parent.cboContainer.SelectedValue.ToStringNull(), row.Cells["product"].Value, row.Cells["Quantity"].Value, row.Cells["uom"].Value, row.Cells["lot"].Value, row.Cells["expiry"].Value); } sql += LedgerSupport.UpdateLocationProductsLedger(insDT); } try { DataSupport.RunNonQuery(sql, IsolationLevel.ReadCommitted); MessageBox.Show("Success"); webBrowser1.DocumentText = webBrowser1.DocumentText.Replace("(issued on save)", putaway_id); btnPrintPreview.Text = "Print"; btnCancel.Visible = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void SaveData() { String now = DateTime.Now.ToString(); String sql = ""; String bs_id = DataSupport.GetNextMenuCodeInt("BS"); // Save Transaction sql += DataSupport.GetInsert("BadStockDeclarations", Utils.ToDict( "declaration_id", bs_id , "declared_by", parent.txtDeclaredBy.Text , "declared_on", now , "status", "OK" )); foreach (DataGridViewRow row in parent.header_grid.Rows) { sql += DataSupport.GetInsert("BadStockDeclarationDetails", Utils.ToDict( "declaration", bs_id , "line", parent.header_grid.Rows.IndexOf(row) + 1 , "product", row.Cells["product"].Value.ToString() , "uom", row.Cells["uom"].Value.ToString() , "lot_no", row.Cells["lot_no"].Value.ToString() , "expiry", row.Cells["expiry"].Value.ToString() , "location", row.Cells["location"].Value.ToString() , "qty", row.Cells["qty"].Value.ToString() , "reason", row.Cells["reason"].Value.ToString() , "bad_stock_storage", row.Cells["bad_stock_storage"].Value.ToString() )); } foreach (DataGridViewRow row in parent.header_grid.Rows) { // Update Transaction Ledger { // Out with the good storage location DataTable outsDT = LedgerSupport.GetLocationLedgerDT(); outsDT.Rows.Add(row.Cells["location"].Value.ToString(), now, "OUT", "BAD STOCK DEC", bs_id); sql += LedgerSupport.UpdateLocationLedger(outsDT); // In with the bad storage location DataTable insDT = LedgerSupport.GetLocationLedgerDT(); insDT.Rows.Add(row.Cells["bad_stock_storage"].Value.ToString(), now, "IN", "BAD STOCK DEC", bs_id); sql += LedgerSupport.UpdateLocationLedger(insDT); } // Update Location Products Ledger { // Out with the good storage location DataTable outsDT = LedgerSupport.GetLocationProductsLedgerDT(); outsDT.Rows.Add(row.Cells["location"].Value.ToString(), row.Cells["product"].Value, int.Parse(row.Cells["qty"].Value.ToString()) * -1, row.Cells["uom"].Value, row.Cells["lot_no"].Value, row.Cells["expiry"].Value); sql += LedgerSupport.UpdateLocationProductsLedger(outsDT); // In with the bad storage location DataTable insDT = LedgerSupport.GetLocationProductsLedgerDT(); insDT.Rows.Add(row.Cells["bad_stock_storage"].Value.ToString(), row.Cells["product"].Value, row.Cells["qty"].Value, row.Cells["uom"].Value, row.Cells["lot_no"].Value, row.Cells["expiry"].Value); sql += LedgerSupport.UpdateLocationProductsLedger(insDT); } // Update For Resolution sql += DataSupport.GetInsert("ForResolutions", Utils.ToDict( "trans_source", "BAD_STOCK_DEC" , "trans_id", bs_id , "detected_on", now , "product", row.Cells["product"].Value , "uom", row.Cells["uom"].Value , "lot_no", row.Cells["lot_no"].Value , "expiry", row.Cells["expiry"].Value , "location", row.Cells["bad_stock_storage"].Value.ToString() , "variance_type", "BAD STOCK" , "variance_qty", row.Cells["qty"].Value , "status", "FOR RESOLUTION" , "line", parent.header_grid.Rows.IndexOf(row) + 1 )); } DataSupport.RunNonQuery(sql, IsolationLevel.ReadCommitted); MessageBox.Show("Success"); webBrowser1.DocumentText = webBrowser1.DocumentText.Replace("(issued on save)", bs_id); btnPrintPreview.Text = "Print"; btnCancel.Visible = false; }
private void saved() { String returnID = DataSupport.GetNextMenuCodeInt("RETURNS"); StringBuilder sql = new StringBuilder(); Dictionary <String, Object> header = new Dictionary <string, object>(); header.Add("shipment_id", returnID); header.Add("custCode", txtCustCode.Text); header.Add("custName", lblCustname.Text); header.Add("codeS", cbxSalesman.Text); header.Add("document_reference", txtInvoiceRef.Text); header.Add("document_reference_date", txtInvoiceDate.Text); header.Add("warehouse", cbxwarehouse.Text); header.Add("incoming_type", "RETURN STOCKS"); header.Add("typeStocks", cbxTypeS.Text); header.Add("remarks", txtRemarks.Text); header.Add("received", txtReceived.Text); header.Add("received_on", txtDateR.Text); header.Add("transCode", txtTransCode.Text); header.Add("wrrNo", txtRgsNo.Text); header.Add("status", "FOR RECEIVING"); sql.Append(DataSupport.GetInsert("IncomingShipmentRequests", header)); foreach (DataGridViewRow row in dataGridView1.Rows) { if (dataGridView1.Rows.IndexOf(row) == dataGridView1.Rows.Count - 1) { break; } Dictionary <String, Object> detail = new Dictionary <string, object>(); detail.Add("shipment", returnID); detail.Add("product", row.Cells[colCode.Name].Value.ToString()); detail.Add("uom", row.Cells[colUnit.Name].Value.ToString()); if (string.IsNullOrEmpty(row.Cells[colQuantity.Name].Value as string)) { detail.Add("received_qty", "0"); } else { detail.Add("received_qty", row.Cells[colQuantity.Name].Value.ToString()); } if (String.IsNullOrEmpty(row.Cells[colPrice.Name].Value.ToString()) || row.Cells[colPrice.Name].Value.ToString() == null) { detail.Add("price", "0.00"); } else { detail.Add("price", row.Cells[colPrice.Name].Value.ToString()); } if (String.IsNullOrEmpty(row.Cells[colTotal.Name].Value.ToString()) || row.Cells[colTotal.Name].Value.ToString() == null) { detail.Add("total", "0.00"); } else { detail.Add("total", row.Cells[colTotal.Name].Value.ToString()); } detail.Add("lot_no", "Null"); detail.Add("expiry", "12-12-2000"); sql.Append(DataSupport.GetInsert("IncomingShipmentRequestDetails", detail)); } DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted); MessageBox.Show("Success"); DialogResult = DialogResult.OK; }
private void saved() { String DrId = DataSupport.GetNextMenuCodeInt("DR"); StringBuilder sql = new StringBuilder(); Dictionary <String, Object> header = new Dictionary <string, object>(); header.Add("out_shipment_id", DrId); header.Add("warehouse", cbxWarehouse.Text); header.Add("typeStocks", txtTypeStock.Text); header.Add("datetime", DateTime.Now); header.Add("outgoing_type", "Delivery"); header.Add("docNo", txtDrno.Text); header.Add("document_reference", txtRefno.Text); header.Add("document_reference_date", txtDateS.Text); header.Add("authorized_tms", txtTransportProvider.Text); header.Add("client", "COMARK"); header.Add("terms", ""); header.Add("poNo", ""); header.Add("sr", ""); header.Add("terrCode", ""); header.Add("customer_id", txtCodeD.Text); header.Add("customer_name", cbxCustName.Text); header.Add("contactNo", ""); header.Add("customer_invoice_address", txtAddressD.Text); header.Add("disc1", ""); header.Add("disc2", ""); header.Add("disc3", ""); header.Add("disc4", ""); header.Add("disc5", ""); header.Add("shippingInstruction", txtReason.Text); header.Add("amountD", ""); header.Add("status", "FOR STOCK CHECKING"); sql.Append(DataSupport.GetInsert("OutgoingShipmentRequests", header)); foreach (DataGridViewRow row in dataGridView1.Rows) { if (dataGridView1.Rows.IndexOf(row) == dataGridView1.Rows.Count - 1) { break; } Dictionary <String, Object> detail = new Dictionary <String, Object>(); detail.Add("out_shipment", DrId); detail.Add("product", row.Cells[colCode.Name].Value.ToString()); detail.Add("uom", row.Cells[colUnit.Name].Value.ToString()); if (string.IsNullOrEmpty(row.Cells[colQuantity.Name].Value as string)) { detail.Add("expected_qty", "0"); } else { detail.Add("expected_qty", row.Cells[colQuantity.Name].Value.ToString()); } sql.Append(DataSupport.GetInsert("OutgoingShipmentRequestDetails", detail)); } if (FAQ.InvoiceExist(txtDrno.Text)) { MessageBox.Show("DR No is Exist"); } else { DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted); MessageBox.Show("Success"); DialogResult = DialogResult.OK; } }
private void saved() { try { String siId = DataSupport.GetNextMenuCodeInt("INVOICE"); StringBuilder sql = new StringBuilder(); Dictionary <String, Object> header = new Dictionary <string, object>(); header.Add("out_shipment_id", siId); header.Add("warehouse", "CEB1"); header.Add("datetime", DateTime.Now); header.Add("outgoing_type", "SALES INVOICE"); header.Add("docNo", txtSalesInvoice.Text); header.Add("document_reference", txtSoNo.Text); header.Add("document_reference_date", txtDateS.Text); header.Add("authorized_tms", cbxWarehouse.Text); header.Add("client", "COMARK"); header.Add("terms", txtTerms.Text); header.Add("poNo", txtPoNo.Text); header.Add("sr", txtSR.Text); header.Add("terrCode", txtTerrCode.Text); header.Add("customer_id", custCode); header.Add("customer_name", txtSoldTo.Text); header.Add("customer_invoice_address", txtCustAddress.Text); header.Add("disc1", ""); header.Add("disc2", ""); header.Add("disc3", ""); header.Add("disc4", ""); header.Add("disc5", ""); header.Add("shippingInstruction", txtInstruction.Text); header.Add("amountD", amountD); header.Add("typeStocks", txtTypeStock.Text); header.Add("status", "FOR STOCK CHECKING"); sql.Append(DataSupport.GetInsert("OutgoingShipmentRequests", header)); foreach (DataGridViewRow row in dataGridView1.Rows) { if (dataGridView1.Rows.IndexOf(row) == dataGridView1.Rows.Count - 1) { break; } Dictionary <String, Object> detail = new Dictionary <String, Object>(); detail.Add("out_shipment", siId); detail.Add("product", row.Cells[colCode.Name].Value.ToString()); detail.Add("uom", row.Cells[colUnit.Name].Value.ToString()); detail.Add("expected_qty", Convert.ToInt32(row.Cells[colQuantity.Name].Value)); //if (Convert.ToInt32(row.Cells["colQuantity"].Value) == 0) //{ detail.Add("expected_qty", "0"); } //else //{ detail.Add("expected_qty", row.Cells[colQuantity.Name].Value.ToString()); } if (string.IsNullOrEmpty(row.Cells[colPrice.Name].Value.ToString())) { detail.Add("price", "0"); } else { detail.Add("price", row.Cells[colPrice.Name].Value.ToString()); } sql.Append(DataSupport.GetInsert("OutgoingShipmentRequestDetails", detail)); } if (FAQ.InvoiceExist(txtSalesInvoice.Text)) { MessageBox.Show("Invoice No is Exist"); } else { DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted); MessageBox.Show("Success"); DialogResult = DialogResult.OK; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void SaveData() { String id = DataSupport.GetNextMenuCodeInt("RC"); // Save Transaction String sql = DataSupport.GetInsert("Receipts", Utils.ToDict( "receipt_id", id , "received_from", parent.txtReceivedFrom.Text , "received_on", parent.txtReceivedOn.Value.ToShortDateString() , "received_by", parent.cboReceivedBy.Text , "encoded_on", DateTime.Now )); foreach (DataGridViewRow row in parent.headerGrid.Rows) { sql += DataSupport.GetInsert("ReceiptDetails", Utils.ToDict( "receipt", id , "line", parent.headerGrid.Rows.IndexOf(row) + 1 , "product", row.Cells["product_id"].Value.ToString() , "qty", row.Cells["Quantity"].Value.ToString() , "uom", row.Cells["uom"].Value.ToString() , "lot_no", row.Cells["lot"].Value.ToString() , "expiry", row.Cells["expiry"].Value.ToString() , "remarks", row.Cells["remarks"].Value.ToString() )); } // Update Location Ledger sql += DataSupport.GetInsert("LocationLedger", Utils.ToDict( "location", "STAGING-IN" , "transaction_datetime", parent.txtReceivedOn.Value.ToShortDateString() , "transaction_type", "IN" , "transaction_name", "RECEIPT" , "transaction_id", id )); // Update Location Products Ledger foreach (DataGridViewRow row in parent.headerGrid.Rows) { if (FAQ.IsNewLine("STAGING-IN", row.Cells["product_id"].Value.ToString(), row.Cells["uom"].Value.ToString(), row.Cells["lot"].Value.ToString(), row.Cells["expiry"].Value.ToString())) { sql += "UPDATE LocationProductsLedger SET qty = qty + " + row.Cells["Quantity"].Value.ToString() + " WHERE location = '" + "STAGING-IN" + "' AND product='" + row.Cells["product_id"].Value.ToString() + "' AND uom ='" + row.Cells["uom"].Value.ToString() + "' AND lot_no = '" + row.Cells["lot"].Value.ToString() + "' AND expiry='" + row.Cells["expiry"].Value.ToString() + "'"; } else { sql += DataSupport.GetInsert("LocationProductsLedger", Utils.ToDict( "location", "STAGING-IN" , "product", row.Cells["product_id"].Value.ToString() , "qty", row.Cells["Quantity"].Value.ToString() , "uom", row.Cells["uom"].Value.ToString() , "lot_no", row.Cells["lot"].Value.ToString() , "expiry", row.Cells["expiry"].Value.ToString() )); } } DataSupport.RunNonQuery(sql, IsolationLevel.ReadCommitted); if (parent.oms_shipment_id != "") { DataSupport oms_dh = new DataSupport(String.Format(@"Initial Catalog={0};Data Source= {1};User Id = {2}; Password = {3}", Utils.DBConnection["OMS"]["DBNAME"], Utils.DBConnection["OMS"]["SERVER"], Utils.DBConnection["OMS"]["USERNAME"], Utils.DBConnection["OMS"]["PASSWORD"])); StringBuilder oms_sql = new StringBuilder("UPDATE IncomingShipmentRequests SET status = 'RECEIVED', received_on = '" + DateTime.Now + "' WHERE shipment_id = '" + parent.oms_shipment_id + "'; "); foreach (DataGridViewRow row in parent.headerGrid.Rows) { oms_sql.Append("UPDATE IncomingShipmentRequestDetails SET received_qty = '" + row.Cells["Quantity"].Value.ToString() + "' WHERE shipment = '" + parent.oms_shipment_id + "' AND product = '" + row.Cells["product_id"].Value.ToString() + "' AND uom = '" + row.Cells["uom"].Value.ToString() + "' AND lot_no='" + row.Cells["lot"].Value.ToString() + "' AND expiry='" + row.Cells["expiry"].Value.ToString() + "';"); } oms_dh.ExecuteNonQuery(oms_sql.ToString()); } MessageBox.Show("Success"); webBrowser1.DocumentText = webBrowser1.DocumentText.Replace("(issued on save)", id); btnPrintPreview.Text = "Print"; btnCancel.Visible = false; }
private void SaveData() { // Inform OMS var selected_row = parent.header_grid.SelectedRows[0]; String order_id = selected_row.Cells["Order ID"].Value.ToString(); DateTime now = DateTime.Now; String id = DataSupport.GetNextMenuCodeInt("ORC"); // Get Reason String reason = parent.dialog.txtReason.Text.EscapeString(); String sql = ""; sql += " UPDATE ReleaseOrders SET status='CANCELLED',cancel_id='" + id + "', cancel_reason ='" + reason + "', cancel_datetime='" + now + "', cancel_by='" + parent.dialog.txtCancelled.Text.EscapeString() + "' WHERE order_id= '" + order_id + "'; "; // Get Picked Items DataTable pickedDT = FAQ.GetPickedItems(FAQ.GetPicklistID(order_id), order_id); // Good Stocks // Move from Staging out to Cancelled Pallet // Update Transaction Ledger { DataTable insDT = LedgerSupport.GetLocationLedgerDT(); insDT.Rows.Add("CANCELLED_PALLET", now, "IN", "CANCEL_ORDER", order_id); sql += LedgerSupport.UpdateLocationLedger(insDT); DataTable outsDT = LedgerSupport.GetLocationLedgerDT(); outsDT.Rows.Add("STAGING-OUT", now, "OUT", "CANCEL_ORDER", order_id); sql += LedgerSupport.UpdateLocationLedger(outsDT); } // Update Location Products Ledger { DataTable insDT = LedgerSupport.GetLocationProductsLedgerDT(); foreach (DataRow row in pickedDT.Rows) { insDT.Rows.Add("CANCELLED_PALLET", row["product"], row["qty"], row["uom"], row["lot_no"], row["expiry"]); } sql += LedgerSupport.UpdateLocationProductsLedger(insDT); DataTable outsDT = LedgerSupport.GetLocationProductsLedgerDT(); foreach (DataRow row in pickedDT.Rows) { outsDT.Rows.Add("STAGING-OUT", row["product"], int.Parse(row["qty"].ToString()) * -1, row["uom"], row["lot_no"], row["expiry"], int.Parse(row["qty"].ToString()) * -1, int.Parse(row["qty"].ToString()) * -1); } sql += LedgerSupport.UpdateLocationProductsLedger(outsDT); } DataSupport.RunNonQuery(sql, IsolationLevel.ReadCommitted); MessageBox.Show("Success"); webBrowser1.DocumentText = webBrowser1.DocumentText.Replace("(issued on save)", id); btnPrintPreview.Text = "Print"; btnCancel.Visible = false; }