Exemple #1
0
        public void ValidateUser(string User, string Password, Form frm)
        {
            FormOrders formOrd = new FormOrders();
            FormLogin  formLog = new FormLogin();

            User Result = SelectUser(User, crypt.EncryptString(Password));

            if (Result != null)
            {
                frm.Hide();
                formOrd.ShowDialog();
            }
        }
Exemple #2
0
        public void Form1_Load(object sender, EventArgs e)
        {
            menuStrip1.ForeColor = Color.White;
            //AuxPay = true;

            if (ctrls != null)
            {
                panelOrder.Controls.Clear();

                for (int j = 0; j < ctrls.Count; j++)
                {
                    panelOrder.Controls.Add(ctrls[j]);
                }
            }
            FormOrder = this;

            if (ActualIdOrder != 0)
            {
                //MessageBox.Show(OrderNum.ToString());

                //OrderNum = objLINQ.GetNextOrderNum();

                NewOrder = objLINQ.SelectOrder(ActualIdOrder);
            }
            else
            {
                NewOrder = objLINQ.SelectUnsaved();

                if (NewOrder == null)
                {
                    NewOrder = objLINQ.SelectOrder(objLINQ.CreateOrder());
                }
            }
            OrderNum      = (int)NewOrder.OrderNum;
            ActualIdOrder = NewOrder.IdOrder;

            //lblOrderNum.Text = "Orden: " + objLINQ.GetOrderNum(OrderNum).ToString("0000");
            lblOrderNum.Text = "Orden: " + (OrderNum).ToString("0000");

            ctrls = new List <Control>();
            foreach (Control c in panelOrder.Controls)
            {
                ctrls.Add(c);
            }

            //NewOrder = objLINQ.SelectOrder(OrderNum);
            listOrderDetails = objLINQ.SelectOrderDetails(NewOrder.IdOrder);
            //objLINQ.CreateOrder();

            double amount = 0;
            int    zeros  = 0;

            for (int i = 0; i < listOrderDetails.Count; i++)
            {
                int contParcial = 0;
                for (int j = 0; j < AuxPartial.Count; j++)
                {
                    if (AuxPartial[j].IdOrderDetail == listOrderDetails[i].IdOrderDetail)
                    {
                        contParcial = AuxPartial[j].Qty;
                    }
                }

                if (listOrderDetails[i].Qty - contParcial > 0)
                {
                    Button button2 = new Button();
                    button2.Name = listOrderDetails[i].IdOrderDetail.ToString();
                    //button2.Text = "1x  |  Tacotote";
                    button2.Text      = (listOrderDetails[i].Qty - contParcial) + "x  |  " + objLINQ.GetMenuName(listOrderDetails[i].IdMenu);
                    button2.Left      = 20;
                    button2.Top       = 60 + ((i - zeros) * 55);
                    button2.Width     = 415;
                    button2.Height    = 45;
                    button2.Font      = new Font("Arial", 18, FontStyle.Regular);
                    button2.TextAlign = ContentAlignment.MiddleLeft;
                    button2.Click    += new EventHandler(button_Click);
                    panelOrder.Controls.Add(button2);

                    Button button3 = new Button();
                    button3.Name      = listOrderDetails[i].IdOrderDetail.ToString();
                    button3.Text      = "X";
                    button3.Left      = 445;
                    button3.Top       = 60 + ((i - zeros) * 55);
                    button3.Width     = 50;
                    button3.Height    = 45;
                    button3.Font      = new Font("Arial", 18, FontStyle.Bold);
                    button3.ForeColor = Color.White;
                    button3.BackColor = Color.FromArgb(217, 83, 79);
                    button3.Click    += new EventHandler(button_Click);
                    panelOrder.Controls.Add(button3);

                    amount += Convert.ToDouble(listOrderDetails[i].Amount);
                }
                else
                {
                    zeros++;
                }
            }

            int ordersHeight = 55 * (listOrderDetails.Count - zeros) + 10;

            if (AuxPay != true)
            {
                lblDivision.Location = new Point(-3, 60 + ordersHeight);

                Label label = new Label();
                label.Text   = "Total:";
                label.Left   = 20;
                label.Top    = 90 + ordersHeight;
                label.Width  = 100;
                label.Height = 40;
                label.Font   = new Font("Arial", 18, FontStyle.Regular);
                panelOrder.Controls.Add(label);

                Label label2 = new Label();
                label2.Text   = "$ " + amount.ToString("N");
                label2.Width  = 200;
                label2.Height = 40;
                label2.Left   = 120;
                label2.Top    = 85 + ordersHeight;
                label2.Font   = new Font("Arial", 20, FontStyle.Regular);
                panelOrder.Controls.Add(label2);


                Button btnFinish = new Button();
                btnFinish.Name      = "Save";
                btnFinish.Text      = "Guardar Orden";
                btnFinish.Left      = 20;
                btnFinish.Top       = 145 + ordersHeight;
                btnFinish.Width     = 475;
                btnFinish.Height    = 60;
                btnFinish.Font      = new Font("Arial", 18, FontStyle.Regular);
                btnFinish.FlatStyle = FlatStyle.System;
                btnFinish.Click    += new EventHandler(button_Click);
                panelOrder.Controls.Add(btnFinish);

                panelOrder.Height = 1 * 85 + 135 + ordersHeight;

                lblParcial.Visible   = false;
                lblDivision2.Visible = false;
                lblDivision.Height   = 10;
            }
            else
            {
                lblDivision.Location = new Point(-3, 60 + ordersHeight);
                lblDivision.Height   = 30;

                lblParcial.Location = new Point(3, 62 + ordersHeight);
                lblDivision2.Width  = 600;
                lblParcial.Visible  = true;

                double amountTotal = amount;
                amount = 0;
                for (int i = 0; i < AuxPartial.Count; i++)
                {
                    Button button2 = new Button();
                    button2.Name = AuxPartial[i].IdOrderDetail.ToString();
                    //button2.Text = "1x  |  Tacotote";
                    button2.Text      = AuxPartial[i].Qty + "x  |  " + objLINQ.GetMenuName(AuxPartial[i].IdMenu);
                    button2.Left      = 20;
                    button2.Top       = 50 + (i * 35) + ordersHeight + 50;
                    button2.Width     = 240;
                    button2.Height    = 30;
                    button2.Font      = new Font("Arial", 12, FontStyle.Regular);
                    button2.TextAlign = ContentAlignment.MiddleLeft;
                    button2.Click    += new EventHandler(button_Click);
                    panelOrder.Controls.Add(button2);

                    Button button3 = new Button();
                    button3.Name      = AuxPartial[i].IdOrderDetail.ToString();
                    button3.Text      = "X";
                    button3.Left      = 260;
                    button3.Top       = 50 + (i * 35) + ordersHeight + 50;
                    button3.Width     = 35;
                    button3.Height    = 30;
                    button3.Font      = new Font("Arial", 12, FontStyle.Bold);
                    button3.ForeColor = Color.White;
                    button3.BackColor = Color.FromArgb(217, 83, 79);
                    button3.Click    += new EventHandler(button_Click);
                    panelOrder.Controls.Add(button3);

                    amount += Convert.ToDouble(AuxPartial[i].Amount);
                }

                lblDivision2.Location = new Point(-3, 109 + ordersHeight + (35 * AuxPartial.Count));
                lblDivision2.Visible  = true;

                Label label = new Label();
                if (AuxPartial.Count > 0)
                {
                    label.Text = "Pago Parcial:";
                }
                else
                {
                    label.Text = "Pago Total:";
                }
                label.Left   = 20;
                label.Height = 40;
                label.Top    = 90 + ordersHeight + 49 + (35 * AuxPartial.Count);
                label.Width  = 200;
                label.Font   = new Font("Arial", 18, FontStyle.Regular);
                panelOrder.Controls.Add(label);

                Label label2 = new Label();
                if (AuxPartial.Count > 0)
                {
                    label2.Text = "$ " + amount.ToString("N");
                }
                else
                {
                    label2.Text = "$ " + amountTotal.ToString("N");
                }
                label2.Left   = 220;
                label2.Height = 40;
                label2.Width  = 400;
                label2.Top    = 85 + ordersHeight + 49 + (35 * AuxPartial.Count);
                label2.Font   = new Font("Arial", 20, FontStyle.Regular);
                panelOrder.Controls.Add(label2);


                Button btnFinish = new Button();
                btnFinish.Name      = "Print";
                btnFinish.Text      = "Imprimir Recibo";
                btnFinish.Left      = 20;
                btnFinish.Top       = 140 + ordersHeight + 49 + (35 * AuxPartial.Count);
                btnFinish.Width     = 475;
                btnFinish.Height    = 60;
                btnFinish.Font      = new Font("Arial", 18, FontStyle.Regular);
                btnFinish.FlatStyle = FlatStyle.System;
                btnFinish.Click    += new EventHandler(button_Click);
                panelOrder.Controls.Add(btnFinish);

                panelOrder.Height = 1 * 45 + 170 + ordersHeight + 49 + (35 * AuxPartial.Count);
            }


            ///////////////////////////////////////////////////////
            listComidas = objLINQ.SelectMenu(1);
            listBebidas = objLINQ.SelectMenu(2);

            //for (int i = 0; i < listComidas.Count; i++)
            //{
            //    ListViewItem lvItem = new ListViewItem();
            //    lvItem.SubItems[0].Text = listComidas[i].Description;
            //    lvItem.SubItems.Add(listComidas[i].Description);
            //    listViewMenu.Items.Add(lvItem);
            //}

            int cont = 0;

            int RowsMeals = 0;
            int ColsMeals = 0;

            RowsMeals = (int)Math.Round((decimal)listComidas.Count / 2, 0, MidpointRounding.AwayFromZero);
            ColsMeals = 2;

            menuStrip1.ForeColor = Color.White;

            int RowsDrinks = (int)Math.Round((decimal)listBebidas.Count / 2, 0, MidpointRounding.AwayFromZero);
            int ColsDrinks = 2;

            for (int row = 0; row < RowsMeals; row++)
            {
                for (int column = 0; column < ColsMeals; column++)
                {
                    Button button = new Button();
                    button.Name   = listComidas[cont].IdMenu.ToString();
                    button.Text   = listComidas[cont].Description.ToString();
                    button.Left   = 20 + column * 255;
                    button.Top    = 60 + row * 75;
                    button.Width  = 220;
                    button.Height = 50;
                    button.Font   = new Font("Arial", 18, FontStyle.Regular);
                    button.Click += new EventHandler(button_Click);
                    panelMeals.Controls.Add(button);

                    cont++;
                    if (cont == listComidas.Count)
                    {
                        break;
                    }
                }
                if (cont == listComidas.Count)
                {
                    break;
                }
            }

            panelMeals.Height = RowsMeals * 75 + 50;
            panelDrinks.Top   = RowsMeals * 75 + 80 + 80;

            cont = 0;

            for (int row = 0; row < RowsDrinks; row++)
            {
                for (int column = 0; column < ColsDrinks; column++)
                {
                    Button button = new Button();
                    button.Name   = listBebidas[cont].IdMenu.ToString();
                    button.Text   = listBebidas[cont].Description.ToString();
                    button.Left   = 20 + column * 255;
                    button.Top    = 60 + row * 75;
                    button.Width  = 220;
                    button.Height = 50;
                    button.Font   = new Font("Arial", 18, FontStyle.Regular);
                    button.Click += new EventHandler(button_Click);
                    panelDrinks.Controls.Add(button);

                    cont++;
                    if (cont == listBebidas.Count)
                    {
                        break;
                    }
                }
                if (cont == listBebidas.Count)
                {
                    break;
                }
            }

            panelDrinks.Height = RowsDrinks * 75 + 50;
        }