public ReplenishmentWindow(NewComing replenishTable, DataTable PTLS) { InitializeComponent(); //expandedItem = null; cart_barcode = replenishTable.TableName; this.replenishTable = replenishTable; PTLs = PTLS; this.Owner = (MainWindow)Application.Current.MainWindow; this.ResizeMode = ResizeMode.NoResize; this.Closing += (se, e) => { if (!Confirmed && !(Owner as MainWindow).close) { MessageBox.Show("Тауарлар толығымен орналастырылмады!"); } }; this.Loaded += (se, ev) => { Owner.IsEnabled = false; if (!Start()) { Close(); } }; string[] st = { "Gateway", "ID" }; dt = PTLs.DefaultView.ToTable(true, st); dt.Columns[0].ColumnName = "Gateway"; dt.Columns[1].ColumnName = "ID"; action_list = new List <Tuple <int, int, string> > [dt.Rows.Count]; for (int ind = 0; ind < dt.Rows.Count; ind++) { action_list[ind] = new List <Tuple <int, int, string> >(); } foreach (DataRow row in replenishTable.Rows) { if (Convert.ToInt32(row[3]) == 0) { DataRow[] r = PTLs.Select("Global = " + row[1]); if (r.Length > 0) { DataRow[] rw = dt.Select("Gateway = " + r[0][2] + " AND ID = " + r[0][3]); if (rw.Length > 0) { int index = dt.Rows.IndexOf(rw[0]); string short_series = row[9].ToString().Substring(Math.Max(0, row[9].ToString().Length - 4)); Tuple <int, int, string> t2 = new Tuple <int, int, string>(Convert.ToInt32(row[0]), Convert.ToInt32(row[2]), short_series); action_list[index].Add(t2); } } } } orderTab.Header = "Корзина " + cart_barcode; int i = 1; //OrdersPanel.Visibility = Visibility.Collapsed; string[] s = { "" }; foreach (DataRow row in replenishTable.Rows) { ReplenishContentItem ordc = new ReplenishContentItem(i, Convert.ToInt32(row[0]), s, row[6].ToString(), row[5].ToString(), row[9].ToString(), Convert.ToInt32(row[2]), Convert.ToInt32(row[1])); if (Convert.ToInt32(row[3]) == 0) { ordc.QuantityReplenished = Convert.ToInt32(row[2]); } else if (Convert.ToInt32(row[3]) == 1) { ordc.Confirmed = true; ordc.QuantityReplenished = Convert.ToInt32(row[4]); } else if (Convert.ToInt32(row[3]) == 2) { ordc.QuantityReplenished = Convert.ToInt32(row[4]); ordc.Expanded = true; } ordc.ShowButtonPressed += (se, ev) => { DataRow[] r2 = replenishTable.Select("Desc_id = " + (se as ReplenishContentItem).RefID); if (r2.Length > 0) { DataRow[] r = PTLs.Select("Global = " + r2[0][1]); if (r.Length > 0) { ConfirmORDC(se as ReplenishContentItem, r2, (se as ReplenishContentItem).QuantityReplenished.ToString(), r); //((MainWindow)Application.Current.MainWindow).ptlconn.ClearNode(Convert.ToInt32(r[0][2]), Convert.ToInt32(r[0][3])); /*DataRow[] newrows = PTLs.Select("Gateway = " + r[0][2] + "AND ID = " + r[0][3]); * * foreach (DataRow newrow in newrows) * { * DataRow[] dr = replenishTable.Select("PTL = " + newrow[1]); * if (dr.Length > 0 && !Convert.ToBoolean(dr[0][3])) * { * Direction dir = Direction.Up; * if (Convert.ToBoolean(newrow[4])) * dir = Direction.Down; * ((MainWindow)Application.Current.MainWindow).ptlconn.SetLEDStatus(Convert.ToInt32(newrow[2]), Convert.ToInt32(newrow[3]), LEDColor.Amber, LEDStatus.On); * ((MainWindow)Application.Current.MainWindow).ptlconn.DisplayQuantity(Convert.ToInt32(newrow[2]), Convert.ToInt32(newrow[3]), Convert.ToInt32(dr[0][2]), dir, 0, 0); * } * }*/ } } }; ordc.ConfirmButtonPressed += (se, ev) => { DataRow[] r2 = replenishTable.Select("Desc_id = " + (se as ReplenishContentItem).RefID); if (r2.Length > 0) { DataRow[] r = PTLs.Select("Global = " + r2[0][1]); if (r.Length > 0) { ConfirmPodp((se as ReplenishContentItem), r2, (se as ReplenishContentItem).QuantityPodpitka.ToString(), r); } } }; ordc.CancelButtonPressed += (se, ev) => // HERE { ordc.cancellation = true; DataRow[] r2 = replenishTable.Select("Desc_id = " + (se as ReplenishContentItem).RefID); if (r2.Length > 0) { r2[0][3] = 1; (this.Owner as MainWindow).sqlQueriesToSend.Add("UPDATE ptl_database.newcomingsdescription " + "SET status=1, statusPotpitka=0 WHERE idNewComingsDescription=" + r2[0][0] + ";"); ordc.Confirmed = true; DataRow[] PTLrow = PTLs.Select("Global = " + r2[0][1]); if (PTLrow.Length > 0) { DataRow[] rw = dt.Select("Gateway = " + PTLrow[0][2] + " AND ID = " + PTLrow[0][3]); if (rw.Length > 0) { ((MainWindow)Application.Current.MainWindow).ptlconn.ClearNode(Convert.ToInt32(PTLrow[0][2]), Convert.ToInt32(PTLrow[0][3])); int index = dt.Rows.IndexOf(rw[0]); if (action_list[index].Count > 0) { action_list[index].RemoveAt(0); } if (action_list[index].Count > 0) { SendToPTL(action_list[index][0]); } } } } bool all_confirmed = true; foreach (ReplenishContentItem o in OrdersPanel.Children.OfType <ReplenishContentItem>()) { if (!o.Confirmed) { all_confirmed = false; } } if (all_confirmed) { this.Confirmed = true; } }; /*ordc.ExpandMe += (se, ev) => * { * if (expandedItem != null) * { * expandedItem.Expanded = false; * } * expandedItem = (se as ReplenishContentItem); * expandedItem.Expanded = true; * };*/ OrdersPanel.Children.Add(ordc); i++; } }
public PodpitkaWindow(NewComing podpitka_table, DataTable PTLS) { InitializeComponent(); this.podpitkaTable = podpitka_table; //podpitka_t = podpitka_table; PTLs = PTLS; //this.order_id = order_id; string[] st = { "Gateway", "ID" }; dt = PTLs.DefaultView.ToTable(true, st); dt.Columns[0].ColumnName = "Gateway"; dt.Columns[1].ColumnName = "ID"; action_list = new List <Tuple <int, int> > [dt.Rows.Count]; for (int ind = 0; ind < dt.Rows.Count; ind++) { action_list[ind] = new List <Tuple <int, int> >(); } this.Owner = (MainWindow)Application.Current.MainWindow; this.ResizeMode = ResizeMode.NoResize; this.Loaded += (se, ev) => { Start(); }; foreach (DataRow row in podpitkaTable.Rows) { if (Convert.ToInt32(row[3]) == 0) { DataRow[] r = PTLs.Select("Global = " + row[1]); if (r.Length > 0) { DataRow[] rw = dt.Select("Gateway = " + r[0][2] + " AND ID = " + r[0][3]); if (rw.Length > 0) { int index = dt.Rows.IndexOf(rw[0]); Tuple <int, int> t2 = new Tuple <int, int>(Convert.ToInt32(row[0]), Convert.ToInt32(row[2])); action_list[index].Add(t2); } } } } int i = 1; string[] s = { "" }; foreach (DataRow row in podpitkaTable.Rows) { PodpitkaContentItem ordc = new PodpitkaContentItem(i, Convert.ToInt32(row[0]), s, row[6].ToString(), row[5].ToString(), Convert.ToInt32(row[2]), Convert.ToInt32(row[1])); if (Convert.ToInt32(row[3]) == 0) { ordc.QuantityCollected = Convert.ToInt32(row[2]); } else { ordc.Confirmed = true; ordc.QuantityCollected = Convert.ToInt32(row[4]); } ordc.ShowButtonPressed += (se, ev) => { DataRow[] r = PTLs.Select("Global = " + (se as PodpitkaContentItem).PTL_global); if (r.Length > 0) { ConfirmORDC(se as PodpitkaContentItem, r, (se as PodpitkaContentItem).QuantityCollected.ToString()); ((MainWindow)Application.Current.MainWindow).ptlconn.ClearNode(Convert.ToInt32(r[0][2]), Convert.ToInt32(r[0][3])); DataRow[] newrows = PTLs.Select("Gateway = " + r[0][2] + "AND ID = " + r[0][3]); /*foreach (DataRow newrow in newrows) * { * foreach (PodpitkaContentItem pp in OrdersPanel.Children.OfType<PodpitkaContentItem>()) * { * if (!pp.Confirmed && pp.PTL_global == Convert.ToInt32(newrow[1])) * { * Direction dir = Direction.Up; * if (Convert.ToBoolean(newrow[4])) * dir = Direction.Down; * ((MainWindow)Application.Current.MainWindow).ptlconn.SetLEDStatus(Convert.ToInt32(newrow[2]), Convert.ToInt32(newrow[3]), LEDColor.Cyan, LEDStatus.On); * ((MainWindow)Application.Current.MainWindow).ptlconn.DisplayQuantity(Convert.ToInt32(newrow[2]), Convert.ToInt32(newrow[3]), pp.Quantity, dir, 0, 0); * * } * } * }*/ DataRow[] rw = dt.Select("Gateway = " + r[0][2] + " AND ID = " + r[0][3]); if (rw.Length > 0) { int index = dt.Rows.IndexOf(rw[0]); int c = action_list[index].Count; for (int ind = c - 1; ind >= 0; ind--) { if (action_list[index][ind].Item1 == (se as PodpitkaContentItem).RefID) { action_list[index].RemoveAt(ind); } } if (action_list[index].Count > 0) { SendToPTL(action_list[index][0]); } } } }; OrdersPanel.Children.Add(ordc); i++; } }