예제 #1
0
        private void ConfirmORDC(OrderContentItem ordc, DataRow[] r, string message)
        {
            DataRow[] r2 = orders.Select("PTL = " + r[0][1]);
            if (r2.Length > 0)
            {
                r2[0][4] = 1;
                r2[0][5] = message.Trim();
                (this.Owner as MainWindow).sqlQueriesToSend.Add("UPDATE ptl_database.orders_description SET status=1, act_quant=" + message.Trim()
                                                                + " WHERE description_id=" + r2[0][0] + ";");
            }

            ordc.Confirmed = true;
            bool all_confirmed = true;

            foreach (OrderContentItem o in OrdersPanel.Children.OfType <OrderContentItem>())
            {
                if (!o.Confirmed)
                {
                    all_confirmed = false;
                }
            }
            if (all_confirmed)
            {
                this.Confirmed = true;
            }
        }
예제 #2
0
        private void ConfirmORDC(OrderContentItem ordc, DataRow[] order_row, string message)
        {
            //DataRow[] r2 = orders.Select("PTL = " + r[0][1]);

            /*if (r2.Length > 0)
             * {*/
            order_row[0][4] = 1;
            order_row[0][5] = Convert.ToInt32(message.Trim());
            (this.Owner as MainWindow).sqlQueriesToSend.Add("UPDATE ptl_database.orders_description SET status=1, act_quant=" + message.Trim()
                                                            + ", user_id=" + (this.Owner as MainWindow).currentUser + " WHERE description_id=" + order_row[0][0] + ";");
            //}
            ordc.status = Status.confirmed;
            //ordc.Confirmed = true;
            bool all_confirmed = true;

            foreach (OrderContentItem o in OrdersPanel.Children.OfType <OrderContentItem>())
            {
                if (o.status != Status.confirmed)
                {
                    all_confirmed = false;
                }
            }
            if (all_confirmed)
            {
                this.Confirmed = true;
            }
        }
예제 #3
0
        private void ConfirmORDC(OrderContentItem ordc, DataRow[] order_row, string message)
        {
            //DataRow[] r2 = orders.Select("PTL = " + r[0][1]);

            /*if (r2.Length > 0)
             * {*/
            order_row[0][4] = 1;
            order_row[0][5] = Convert.ToInt32(message.Trim());
            (this.Owner as MainWindow).sqlQueriesToSend.Add("UPDATE ptl_database.ordersdescription SET status=1, actQuant=" + message.Trim()
                                                            + ", userId=" + (this.Owner as MainWindow).currentUser + ", datetimeProcessed=CURRENT_TIMESTAMP WHERE descriptionId=" + order_row[0][0] + ";");
            //MessageBox.Show("HERE");

            //}
            if (Convert.ToInt32(orders.Rows[0]["Palletized"]) != 0)
            {
                if (orders.DestinationZone != null)
                {
                    (this.Owner as MainWindow).sqlQueriesToSend.Add("UPDATE ptl_database.newcomingsdescription SET cartBarcode='" +
                                                                    (mainGrid.Child as CartBarcodesWrapPanel).Children.OfType <CartBarcodeBorder>().First().Barcode +
                                                                    "', quantity=" + message.Trim() + " WHERE orderId=" + orders.order_id + ";");


                    DataTable id_table = new DataTable();
                    {
                        string           stu = "SELECT docId FROM newcomingsdescription WHERE orderId=" + orders.order_id + ";";
                        MySqlDataAdapter da1 = new MySqlDataAdapter(stu, connect);
                        da1.Fill(id_table);
                    }

                    String id_str = id_table.Rows[0][0].ToString();
                    (this.Owner as MainWindow).sqlQueriesToSend.Add("INSERT INTO ptl_database.newcomings (docId, cartBarcode, zoneId) VALUES (" + id_str
                                                                    + ", '" + (mainGrid.Child as CartBarcodesWrapPanel).Children.OfType <CartBarcodeBorder>().First().Barcode + "', " + orders.Rows[0]["zone_dest"].ToString() + ");");
                }
            }
            ordc.status = Status.confirmed;
            //ordc.Confirmed = true;
            bool all_confirmed = true;

            foreach (OrderContentItem o in OrdersPanel.Children.OfType <OrderContentItem>())
            {
                if (o.status != Status.confirmed)
                {
                    all_confirmed = false;
                }
            }
            if (all_confirmed)
            {
                this.Confirmed = true;
            }
        }
예제 #4
0
        public OrderWindow(DataTable orderTable, DataTable PTLS, string order_name, int order_id)
        {
            InitializeComponent();
            expandedItem    = null;
            InProcess       = false;
            orders          = orderTable;
            PTLs            = PTLS;
            this.order_name = order_name;
            this.order_id   = order_id;

            this.Owner      = (MainWindow)Application.Current.MainWindow;
            this.ResizeMode = ResizeMode.NoResize;
            this.Closing   += (se, e) =>
            {
                if (!Confirmed && !(Owner as MainWindow).close)
                {
                    MessageBox.Show("Заказ не собран!");
                    e.Cancel = true;
                }
            };

            orderName.Text = order_name;
            int i = 1;

            OrdersPanel.Visibility = Visibility.Collapsed;
            string[] s = { "" };
            foreach (DataRow row in orders.Rows)
            {
                //

                OrderContentItem ordc = new OrderContentItem(i, Convert.ToInt32(row[1]), s, row[7].ToString(), row[6].ToString(), row[3].ToString(), Convert.ToInt32(row[2]));

                if (Convert.ToInt32(row[4]) == 0)
                {
                    ordc.QuantityCollected = Convert.ToInt32(row[2]);
                }
                else
                {
                    ordc.Confirmed         = true;
                    ordc.QuantityCollected = Convert.ToInt32(row[5]);
                }
                ordc.ShowButtonPressed += (se, ev) =>
                {
                    DataRow[] r = PTLs.Select("Global = " + (se as OrderContentItem).RefID);
                    if (r.Length > 0)
                    {
                        ConfirmORDC(se as OrderContentItem, r, (se as OrderContentItem).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)
                        {
                            DataRow[] dr = orders.Select("PTL = " + newrow[1]);
                            if (dr.Length > 0 && !Convert.ToBoolean(dr[0][4]))
                            {
                                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.Blue, 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.ExpandMe += (se, ev) =>
                {
                    if (expandedItem != null)
                    {
                        expandedItem.Expanded = false;
                    }
                    expandedItem          = (se as OrderContentItem);
                    expandedItem.Expanded = true;
                };
                OrdersPanel.Children.Add(ordc);
                i++;
            }
        }
예제 #5
0
        public OrderWindow(Order orderTable, DataTable PTLS, DataTable all_baskets, MySqlConnection conn)
        {
            connect = conn;
            baskets = all_baskets;
            InitializeComponent();
            expandedItem = null;
            InProcess    = false;
            orders       = orderTable;
            PTLs         = PTLS;

            bool etw = true;

            if (orders.DestinationZone == null)
            {
                dest_zone_block.Text = "Зона назначения: Зона контроля";
                etw = true;
            }
            else
            {
                dest_zone_block.Text = "Зона назначения: " + orders.DestinationZone;
                etw = false;
            }

            this.Owner      = (MainWindow)Application.Current.MainWindow;
            this.ResizeMode = ResizeMode.CanResize;
            this.Closing   += (se, e) =>
            {
                if (!Confirmed && !(Owner as MainWindow).close)
                {
                    MessageBox.Show("Тапсырыс толығымен жиналмады!");
                    e.Cancel = true;
                }
            };

            if (Convert.ToInt32(orders.Rows[0]["Palletized"]) == 0 || Convert.ToInt32(orders.Rows[0]["zone_dest"]) != -1)
            {
                CartBarcodesWrapPanel wrp = new CartBarcodesWrapPanel(this, etw, baskets)
                {
                    Margin = new Thickness(0)
                };
                mainGrid.Child = wrp;


                foreach (DataRow row in orders.existingCarts.Rows)
                {
                    wrp.AddExistingCart(row[1].ToString());
                    //listBox.Items.Add(new TextBlock() { Text = row[1].ToString() });
                }
            }

            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 <bool, int, string> > [dt.Rows.Count];
            for (int ind = 0; ind < dt.Rows.Count; ind++)
            {
                action_list[ind] = new List <Tuple <bool, int, string> >();
            }

            foreach (DataRow row in orders.Rows)
            {
                if (Convert.ToInt32(row[4]) == 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]);

                            //int max_exp = 6;

                            //int month = DateTime.Now.Month;
                            //int year = DateTime.Now.Year % 2000;

                            //int thisdate = (Convert.ToInt32(row[3]) - month) + 12 * (Convert.ToInt32(row[8]) - year);

                            //if (thisdate <= max_exp && thisdate >= 0)
                            //{
                            string short_series         = row[10].ToString().Substring(Math.Max(0, row[10].ToString().Length - 5));    //5 last digits of series
                            Tuple <bool, int, string> t = new Tuple <bool, int, string>(false, Convert.ToInt32(row[0]), short_series);
                            action_list[index].Add(t);
                            //}
                            Tuple <bool, int, string> t2 = new Tuple <bool, int, string>(true, Convert.ToInt32(row[0]), row[2].ToString());
                            action_list[index].Add(t2);
                        }
                    }
                }
            }

            orderTab.Header = "Заказ " + orders.TableName;
            int i = 1;

            OrdersPanel.Visibility = Visibility.Collapsed;
            string[] s = { "" };
            foreach (DataRow row in orders.Rows)
            {
                //

                OrderContentItem ordc = new OrderContentItem(i, Convert.ToInt32(row[0]), s, row[7].ToString(), row[6].ToString(), (row[3].ToString() + "-" + row[8].ToString()), Convert.ToInt32(row[2]), Convert.ToInt32(row[1]));

                if (Convert.ToInt32(row[4]) == 0)
                {
                    ordc.QuantityCollected = Convert.ToInt32(row[2]);
                }
                else
                {
                    ordc.status            = Status.confirmed;
                    ordc.QuantityCollected = Convert.ToInt32(row[5]);
                }
                ordc.ShowButtonPressed += (se, ev) =>
                {
                    DataRow[] order_row = orders.Select("Desc_id = " + (se as OrderContentItem).RefID);

                    if (order_row.Length > 0)
                    {
                        ConfirmORDC(se as OrderContentItem, order_row, (se as OrderContentItem).QuantityCollected.ToString());
                    }

                    DataRow[] r = PTLs.Select("Global = " + (se as OrderContentItem).PTL_global);
                    if (r.Length > 0)
                    {
                        //ConfirmORDC(se as OrderContentItem, r, (se as OrderContentItem).QuantityCollected.ToString());
                        ((MainWindow)Application.Current.MainWindow).ptlconn.ClearNode(Convert.ToInt32(r[0][2]), Convert.ToInt32(r[0][3]));

                        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].Item2 == (se as OrderContentItem).RefID)
                                {
                                    action_list[index].RemoveAt(ind);
                                }
                            }

                            /*for (int ind = 0; ind < c; ind++)
                             * {
                             *  Tuple<bool, int, string> t = action_list[index].Dequeue();
                             *  if (t.Item2 != (se as InventoryContentItem).RefID)
                             *  {
                             *      action_list[index].Enqueue(t);
                             *  }
                             * }*/
                            if (action_list[index].Count > 0)
                            {
                                SendToPTL(action_list[index][0]);
                            }
                        }

                        /*DataRow[] newrows = PTLs.Select("Gateway = " + r[0][2] + "AND ID = " + r[0][3]);
                         *
                         * foreach (DataRow newrow in newrows)
                         * {
                         *  DataRow[] dr = orders.Select("PTL = " + newrow[1]);
                         *  if (dr.Length > 0 && !Convert.ToBoolean(dr[0][4]))
                         *  {
                         *      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.Blue, 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.ExpandMe += (se, ev) =>
                 * {
                 *  if (expandedItem != null)
                 *  {
                 *      expandedItem.Expanded = false;
                 *  }
                 *  expandedItem = (se as OrderContentItem);
                 *  expandedItem.Expanded = true;
                 * };*/
                OrdersPanel.Children.Add(ordc);
                i++;
            }
        }
예제 #6
0
        public OrderWindow(Order orderTable, DataTable PTLS)
        {
            InitializeComponent();
            expandedItem = null;
            InProcess    = false;
            orders       = orderTable;
            PTLs         = PTLS;

            this.Owner      = (MainWindow)Application.Current.MainWindow;
            this.ResizeMode = ResizeMode.NoResize;
            this.Closing   += (se, e) =>
            {
                if (!Confirmed && !(Owner as MainWindow).close)
                {
                    MessageBox.Show("Заказ не собран!");
                    e.Cancel = true;
                }
            };

            foreach (DataRow row in orders.existingCarts.Rows)
            {
                listBox.Items.Add(new TextBlock()
                {
                    Text = row[1].ToString()
                });
            }

            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 <bool, int, string> > [dt.Rows.Count];
            for (int ind = 0; ind < dt.Rows.Count; ind++)
            {
                action_list[ind] = new List <Tuple <bool, int, string> >();
            }

            foreach (DataRow row in orders.Rows)
            {
                if (Convert.ToInt32(row[4]) == 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]);

                            int max_exp = 6;

                            int month = DateTime.Now.Month;
                            int year  = DateTime.Now.Year % 2000;

                            int thisdate = (Convert.ToInt32(row[3]) - month) + 12 * (Convert.ToInt32(row[8]) - year);

                            if (thisdate <= max_exp && thisdate >= 0)
                            {
                                Tuple <bool, int, string> t = new Tuple <bool, int, string>(false, Convert.ToInt32(row[0]), (row[3].ToString() + "-" + row[8].ToString()));
                                action_list[index].Add(t);
                            }
                            Tuple <bool, int, string> t2 = new Tuple <bool, int, string>(true, Convert.ToInt32(row[0]), row[2].ToString());
                            action_list[index].Add(t2);
                        }
                    }
                }
            }

            orderName.Text = orders.TableName;
            int i = 1;

            OrdersPanel.Visibility = Visibility.Collapsed;
            string[] s = { "" };
            foreach (DataRow row in orders.Rows)
            {
                //

                OrderContentItem ordc = new OrderContentItem(i, Convert.ToInt32(row[0]), s, row[7].ToString(), row[6].ToString(), (row[3].ToString() + "-" + row[8].ToString()), Convert.ToInt32(row[2]), Convert.ToInt32(row[1]));

                if (Convert.ToInt32(row[4]) == 0)
                {
                    ordc.QuantityCollected = Convert.ToInt32(row[2]);
                }
                else
                {
                    ordc.status            = Status.confirmed;
                    ordc.QuantityCollected = Convert.ToInt32(row[5]);
                }
                ordc.ShowButtonPressed += (se, ev) =>
                {
                    DataRow[] order_row = orders.Select("Desc_id = " + (se as OrderContentItem).RefID);

                    if (order_row.Length > 0)
                    {
                        ConfirmORDC(se as OrderContentItem, order_row, (se as OrderContentItem).QuantityCollected.ToString());
                    }

                    DataRow[] r = PTLs.Select("Global = " + (se as OrderContentItem).PTL_global);
                    if (r.Length > 0)
                    {
                        //ConfirmORDC(se as OrderContentItem, r, (se as OrderContentItem).QuantityCollected.ToString());
                        ((MainWindow)Application.Current.MainWindow).ptlconn.ClearNode(Convert.ToInt32(r[0][2]), Convert.ToInt32(r[0][3]));

                        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].Item2 == (se as OrderContentItem).RefID)
                                {
                                    action_list[index].RemoveAt(ind);
                                }
                            }

                            /*for (int ind = 0; ind < c; ind++)
                             * {
                             *  Tuple<bool, int, string> t = action_list[index].Dequeue();
                             *  if (t.Item2 != (se as InventoryContentItem).RefID)
                             *  {
                             *      action_list[index].Enqueue(t);
                             *  }
                             * }*/
                            if (action_list[index].Count > 0)
                            {
                                SendToPTL(action_list[index][0]);
                            }
                        }

                        /*DataRow[] newrows = PTLs.Select("Gateway = " + r[0][2] + "AND ID = " + r[0][3]);
                         *
                         * foreach (DataRow newrow in newrows)
                         * {
                         *  DataRow[] dr = orders.Select("PTL = " + newrow[1]);
                         *  if (dr.Length > 0 && !Convert.ToBoolean(dr[0][4]))
                         *  {
                         *      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.Blue, 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.ExpandMe += (se, ev) =>
                 * {
                 *  if (expandedItem != null)
                 *  {
                 *      expandedItem.Expanded = false;
                 *  }
                 *  expandedItem = (se as OrderContentItem);
                 *  expandedItem.Expanded = true;
                 * };*/
                OrdersPanel.Children.Add(ordc);
                i++;
            }
        }