Exemple #1
0
        private void closeTab()
        {
            OrderTab ot = (OrderTab)tabControl1.SelectedTab;
            Order    o  = ot.Order;

            if (ot.Empty == false)
            {
                foreach (DataGridView d in ot.Controls.OfType <DataGridView>())
                {
                    o.CONTENTLIST = Databases.compactData(((DataTable)d.DataSource));
                }

                o.INDEXLIST = Databases.compactList(ot.IndexIdentifiers);
                o.TABLE     = -1;

                CloseFatura f = new CloseFatura(o);
                f.FormClosed += new FormClosedEventHandler(checkClose);
                f.Show();
            }
            else
            {
                Notification n = new Notification(Classes.Enum.AlertType.ERROR, "Nenhum pedido foi iniciado.", 1);
                n.ShowDialog();
            }
        }
Exemple #2
0
        private void ProdutoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedTab != null)
            {
                foreach (DataGridView dv in tabControl1.SelectedTab.Controls.OfType <DataGridView>())
                {
                    Int32 selectedRowCount = dv.Rows.GetRowCount(DataGridViewElementStates.Selected);
                    if (selectedRowCount > 0)
                    {
                        for (int i = 0; i < selectedRowCount; i++)
                        {
                            int selectedrowindex = dv.SelectedCells[0].RowIndex;

                            DataGridViewRow selectedRow = dv.Rows[selectedrowindex];

                            dv.Rows.RemoveAt(dv.SelectedRows[0].Index);

                            TabPage  tab         = tabControl1.SelectedTab;
                            OrderTab selectedTab = (OrderTab)tab;

                            if (dv.Rows.GetRowCount(DataGridViewElementStates.Visible) == 0)
                            {
                                selectedTab.Empty = true;
                            }

                            Product p = ProductManager.getProduct(selectedTab.IndexIdentifiers[selectedrowindex]);

                            selectedTab.IndexIdentifiers.RemoveAt(selectedrowindex);

                            selectedTab.List = (DataTable)dv.DataSource;

                            selectedTab.Order.VALUE -= p.PRICE;

                            foreach (Label l in selectedTab.Controls.OfType <Label>())
                            {
                                if (l.Name == "priceshow")
                                {
                                    l.Text = selectedTab.Order.VALUE + "€";
                                }
                            }

                            if (p.unlimitedSTOCK == false)
                            {
                                p.STOCK += 1;
                                ProductManager.editStockNumb(p);
                            }

                            selectedTab.Order.EVENTS = String.Concat(selectedTab.Order.EVENTS, "§" + log.IDENTIFIER + " removeu " + p.NAME + " (" + Time.get() + ")");
                        }
                    }
                }
            }
            else
            {
                Notification n = new Notification(Classes.Enum.AlertType.ERROR, "Nenhum pedido foi iniciado.", 1);
                n.ShowDialog();
            }
        }
 public OrderInfo(int orderId, OrderTab _orderTab, OrderHistoryTab _orderHistoryTab = null)
 {
     InitializeComponent();
     OrderId         = orderId;
     orderTab        = _orderTab;
     orderHistoryTab = _orderHistoryTab;
     ComboBoxSelectFood.TextBoxSearch.FontSize = 11;
     reloadAllUI();
 }
Exemple #4
0
        private void infoTab()
        {
            TabPage  sel = tabControl1.SelectedTab;
            OrderTab o   = (OrderTab)sel;

            OrderInfo d = new OrderInfo(o.Order);

            d.ShowDialog();
        }
Exemple #5
0
        private void updvalor(object sender, FormClosingEventArgs e)
        {
            if (Data.done == true)
            {
                if (tabControl1.SelectedTab == null)
                {
                    Notification n = new Notification(Classes.Enum.AlertType.ERROR, "Nenhum pedido foi iniciado.", 1);
                    n.ShowDialog();
                    return;
                }

                OrderTab selectedTab = (OrderTab)tabControl1.SelectedTab;
                selectedTab.Empty = false;

                foreach (DataGridView rb in selectedTab.Controls.OfType <DataGridView>())
                {
                    DataTable dataTable = (DataTable)rb.DataSource;
                    DataRow   drToAdd   = dataTable.NewRow();

                    drToAdd["Produto"] = Data.name;
                    drToAdd["Valor"]   = Data.price + "€";

                    dataTable.Rows.Add(drToAdd);
                    dataTable.AcceptChanges();

                    selectedTab.List = dataTable;

                    selectedTab.Order.VALUE += Data.price;

                    if (selectedTab.IndexIdentifiers == null)
                    {
                        selectedTab.IndexIdentifiers = new List <string>();
                    }
                    selectedTab.IndexIdentifiers.Add(Data.id);

                    foreach (Label l in selectedTab.Controls.OfType <Label>())
                    {
                        if (l.Name == "priceshow")
                        {
                            l.Text = selectedTab.Order.VALUE + "€";
                        }
                    }

                    if (selectedTab.Order.EVENTS == null)
                    {
                        selectedTab.Order.EVENTS = log.IDENTIFIER + " adicionou um produto não listado " + Data.name + " no valor de " + Data.price + "€" + " (" + Time.get() + ")";
                    }
                    else
                    {
                        selectedTab.Order.EVENTS = String.Concat(selectedTab.Order.EVENTS, "§" + log.IDENTIFIER + " adicionou um produto não listado " + Data.name + " no valor de " + Data.price + "€" + " (" + Time.get() + ")");
                    }
                }
                Data.done = false;
            }
        }
Exemple #6
0
        //TAB
        private void OrderTab_SelectedIndexChanged(object sender, EventArgs e)
        {
            Form frm = OrderTab.FindForm();

            if (ComboOrderCustomer.SelectedIndex > 0)
            {
                HelperCS.dt      = null;
                lblEditmode.Text = "";
                CheckTabActive();
            }
            else
            {
                //MessageBox.Show("Please Select Customer Before" ,"Select Customer",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
                //MetroMessageBox.Show(frm, "Please Select Customer Before");
            }
        }
Exemple #7
0
        private void PedidoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedTab != null)
            {
                TabPage  tab         = tabControl1.SelectedTab;
                OrderTab selectedTab = (OrderTab)tab;
                OrderManager.deleteOrder(selectedTab.Order);

                this.tabControl1.TabPages.Remove(tabControl1.SelectedTab);
            }
            else
            {
                Notification n = new Notification(Classes.Enum.AlertType.ERROR, "Nenhum pedido foi iniciado.", 1);
                n.ShowDialog();
            }
        }
Exemple #8
0
        public void saveOrders()
        {
            foreach (TabPage p in tabControl1.TabPages)
            {
                OrderTab ot = (OrderTab)p;
                Order    o  = ot.Order;

                if (!OrderManager.orderExistsNormal(o))
                {
                    if (ot.Empty == false)
                    {
                        foreach (DataGridView d in ot.Controls.OfType <DataGridView>())
                        {
                            o.CONTENTLIST = Databases.compactData(((DataTable)d.DataSource));
                        }

                        o.INDEXLIST = Databases.compactList(ot.IndexIdentifiers);
                        o.TABLE     = -1;
                        OrderManager.saveOrder(o);
                    }
                    else
                    {
                        tabControl1.TabPages.Remove(ot);
                    }
                }
                else
                {
                    if (ot.Empty == false)
                    {
                        foreach (DataGridView d in ot.Controls.OfType <DataGridView>())
                        {
                            o.CONTENTLIST = Databases.compactData(((DataTable)d.DataSource));
                        }

                        o.INDEXLIST = Databases.compactList(ot.IndexIdentifiers);
                        o.TABLE     = -1;
                        OrderManager.editOrder(o);
                    }
                    else
                    {
                        tabControl1.TabPages.Remove(ot);
                    }
                }
            }
        }
Exemple #9
0
        private void delProduct(object sender2, KeyEventArgs e2, DataGridView dv)
        {
            if (e2.KeyCode == Keys.Delete)
            {
                Int32 selectedRowCount = dv.Rows.GetRowCount(DataGridViewElementStates.Selected);
                if (selectedRowCount > 0)
                {
                    for (int i = 0; i < selectedRowCount; i++)
                    {
                        TabPage  tab         = tabControl1.SelectedTab;
                        OrderTab selectedTab = (OrderTab)tab;

                        int selectedrowindex = dv.SelectedCells[0].RowIndex;

                        if (selectedTab.IndexIdentifiers[selectedrowindex] != "Added By User")
                        {
                            Product p = ProductManager.getProduct(selectedTab.IndexIdentifiers[selectedrowindex]);

                            DataGridViewRow selectedRow = dv.Rows[selectedrowindex];

                            dv.Rows.RemoveAt(dv.SelectedRows[0].Index);

                            if (dv.Rows.GetRowCount(DataGridViewElementStates.Visible) == 0)
                            {
                                selectedTab.Empty = true;
                            }

                            selectedTab.IndexIdentifiers.RemoveAt(selectedrowindex);

                            selectedTab.List = (DataTable)dv.DataSource;

                            selectedTab.Order.VALUE -= p.PRICE;

                            foreach (Label l in selectedTab.Controls.OfType <Label>())
                            {
                                if (l.Name == "priceshow")
                                {
                                    l.Text = selectedTab.Order.VALUE + "€";
                                }
                            }

                            if (p.unlimitedSTOCK == false)
                            {
                                p.STOCK += 1;
                                ProductManager.editStockNumb(p);
                            }

                            selectedTab.Order.EVENTS = String.Concat(selectedTab.Order.EVENTS, "§" + log.IDENTIFIER + " removeu " + p.NAME + " (" + Time.get() + ")");
                        }
                        else
                        {
                            DataGridViewRow selectedRow = dv.Rows[selectedrowindex];

                            if (dv.Rows.GetRowCount(DataGridViewElementStates.Visible) == 0)
                            {
                                selectedTab.Empty = true;
                            }

                            selectedTab.IndexIdentifiers.RemoveAt(selectedrowindex);

                            selectedTab.List = (DataTable)dv.DataSource;

                            String nom = dv.Rows[selectedrowindex].Cells["Produto"].Value.ToString();
                            Double d   = Double.Parse(dv.Rows[selectedrowindex].Cells["Valor"].Value.ToString().Replace("€", ""));

                            dv.Rows.RemoveAt(dv.SelectedRows[0].Index);

                            selectedTab.Order.VALUE -= d;

                            foreach (Label l in selectedTab.Controls.OfType <Label>())
                            {
                                if (l.Name == "priceshow")
                                {
                                    l.Text = selectedTab.Order.VALUE + "€";
                                }
                            }

                            selectedTab.Order.EVENTS = String.Concat(selectedTab.Order.EVENTS, "§" + log.IDENTIFIER + " removeu " + nom + " (" + Time.get() + ")");
                        }
                    }
                }
            }
        }
Exemple #10
0
        private void addFatura(Boolean source, Order souce)
        {
            OrderTab tp = new OrderTab();

            tp.Padding  = new System.Windows.Forms.Padding(3);
            tp.Size     = new System.Drawing.Size(159, 280);
            tp.TabIndex = tabControl1.TabPages.Count + 1;
            tp.UseVisualStyleBackColor = true;

            if (source == false)
            {
                tp.Text = fatn + 1 + "";

                Order o = new Order();
                o.CREATORUSERID = log.IDENTIFIER;
                o.ORDERTYPE     = 0;
                o.ID            = fatn + 1;
                o.DATECREATED   = Time.get();
                o.DONE          = false;
                o.IDENTIFIER    = Databases.getIdentifier(Classes.Enum.IdentifierType.ORDER);

                tp.Order = o;

                tp.Empty = true;
            }
            else
            {
                tp.Empty            = false;
                tp.Text             = souce.ID + "";
                tp.Order            = souce;
                tp.IndexIdentifiers = Databases.uncompactList(tp.Order.INDEXLIST);
            }

            fatn += 1;

            DataGridView dv = new DataGridView();

            dv.AllowUserToAddRows          = false;
            dv.AllowUserToDeleteRows       = false;
            dv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            dv.EnableHeadersVisualStyles   = false;
            dv.AutoSizeColumnsMode         = DataGridViewAutoSizeColumnsMode.DisplayedCells;
            dv.Location          = new System.Drawing.Point(3, 3);
            dv.ReadOnly          = true;
            dv.RowHeadersVisible = false;
            dv.SelectionMode     = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
            dv.Size   = new System.Drawing.Size(146, 213);
            dv.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                               | System.Windows.Forms.AnchorStyles.Left)
                                                              | System.Windows.Forms.AnchorStyles.Right)));
            dv.KeyDown += (sender2, e2) => delProduct(sender2, e2, dv);

            if (source == true)
            {
                dv.DataSource = Databases.uncompactTable(souce.CONTENTLIST);
            }
            else
            {
                DataTable dbUsers = new DataTable();
                dbUsers.Columns.Add("Produto", typeof(string));
                dbUsers.Columns.Add("Valor", typeof(string));
                dv.DataSource = dbUsers;
            }

            tp.Controls.Add(dv);

            Label l = new Label();

            l.AutoSize = true;
            l.Font     = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            l.Location = new System.Drawing.Point(0, 218);
            l.Size     = new System.Drawing.Size(56, 20);
            l.Text     = "Total:";
            l.Anchor   = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            tp.Controls.Add(l);

            Label l2 = new Label();

            l2.AutoSize  = true;
            l2.Font      = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            l2.Location  = new System.Drawing.Point(54, 218);
            l2.Size      = new System.Drawing.Size(0, 24);
            l2.AllowDrop = true;
            l2.Anchor    = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            if (source == true)
            {
                l2.Text = souce.VALUE + "€";
            }
            else
            {
                l2.Text = "0€";
            }
            l2.Name = "priceshow";
            tp.Controls.Add(l2);

            PictureBox p3 = new PictureBox();

            p3.Anchor   = System.Windows.Forms.AnchorStyles.Bottom;
            p3.Image    = global::Retail2.Properties.Resources.info;
            p3.Location = new System.Drawing.Point(68, 244);
            p3.Name     = "pictureBox3";
            p3.Size     = new System.Drawing.Size(30, 30);
            p3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            p3.TabIndex = 5;
            p3.TabStop  = false;
            p3.Click   += (sender2, e2) => infoTab();
            tp.Controls.Add(p3);

            PictureBox p2 = new PictureBox();

            p2.Anchor   = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            p2.Image    = global::Retail2.Properties.Resources.close_fatura;
            p2.Location = new System.Drawing.Point(124, 244);
            p2.Name     = "pictureBox2";
            p2.Size     = new System.Drawing.Size(30, 30);
            p2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            p2.TabIndex = 4;
            p2.TabStop  = false;
            p2.Click   += (sender2, e2) => closeTab();
            tp.Controls.Add(p2);

            PictureBox p1 = new PictureBox();

            p1.Anchor   = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            p1.Image    = global::Retail2.Properties.Resources.add;
            p1.Location = new System.Drawing.Point(7, 244);
            p1.Name     = "pictureBox1";
            p1.Size     = new System.Drawing.Size(30, 30);
            p1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            p1.TabIndex = 3;
            p1.Click   += (sender2, e2) => addUnknownValue();
            p1.TabStop  = false;
            tp.Controls.Add(p1);

            tabControl1.TabPages.Add(tp);
        }
Exemple #11
0
        private void addItem(object sender2, EventArgs e2, String s)
        {
            if (tabControl1.SelectedTab == null)
            {
                Notification n = new Notification(Classes.Enum.AlertType.ERROR, "Nenhum pedido foi iniciado.", 1);
                n.ShowDialog(); return;
            }


            TabPage  tab         = tabControl1.SelectedTab;
            OrderTab selectedTab = (OrderTab)tab;

            selectedTab.Empty = false;

            foreach (DataGridView rb in selectedTab.Controls.OfType <DataGridView>())
            {
                Product p = ProductManager.getProduct(s);

                if (p.unlimitedSTOCK == false)
                {
                    if (p.STOCK >= 1)
                    {
                        p.STOCK -= 1;
                        ProductManager.editStockNumb(p);

                        DataTable dataTable = (DataTable)rb.DataSource;
                        DataRow   drToAdd   = dataTable.NewRow();

                        drToAdd["Produto"] = p.NAME;
                        drToAdd["Valor"]   = p.PRICE + "€";

                        dataTable.Rows.Add(drToAdd);
                        dataTable.AcceptChanges();

                        selectedTab.List = dataTable;

                        selectedTab.Order.VALUE += p.PRICE;

                        if (selectedTab.IndexIdentifiers == null)
                        {
                            selectedTab.IndexIdentifiers = new List <string>();
                        }
                        selectedTab.IndexIdentifiers.Add(p.IDENTIFIER);

                        foreach (Label l in selectedTab.Controls.OfType <Label>())
                        {
                            if (l.Name == "priceshow")
                            {
                                l.Text = selectedTab.Order.VALUE + "€";
                            }
                        }

                        if (selectedTab.Order.EVENTS == null)
                        {
                            selectedTab.Order.EVENTS = log.IDENTIFIER + " adicionou " + p.NAME + " (" + Time.get() + ")";
                        }
                        else
                        {
                            selectedTab.Order.EVENTS = String.Concat(selectedTab.Order.EVENTS, "§" + log.IDENTIFIER + " adicionou " + p.NAME + " (" + Time.get() + ")");
                        }
                    }
                    else
                    {
                        Notification n = new Notification(Classes.Enum.AlertType.ERROR, "Produto esgotado.", 1);
                        n.ShowDialog();
                    }
                }
                else
                {
                    DataTable dataTable = (DataTable)rb.DataSource;
                    DataRow   drToAdd   = dataTable.NewRow();

                    drToAdd["Produto"] = p.NAME;
                    drToAdd["Valor"]   = p.PRICE + "€";

                    dataTable.Rows.Add(drToAdd);
                    dataTable.AcceptChanges();

                    selectedTab.List = dataTable;

                    selectedTab.Order.VALUE += p.PRICE;

                    if (selectedTab.IndexIdentifiers == null)
                    {
                        selectedTab.IndexIdentifiers = new List <string>();
                    }
                    selectedTab.IndexIdentifiers.Add(p.IDENTIFIER);

                    foreach (Label l in selectedTab.Controls.OfType <Label>())
                    {
                        if (l.Name == "priceshow")
                        {
                            l.Text = selectedTab.Order.VALUE + "€";
                        }
                    }

                    if (selectedTab.Order.EVENTS == null)
                    {
                        selectedTab.Order.EVENTS = log.IDENTIFIER + " adicionou " + p.NAME + " (" + Time.get() + ")";
                    }
                    else
                    {
                        selectedTab.Order.EVENTS = String.Concat(selectedTab.Order.EVENTS, "§" + log.IDENTIFIER + " adicionou " + p.NAME + " (" + Time.get() + ")");
                    }
                }
            }
        }