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");
        }
示例#2
0
文件: Utils.cs 项目: rikscen/vglTMS
    public static string GetTripWMSSyncSQL(String trip_id)
    {
        StringBuilder result = new StringBuilder();

        result.AppendLine($"DELETE FROM ReleaseTripDetails WHERE trip = '{ trip_id }';");
        result.AppendLine($"DELETE FROM ReleaseTrips WHERE trip_id = '{ trip_id }';");

        DataSet set      = DataSupport.RunDataSet($"SELECT * FROM Trips WHERE trip_id = '{trip_id}'; SELECT * FROM TripOrders WHERE trip = '{trip_id}';");
        DataRow trip_row = set.Tables[0].Rows[0];

        Dictionary <String, Object> header = new Dictionary <string, object>();

        header.Add("trip_id", trip_id);
        header.Add("authorized_receiver", trip_row["in_charge"].ToString());
        header.Add("tms_name", DataSupport.GetTMSCode());

        result.Append(DataSupport.GetInsert("ReleaseTrips", header));

        foreach (DataRow row in set.Tables[1].Rows)
        {
            Dictionary <String, Object> detail = new Dictionary <string, object>();
            detail.Add("trip", trip_id);
            detail.Add("order_id", row["order_id"].ToString());
            detail.Add("drop_sequence", row["drop_sequence"].ToString());
            result.Append(DataSupport.GetInsert("ReleaseTripDetails", detail));
        }

        return(result.ToString());
    }
示例#3
0
        private void saved()
        {
            StringBuilder sql = new StringBuilder();
            Dictionary <String, Object> header = new Dictionary <string, object>();

            header.Add("custCode", txtcustCode.Text);
            header.Add("customer", txtcustName.Text);
            header.Add("address", txtaddress.Text);
            header.Add("businessStyle", txtbusiness.Text);
            header.Add("contactNo", txtcontact.Text);
            header.Add("postalCode", txtpostCode.Text);
            header.Add("tinNo", txttin.Text);
            header.Add("terms", txtterms.Text);
            header.Add("discount1", txtdisc1.Text);
            header.Add("discount2", txtdisc2.Text);
            header.Add("discount3", txtdisc3.Text);
            header.Add("discount4", txtdisc4.Text);
            header.Add("discount5", txtdisc5.Text);
            header.Add("zone", txtzone.Text);
            header.Add("status", 1);
            sql.Append(DataSupport.GetInsert("base_customer", header));
            DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted);
            MessageBox.Show("Saved");
            DialogResult = DialogResult.OK;
        }
示例#4
0
        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;
        }
示例#5
0
        private void btnDeclare_Click(object sender, EventArgs e)
        {
            StringBuilder sql = new StringBuilder();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (dataGridView1.Rows.IndexOf(row) == dataGridView1.Rows.Count - 1)
                {
                    break;
                }
                var primary = new List <string>();
                Dictionary <String, Object> header = new Dictionary <String, Object>();
                header.Add("productID", txtCode.Text);
                header.Add("uom", row.Cells[colUom.Name].Value.ToString());
                header.Add("priceTypeID", row.Cells[colPriceType.Name].Value.ToString());
                header.Add("unitPrice", row.Cells[colUnitPrice.Name].Value.ToString());
                header.Add("dateStamp", DateTime.Now);
                header.Add("qty", row.Cells[colQty.Name].Value.ToString());
                primary.Add("productID"); primary.Add("uom"); primary.Add("priceTypeID");
                if (FAQ.productPriceExist(Convert.ToInt32(txtCode.Text), row.Cells[colUom.Name].Value.ToString(), row.Cells[colPriceType.Name].Value.ToString()))
                {
                    sql.Append(DataSupport.GetUpdate("itemPrice", header, primary));
                }
                else
                {
                    sql.Append(DataSupport.GetInsert("itemPrice", header));
                }
            }
            DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted);
            MessageBox.Show("Success");
            DialogResult = DialogResult.OK;
        }
示例#6
0
        private void SaveData()
        {
            ResolutionsWindow grandparent  = parent.parent;
            String            trans_source = grandparent.product_row.Cells["Trans"].Value.ToString();
            String            trans_id     = grandparent.product_row.Cells["Id"].Value.ToString();
            String            line         = grandparent.product_row.Cells["Line"].Value.ToString();


            int explanation_no = int.Parse(DataSupport.RunDataSet("SELECT COUNT(*)[count] FROM Resolutions WHERE trans_source = '" + trans_source + "' AND trans_id = '" + trans_id + "' AND line='" + line + "'").Tables[0].Rows[0][0].ToString());

            // Save Transaction
            String sql = DataSupport.GetInsert("Resolutions", Utils.ToDict(
                                                   "trans_source", trans_source
                                                   , "trans_id", trans_id
                                                   , "line", line
                                                   , "explanation_no", explanation_no
                                                   , "explanation", parent.txtExplanation.Text
                                                   , "charge_to", parent.txtChargeTo.Text
                                                   , "qty_resolved", parent.txtQtyToResolve.Text
                                                   , "resolved_by", parent.txtResolvedBy.Text
                                                   , "resolved_on", DateTime.Now
                                                   ));



            DataSupport.RunNonQuery(sql, IsolationLevel.ReadCommitted);
            MessageBox.Show("Success");

            webBrowser1.DocumentText = webBrowser1.DocumentText.Replace("(issued on save)", trans_id + "-" + line + "-RS-" + explanation_no);
            btnPrintPreview.Text     = "Print";
            btnCancel.Visible        = false;
        }
示例#7
0
        private void saved()
        {
            StringBuilder sql = new StringBuilder();
            Dictionary <String, Object> header = new Dictionary <string, object>();

            header.Add("transport", txtTransport.Text);
            header.Add("customer", txtcustname.Text);
            header.Add("custCode", txtCode.Text);
            header.Add("address", txtAddress.Text);
            header.Add("contactNo", txtcontact.Text);
            header.Add("postalCode", txtpostCode.Text);
            header.Add("tinNo", txtTin.Text);
            header.Add("terms", txtTerms.Text);
            header.Add("discount1", txtDis1.Text);
            header.Add("discount2", txtDis2.Text);
            header.Add("discount3", txtDis3.Text);
            header.Add("discount4", txtDis4.Text);
            header.Add("discount5", txtDis5.Text);
            header.Add("zone", txtZone.Text);
            header.Add("dateStamp", DateTime.Now);
            header.Add("status", 1);
            sql.Append(DataSupport.GetInsert("[TransportCustomers]", header));

            DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted);
            MessageBox.Show("Success");
            DialogResult = DialogResult.OK;
        }
示例#8
0
        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
            {
            }
        }
示例#9
0
        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;
        }
示例#10
0
        private void saved()
        {
            StringBuilder sql = new StringBuilder();
            Dictionary <String, Object> header = new Dictionary <String, Object>();

            header.Add("product_code", txtproductCode.Text);
            header.Add("customer_code", txtCustCode.Text);
            header.Add("description", txtDescription.Text);
            sql.Append(DataSupport.GetInsert("base_product", header));

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (dataGridView1.Rows.IndexOf(row) == dataGridView1.Rows.Count - 1)
                {
                    break;
                }
                Dictionary <String, Object> details = new Dictionary <String, Object>();
                details.Add("product_code", txtproductCode.Text);
                if (string.IsNullOrEmpty(row.Cells[colUOM.Name].Value as string))
                {
                    details.Add("uom", "");
                }
                else
                {
                    details.Add("uom", row.Cells[colUOM.Name].Value.ToString());
                }
                if (string.IsNullOrEmpty(row.Cells[colUOM.Name].Value as string))
                {
                    details.Add("quantity", "");
                }
                else
                {
                    details.Add("quantity", row.Cells[colQty.Name].Value.ToString());
                }
                if (string.IsNullOrEmpty(row.Cells[colPriceType.Name].Value as string))
                {
                    details.Add("priceType", "");
                }
                else
                {
                    details.Add("priceType", row.Cells[colPriceType.Name].Value.ToString());
                }
                if (string.IsNullOrEmpty(row.Cells[colPriceType.Name].Value as string))
                {
                    details.Add("price", "");
                }
                else
                {
                    details.Add("price", row.Cells[colPrice.Name].Value.ToString());
                }
                sql.Append(DataSupport.GetInsert("base_price", details));
            }
            DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted);
            MessageBox.Show("Success");
            DialogResult = DialogResult.OK;
        }
示例#11
0
        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();
                }
            }
        }
示例#12
0
    public static String UpdateLocationProductsLedger(DataTable dt, Boolean is_overwrite)
    {
        String sql = "";

        if (!is_overwrite)
        {
            if (dt.Rows.Count == 0)
            {
                return("");
            }

            if (dt.Rows[0]["reserved_qty"].ToString() == "")
            {
                dt = ConsolidateDT(dt, "location", "product", "uom", "lot_no", "expiry");
            }

            foreach (DataRow row in dt.Rows)
            {
                if (FAQ.IsNewLine(row["location"].ToString(), row["product"].ToString(), row["uom"].ToString(), row["lot_no"].ToString(), row["expiry"].ToString()))
                {
                    sql += " UPDATE LocationProductsLedger SET qty = qty + " + row["qty"].ToString() + " WHERE location = '" + row["location"].ToString() + "' AND product='" + row["product"].ToString() + "' AND uom ='" + row["uom"].ToString() + "' AND lot_no = '" + row["lot_no"].ToString() + "' AND expiry='" + row["expiry"].ToString() + "'\r\n\r\n\r\n\r\n";
                }
                else
                {
                    sql += DataSupport.GetInsert("LocationProductsLedger", Utils.ToDict(
                                                     "location", row["location"].ToString()
                                                     , "product", row["product"].ToString()
                                                     , "qty", row["qty"].ToString()
                                                     , "uom", row["uom"].ToString()
                                                     , "lot_no", row["lot_no"].ToString()
                                                     , "expiry", row["expiry"].ToString()
                                                     ));
                }

                if (row["location"].ToString() == "STAGING-OUT" || row["location"].ToString() == "FOR-RESOLUTION" || row["location"].ToString() == "RELEASED" || row["location"].ToString() == "CANCELLED_PALLET")
                {
                    sql += " UPDATE LocationProductsLedger SET reserved_qty = qty WHERE location = '" + row["location"].ToString() + "' AND product='" + row["product"].ToString() + "' AND uom ='" + row["uom"].ToString() + "' AND lot_no = '" + row["lot_no"].ToString() + "' AND expiry='" + row["expiry"].ToString() + "'\r\n\r\n\r\n\r\n";
                }

                if (row["reserved_qty"].ToString() != "")
                {
                    sql += " UPDATE LocationProductsLedger SET reserved_qty = reserved_qty + " + row["reserved_qty"].ToString() + " WHERE location = '" + row["location"].ToString() + "' AND product='" + row["product"].ToString() + "' AND uom ='" + row["uom"].ToString() + "' AND lot_no = '" + row["lot_no"].ToString() + "' AND expiry='" + row["expiry"].ToString() + "'\r\n\r\n\r\n\r\n";
                }
                if (row["to_be_picked_qty"].ToString() != "")
                {
                    sql += " UPDATE LocationProductsLedger SET to_be_picked_qty = to_be_picked_qty + " + row["to_be_picked_qty"].ToString() + " WHERE location = '" + row["location"].ToString() + "' AND product='" + row["product"].ToString() + "' AND uom ='" + row["uom"].ToString() + "' AND lot_no = '" + row["lot_no"].ToString() + "' AND expiry='" + row["expiry"].ToString() + "'\r\n\r\n\r\n\r\n";
                }

                sql += " UPDATE LocationProductsLedger SET reserved_qty = qty WHERE location = (SELECT location_id FROM Locations WHERE location = location_id AND type='STORAGE - BAD STOCKS'); ";
            }
        }

        return(sql);
    }
示例#13
0
        private void saveUOM()
        {
            StringBuilder sql = new StringBuilder();
            String        id  = DataSupport.RunDataSet("Select max(id) from Products").Tables[0].Rows[0][0].ToString();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (dataGridView1.Rows.IndexOf(row) == dataGridView1.Rows.Count - 1)
                {
                    break;
                }
                Dictionary <String, Object> details = new Dictionary <String, Object>();
                details.Add("productID", id);
                details.Add("prodCode", txtCode.Text);
                if (string.IsNullOrEmpty(row.Cells[colUOM.Name].Value as string))
                {
                    details.Add("uom", "");
                }
                else
                {
                    details.Add("uom", row.Cells[colUOM.Name].Value.ToString());
                }
                if (string.IsNullOrEmpty(row.Cells[colUOM.Name].Value as string))
                {
                    details.Add("qty", "");
                }
                else
                {
                    details.Add("qty", row.Cells[colQty.Name].Value.ToString());
                }
                if (string.IsNullOrEmpty(row.Cells[colPriceType.Name].Value as string))
                {
                    details.Add("priceTypeID", "");
                }
                else
                {
                    details.Add("priceTypeID", row.Cells[colPriceType.Name].Value.ToString());
                }
                if (string.IsNullOrEmpty(row.Cells[colPriceType.Name].Value as string))
                {
                    details.Add("unitPrice", "");
                }
                else
                {
                    details.Add("unitPrice", row.Cells[colPrice.Name].Value.ToString());
                }
                details.Add("dateStamp", DateTime.Now);
                sql.Append(DataSupport.GetInsert("itemPrice", details));
            }
            DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted);
            MessageBox.Show("Success");
        }
示例#14
0
        private void button1_Click(object sender, EventArgs e)
        {
            StringBuilder sql = new StringBuilder();
            Dictionary <String, Object> header = new Dictionary <string, object>();

            header.Add("employee_id", txtId.Text);
            header.Add("name", txtname.Text);
            header.Add("position", txtposition.Text);
            header.Add("password", SecuritySupport.Encrypt(txtpass.Text));
            header.Add("usertype", cbxType.Text);
            sql.Append(DataSupport.GetInsert("[employees]", header));

            DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted);
        }
示例#15
0
        private void btnStockCheck_Click(object sender, EventArgs e)
        {
            try
            {
                var row = headerGrid.SelectedRows[0];

                StringBuilder sql = new StringBuilder();
                Dictionary <String, Object> header = new Dictionary <string, object>();
                DataTable dt = FAQ.GetOMSOutgoingDetails(row.Cells["out_shipment_id"].Value.ToString());

                if (FAQ.IsAlreadyDownloaded(row.Cells["out_shipment_id"].Value.ToString()))
                {
                    LedgerSupport.StockCheck();
                    return;
                }

                String order_id = row.Cells["out_shipment_id"].Value.ToString();
                header.Add("order_id", order_id);

                header.Add("client", row.Cells["client"].Value);
                header.Add("reference", row.Cells["document_reference"].Value);
                header.Add("reference_date", row.Cells["document_reference_date"].Value);
                header.Add("order_date", row.Cells["datetime"].Value);
                header.Add("recipient", row.Cells["authorized_tms"].Value);
                header.Add("customer", row.Cells["customer_id"].Value);
                header.Add("oms_shipment_id", row.Cells["out_shipment_id"].Value);
                sql.Append(DataSupport.GetInsert("ReleaseOrders", header));

                foreach (DataRow detail_row in dt.Rows)
                {
                    Dictionary <String, Object> detail = new Dictionary <string, object>();

                    detail.Add("release_order", order_id);
                    detail.Add("product", detail_row["product"]);
                    detail.Add("uom", detail_row["uom"]);
                    detail.Add("qty", detail_row["expected_qty"]);

                    sql.Append(DataSupport.GetInsert("ReleaseOrderDetails", detail));
                }

                DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted);
                LedgerSupport.StockCheck();
                MessageBox.Show("Stock Check Complete");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#16
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var row = header_grid.CurrentRow;

            // Update Itself
            {
                Dictionary <String, Object> dict = new Dictionary <string, object>();
                dict.Add("trip", trip_id);
                dict.Add("order_id", row.Cells["colShipId"].Value.ToString());
                dict.Add("client", row.Cells["colClient"].Value.ToString());
                dict.Add("customer", row.Cells["colCustomer"].Value.ToString());
                dict.Add("status", "FOR RECEIVING");
                dict.Add("reference", row.Cells["colRefDoc"].Value.ToString());
                dict.Add("reference_date", row.Cells["colRefDocDate"].Value.ToString());
                dict.Add("oms", row.Cells["colClient"].Value.ToString());
                dict.Add("doc_value", row.Cells["colDocValue"].Value.ToString());
                dict.Add("drop_sequence", FAQ.GetSequence(trip_id));

                String sql = DataSupport.GetInsert("TripOrders", dict);
                string s   = row.Cells["colRoute"].Value.ToString();
                sql += " UPDATE Trips SET route = '" + row.Cells["colRoute"].Value.ToString() + "', last_updated_on ='" + DateTime.Now + "' WHERE trip_id = '" + trip_id + "' ";
                DataSupport.RunNonQuery(sql, IsolationLevel.ReadCommitted);
            }

            // Update OMS
            {
                String sql = " UPDATE OutgoingShipmentRequests SET status ='FOR RELEASING' WHERE out_shipment_id = '" + row.Cells["colShipId"].Value.ToString() + "'; ";
                Connection.GetOMSConnection.ExecuteNonQuery(sql, IsolationLevel.ReadCommitted);
            }

            // Update WMS
            {
                // Sync the trip
                String sql = Utils.GetTripWMSSyncSQL(trip_id);

                // Sync the orders of the trip
                var tripDetailsDT = Utils.GetTripDetails(trip_id);
                var tripHeaderRow = Utils.GetTripHeader(trip_id);

                foreach (DataRow trip_row in tripDetailsDT.Rows)
                {
                    sql += $"UPDATE ReleaseOrders SET status='FOR PICKING', scheduled_release_date = '{ tripHeaderRow["expected_start"] }' WHERE order_id ='{ trip_row["order_id"] }' AND status='FOR SCHEDULING';";
                }

                Connection.GetWMSConnection.ExecuteNonQuery(sql, IsolationLevel.ReadCommitted);
            }

            LoadTable();
        }
示例#17
0
        private void button2_Click(object sender, EventArgs e)
        {
            StringBuilder sql = new StringBuilder();
            Dictionary <String, Object> header = new Dictionary <String, Object>();

            header.Add("product_id", txtProductCode.Text);
            header.Add("description", txtDescription.Text);
            header.Add("description1", txtDescrip1.Text);
            header.Add("description2", txtdescription2.Text);
            header.Add("category", txtCat.Text);
            header.Add("pcs_per_case", "0");
            header.Add("default_owner", "COMARK");
            sql.Append(DataSupport.GetInsert("products", header));
            DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted);
        }
示例#18
0
    public static String ToInsert(this DataTable dt, String table)
    {
        StringBuilder result = new StringBuilder();

        foreach (DataRow row in dt.Rows)
        {
            Dictionary <String, Object> insert_list = new Dictionary <string, object>();
            foreach (DataColumn col in dt.Columns)
            {
                insert_list.Add(col.ColumnName, row[col]);
            }
            result.Append(DataSupport.GetInsert(table, insert_list));
        }
        return(result.ToString());
    }
示例#19
0
        private void saved()
        {
            StringBuilder sql = new StringBuilder();
            Dictionary <String, Object> header = new Dictionary <String, Object>();

            header.Add("product_id", txtCode.Text);
            header.Add("description", txtdesc1.Text);
            header.Add("description1", txtdesc2.Text);
            header.Add("description2", txtdesc3.Text);
            header.Add("category", txtCategory.Text);
            header.Add("pcs_per_case", "0");
            header.Add("default_owner", "COMARK");
            sql.Append(DataSupport.GetInsert("products", header));
            DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted);
            saveUOM();
        }
示例#20
0
        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;
        }
示例#21
0
        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;
        }
示例#24
0
        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;
        }
示例#26
0
        private void update()
        {
            StringBuilder sql     = new StringBuilder();
            var           primary = new List <string>();
            Dictionary <String, Object> header = new Dictionary <String, Object>();

            header.Add("product_code", txtproductCode.Text);
            header.Add("description", txtDescription.Text);
            primary.Add("product_code");
            sql.Append(DataSupport.GetUpdate("base_product", header, primary));

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (dataGridView1.Rows.IndexOf(row) == dataGridView1.Rows.Count - 1)
                {
                    break;
                }
                var primarys = new List <string>();
                Dictionary <String, Object> details = new Dictionary <String, Object>();
                details.Add("product_code", txtproductCode.Text);
                if (string.IsNullOrEmpty(row.Cells[colUOM.Name].Value as string))
                {
                    details.Add("uom", "");
                }
                else
                {
                    details.Add("uom", row.Cells[colUOM.Name].Value.ToString());
                }
                if (string.IsNullOrEmpty(row.Cells[colUOM.Name].Value as string))
                {
                    details.Add("quantity", "");
                }
                else
                {
                    details.Add("quantity", row.Cells[colQty.Name].Value.ToString());
                }
                if (string.IsNullOrEmpty(row.Cells[colPriceType.Name].Value as string))
                {
                    details.Add("priceType", "");
                }
                else
                {
                    details.Add("priceType", row.Cells[colPriceType.Name].Value.ToString());
                }
                if (string.IsNullOrEmpty(row.Cells[colPriceType.Name].Value as string))
                {
                    details.Add("price", "");
                }
                else
                {
                    details.Add("price", row.Cells[colPrice.Name].Value.ToString());
                }
                primarys.Add("product_code"); primarys.Add("uom"); primarys.Add("priceType");
                if (FAQ.productPriceExist(txtproductCode.Text, row.Cells[colUOM.Name].Value.ToString(), row.Cells[colPriceType.Name].Value.ToString()))
                {
                    sql.Append(DataSupport.GetUpdate("base_price", details, primarys));
                }
                else
                {
                    sql.Append(DataSupport.GetInsert("base_price", details));
                }
            }
            DataSupport.RunNonQuery(sql.ToString(), IsolationLevel.ReadCommitted);
            MessageBox.Show("updated");
            DialogResult = DialogResult.OK;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            String sql        = "";
            String putaway_id = txtPutawayID.Text;

            // Update the Putaway Details for those declared complete
            foreach (DataGridViewRow row in putaway_details_grid.Rows)
            {
                sql += "UPDATE PutawayDetails SET actual_qty = '" + row.Cells["Quantity"].Value.ToString() + "' WHERE putaway='" + txtPutawayID.Text + "' 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() + "' ";
            }


            // Update the Putaway Details for those declared returneds
            foreach (DataGridViewRow row in returns_grid.Rows)
            {
                sql += "UPDATE PutawayDetails SET actual_qty = expected_qty - " + row.Cells["qty"].Value.ToString() + " WHERE putaway='" + txtPutawayID.Text + "' 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() + "' ";
            }

            // Transactions Ledger

            sql += DataSupport.GetInsert("LocationLedger", Utils.ToDict(
                                             "location", txtContainer.Text
                                             , "transaction_datetime", DateTime.Now.ToString()
                                             , "transaction_type", "OUT"
                                             , "transaction_name", "PUTAWAY_DECLARE_INCOMPLETE"
                                             , "transaction_id", putaway_id
                                             ));

            foreach (DataGridViewRow row in putaway_details_grid.Rows)
            {
                sql += DataSupport.GetUpsert("LocationLedger", Utils.ToDict(
                                                 "location", row.Cells["location"].Value.ToString()
                                                 , "transaction_datetime", DateTime.Now.ToString()
                                                 , "transaction_type", "IN"
                                                 , "transaction_name", "PUTAWAY_DECLARE_INCOMPLETE"
                                                 , "transaction_id", putaway_id
                                                 ), "location", "transaction_datetime", "transaction_id");
            }

            foreach (DataGridViewRow row in returns_grid.Rows)
            {
                sql += DataSupport.GetUpsert("LocationLedger", Utils.ToDict(
                                                 "location", "STAGING-IN"
                                                 , "transaction_datetime", DateTime.Now.ToString()
                                                 , "transaction_type", "IN"
                                                 , "transaction_name", "PUTAWAY_DECLARE_INCOMPLETE"
                                                 , "transaction_id", putaway_id
                                                 ), "location", "transaction_datetime", "transaction_id");
            }

            // Update Location Products Ledger
            foreach (DataGridViewRow row in putaway_details_grid.Rows)
            {
                sql += "UPDATE LocationProductsLedger SET qty = qty - " + row.Cells["Quantity"].Value.ToString() + " WHERE location = '" + txtContainer.Text + "' 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() + "'";

                if (FAQ.IsNewLine(row.Cells["location"].Value.ToString(), row.Cells["product"].Value.ToString(), row.Cells["uom"].Value.ToString(), row.Cells["lot no"].Value.ToString(), row.Cells["expiry"].Value.ToString()))
                {
                    sql += "UPDATE LocationProductsLedger SET qty = qty + " + row.Cells["Quantity"].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() + "'";
                }
                else
                {
                    sql += DataSupport.GetInsert("LocationProductsLedger", Utils.ToDict(
                                                     "location", row.Cells["location"].Value.ToString()
                                                     , "product", row.Cells["product"].Value.ToString()
                                                     , "qty", row.Cells["Quantity"].Value.ToString()
                                                     , "uom", row.Cells["uom"].Value.ToString()
                                                     , "lot_no", row.Cells["lot no"].Value.ToString()
                                                     , "expiry", row.Cells["expiry"].Value.ToString()
                                                     ));
                }
            }

            foreach (DataGridViewRow row in returns_grid.Rows)
            {
                sql += "UPDATE LocationProductsLedger SET qty = qty - " + row.Cells["qty"].Value.ToString() + " WHERE location = '" + txtContainer.Text + "' 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() + "'";

                if (FAQ.IsNewLine("STAGING-IN", row.Cells["product"].Value.ToString(), row.Cells["uom"].Value.ToString(), row.Cells["lot_no"].Value.ToString(), row.Cells["expiry"].Value.ToString()))
                {
                    sql += "UPDATE LocationProductsLedger SET qty = qty + " + row.Cells["qty"].Value.ToString() + " WHERE location = '" + "STAGING-IN" + "' 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() + "'";
                }
                else
                {
                    sql += DataSupport.GetInsert("LocationProductsLedger", Utils.ToDict(
                                                     "location", "STAGING-IN"
                                                     , "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()
                                                     ));
                }
            }

            DataSupport.RunNonQuery(sql, IsolationLevel.ReadCommitted);
        }
示例#28
0
        private void txtBarcode_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                DataTable order_dt = FAQ.GetTripDetails(txtBarcode.Text);
                if (order_dt.Rows.Count == 0)
                {
                    MessageBox.Show("Barcode not recognized");
                    txtBarcode.Text = "";
                    return;
                }

                // Populate

                if (!FAQ.DoesReleasingExist(txtBarcode.Text))
                {
                    String release_id = DataSupport.GetNextMenuCode("RL", "RL");
                    String trip_id    = txtBarcode.Text;
                    String now        = DateTime.Now.ToString();
                    String sql        = "";

                    sql += DataSupport.GetInsert("Releases", Utils.ToDict(
                                                     "release_id", release_id
                                                     , "trip", trip_id
                                                     , "released_on", now
                                                     ));

                    foreach (DataRow row in order_dt.Rows)
                    {
                        String status = "FOR RELEASING";
                        if (order_dt.Rows.IndexOf(row) == 0)
                        {
                            status = "RELEASING";
                        }

                        sql += DataSupport.GetInsert("ReleaseDetails", Utils.ToDict(
                                                         "release", release_id
                                                         , "order_id", row["order_id"]
                                                         , "drop_sequence", row["drop_sequence"]
                                                         , "status", status
                                                         ));

                        DataTable items_dt = FAQ.GetPickedOrder(row["order_id"].ToString());
                        foreach (DataRow item_row in items_dt.Rows)
                        {
                            sql += DataSupport.GetInsert("ReleaseDetailItems", Utils.ToDict(
                                                             "release", release_id
                                                             , "line", items_dt.Rows.IndexOf(item_row)
                                                             , "order_id", item_row["order_id"]
                                                             , "product", item_row["product"]
                                                             , "expiry", item_row["expiry"]
                                                             , "lot_no", item_row["lot_no"]
                                                             , "order_qty", item_row["qty"]
                                                             , "uom", item_row["uom"]
                                                             , "scanned_qty", 0
                                                             ));
                        }
                    }
                    DataSupport.RunNonQuery(sql, IsolationLevel.ReadCommitted);
                }


                ReleasesWindow dialog = new ReleasesWindow();
                dialog.txtTrip.Text = txtBarcode.Text;
                dialog.ShowDialog();
            }
        }
示例#29
0
        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;
            }
        }
示例#30
0
        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;
        }