コード例 #1
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();
            }
        }