Example #1
0
        private void UpdateSalary()
        {
            double     newSalary = Convert.ToDouble(this.salaryTxt.Text);
            Form_Login formLogin = new Form_Login(string.Format("Verificación De\nUsuario"));
            DarkForm   darkForm  = new DarkForm();

            if (this.employee.salary == newSalary)
            {
                return;
            }
            darkForm.Show();
            int      num1     = (int)formLogin.ShowDialog();
            Empleado empleado = new Empleado(formLogin.ID);

            if (formLogin.DialogResult == DialogResult.OK && empleado.isAdmin)
            {
                this.employee.updateSalary(newSalary);
                int num2 = (int)MessageBox.Show("Se ha actualizado el número el salario");
                this.salaryTxt.Text = newSalary.ToString("n2");
            }
            else if (formLogin.DialogResult == DialogResult.OK && !empleado.isAdmin && formLogin.ID > -1)
            {
                int num2 = (int)MessageBox.Show("No tiene los permisos necesarios para realizar esta acción");
                this.salaryTxt.Text = this.employee.salary.ToString("n2");
            }
            else
            {
                this.salaryTxt.Text = this.employee.salary.ToString("n2");
            }
            darkForm.Close();
        }
Example #2
0
        private void UpdatePosition()
        {
            Form_Login formLogin = new Form_Login(string.Format("Verificación De\nUsuario"));
            DarkForm   darkForm  = new DarkForm();

            if (this.employee.ID != 1)
            {
                darkForm.Show();
                int      num1     = (int)formLogin.ShowDialog();
                Empleado empleado = new Empleado(formLogin.ID);
                if (formLogin.DialogResult == DialogResult.OK && empleado.isAdmin)
                {
                    this.employee.UpdatePosition(this.comboBox1.SelectedIndex == 1);
                    int num2 = (int)MessageBox.Show("Se ha actualizado el puesto del empleado");
                }
                else if (formLogin.DialogResult == DialogResult.OK && !empleado.isAdmin && formLogin.ID > -1)
                {
                    int num2 = (int)MessageBox.Show("No tiene los permisos necesarios para realizar esta acción");
                    this.changingEmployee        = true;
                    this.comboBox1.SelectedIndex = this.employee.isAdmin ? 1 : 0;
                    this.changingEmployee        = false;
                }
                else
                {
                    this.changingEmployee        = true;
                    this.comboBox1.SelectedIndex = this.employee.isAdmin ? 1 : 0;
                    this.changingEmployee        = false;
                }
                darkForm.Close();
            }
            else
            {
                int num = (int)MessageBox.Show("No puede dejar de ser administrador");
            }
        }
Example #3
0
        private void ConfirmBtn_Click(object sender, EventArgs e)
        {
            dataGridView1.EndEdit();
            foreach (DataGridViewRow row in this.dataGridView1.Rows)
            {
                if (row.DefaultCellStyle.ForeColor.ToKnownColor() == Color.FromArgb(0, 0, 0, 0).ToKnownColor())
                {
                    MessageBox.Show("Aún quedan artículos sin revisar");
                    dataGridView1.CurrentCell = row.Cells["Cantidad"];
                    dataGridView1.BeginEdit(true);
                    return;
                }
            }
            Form_Login formLogin = new Form_Login(string.Format("Verificación De\nUsuario"));
            DarkForm   darkForm  = new DarkForm();

            darkForm.Show();
            if (formLogin.ShowDialog() == DialogResult.OK)
            {
                foreach (DataGridViewRow row in this.dataGridView1.Rows)
                {
                    if (row.DefaultCellStyle.ForeColor == Color.LimeGreen || row.DefaultCellStyle.ForeColor == Color.Tomato)
                    {
                        int correspondingIndex = this.getCorrespondingIndex(row.Index);
                        if (correspondingIndex > -1 && row.Cells["Cantidad"].Value != this.PO._products.Rows[correspondingIndex]["Cantidad"])
                        {
                            Producto producto = new Producto(row.Cells["Código de Barras"].Value.ToString());

                            double num = (Convert.ToDouble(row.Cells["Cantidad"].Value) - Convert.ToDouble(this.PO._products.Rows[correspondingIndex]["Cantidad"])) * Convert.ToDouble(row.Cells["Piezas por Caja"].Value);

                            if (num != 0.0)
                            {
                                Bodega depot = new Bodega(producto.defaultDepotID);
                                depot.UpdateProductQuantity(depot.getProductQuantity(producto.Barcode) + num, producto.Barcode);
                                this.PO.UpdateProductQunantity(producto.Barcode, Convert.ToDouble(row.Cells["Cantidad"].Value));
                            }
                        }
                    }
                }

                this.PO.delivered = true;
                this.PO._EmployeeWhoConfirmedThePurchaseID = formLogin.ID;
                this.PO.updateDeliveryStatus();
                this.updateValues();
                this.PO = new OrdenCompra(this.PO.ID);

                if (inASearch)
                {
                    searchPO();
                }
                else
                {
                    this.loadPurchases();
                }
            }
            darkForm.Close();
        }
Example #4
0
        private void deleteEmployeeBtn_Click(object sender, EventArgs e)
        {
            Form_Login formLogin = new Form_Login(string.Format("Verificación De\nUsuario"));

            if (MessageBox.Show("¿Desea borrar la información del empleado seleccionado?.\n La información como cliente no será borrada al " +
                                "realizar esta acción", "Borrar Empleado", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                if (formLogin.ShowDialog() == DialogResult.OK)
                {
                    employee.delete();
                    EmployeePanel.Hide();
                }
            }
        }
Example #5
0
        private void changeUserBtn_Click(object sender, EventArgs e)
        {
            Form_Login formLogin = new Form_Login("Iniciar Sesión");
            DarkForm   darkForm  = new DarkForm();

            if (MessageBox.Show(string.Format("¿Desea cambiar de usuario?.\nGuarde su información antes de continuar."), "", MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }
            darkForm.Show();

            if (formLogin.ShowDialog() == DialogResult.OK)
            {
                employee = new Empleado(formLogin.ID);
                displayHideTabs();

                homeBtn.BackColor = homeBtn.Parent.BackColor;//changing color to load home panel
                homeBtn_Click((object)this, (EventArgs)null);

                try { (ContainerPanel.Controls[0] as Panel_Inicio).EmployeeID = employee.ID; }
                catch (Exception) { }

                var count = Application.OpenForms.Count;
                for (int i = 0; i < count; i++)
                {
                    var item = Application.OpenForms[i];


                    if (item.GetType() == typeof(Panel_Ventas))
                    {
                        (item as Panel_Ventas).setEmployee(employee.ID);
                    }
                    if (item.GetType() == typeof(Panel_Productos))
                    {
                        (item as Panel_Productos).setEmployee(employee.ID);

                        if (count > Application.OpenForms.Count)
                        {
                            i--;
                            count = Application.OpenForms.Count;
                        }
                    }
                }
            }
            darkForm.Close();
        }
Example #6
0
        private void t_Tick(object sender, EventArgs e)
        {
            Form_Login           formLogin            = new Form_Login("Iniciar Sesión");
            SecondStartingWindow secondStartingWindow = new SecondStartingWindow();

            (sender as Timer).Stop();
            this.TopMost = false;
            if (Turno.isFirsUsageDateSet)
            {
                if (formLogin.ShowDialog() == DialogResult.OK)
                {
                    this.Hide();
                    new Form1(formLogin.ID).Show();
                }
                else
                {
                    this.Close();
                }
            }
            else
            {
                DarkForm darkForm = new DarkForm();
                panelEmpleados_nuevoEmpleado empleadosNuevoEmpleado = new panelEmpleados_nuevoEmpleado(false);
                this.Hide();
                darkForm.Show();
                if (empleadosNuevoEmpleado.ShowDialog() == DialogResult.OK)
                {
                    resetDefaultFonts();
                    if (secondStartingWindow.ShowDialog() == DialogResult.OK)
                    {
                        new Form1(empleadosNuevoEmpleado.newEmployeeID).Show();
                    }
                }
                else
                {
                    this.Close();
                }
                darkForm.Close();
            }
        }
Example #7
0
        private void Paybtn_Click(object sender, EventArgs e)
        {
            FormCambio formCambio = new FormCambio(this.employee.salary);
            //DarkForm darkForm = new DarkForm();
            Form_Login formLogin = new Form_Login(string.Format("Verificación De\nUsuario"));

            //darkForm.Show();
            formLogin.ShowDialog();
            Empleado empleado = new Empleado(formLogin.ID);

            if (formLogin.DialogResult == DialogResult.OK)
            {
                if (empleado.isAdmin)
                {
                    /*try
                     * {
                     *  this.printDocument1.PrinterSettings.PrinterName = this.printDialog1.PrinterSettings.PrinterName;
                     *  this.printDialog1.Document = this.printDocument1;
                     *  this.printDocument1.Print();
                     * }
                     * catch (InvalidPrinterException)
                     * {
                     *  int num2 = (int)MessageBox.Show("Registre una impresora para poder utilizar esta opción", "No se ha registrado impresora");
                     * }*/

                    openDrawer();
                    this.employee.paySalary();
                    formCambio.ShowDialog();
                    // goto label_7;
                }
            }
            if (formLogin.DialogResult == DialogResult.OK && !empleado.isAdmin)
            {
                MessageBox.Show("No dispone de los permisos necesarios para realizar el pago");
            }
        }
Example #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!Turno.shiftActive)
            {
                return;
            }
            DarkForm          darkForm          = new DarkForm();
            Form_Login        formLogin         = new Form_Login(string.Format("Verificación De\nUsuario"));
            FormShiftAddMoney formShiftAddMoney = new FormShiftAddMoney();

            darkForm.Show();
            formLogin.ShowDialog();

            Empleado empleado = new Empleado(formLogin.ID);


            if (formLogin.DialogResult == DialogResult.OK && empleado.isAdmin)
            {
                if (formShiftAddMoney.ShowDialog() == DialogResult.OK)
                {
                    //<<< step1 >>> --Start
                    //When outputting to a printer,a mouse cursor becomes like a hourglass.


                    try
                    {
                        if (m_Drawer != null)
                        {
                            //Open the device
                            //Use a Logical Device Name which has been set on the SetupPOS.
                            m_Drawer.Open();

                            //Get the exclusive control right for the opened device.
                            //Then the device is disable from other application.
                            m_Drawer.Claim(1000);

                            //Enable the device.
                            m_Drawer.DeviceEnabled = true;
                            //Open the drawer by using the "OpenDrawer" method.
                            m_Drawer.OpenDrawer();


                            m_Drawer.DeviceEnabled = false;
                            m_Drawer.Release();
                            m_Drawer.Close();
                        }
                        else
                        {
                            useDefaultPrinter();
                        }
                    }
                    catch (Exception)
                    {
                        if (m_Drawer != null)
                        {
                            m_Drawer.Release();
                            m_Drawer.Close();
                        }
                        useDefaultPrinter();
                    }
                    //<<<step1>>>--End

                    Turno.AddCashToDrawer(empleado.ID, formShiftAddMoney.cash, formShiftAddMoney.reason);
                    MessageBox.Show("Se realizó correctamente");
                    this.setGroupBoxInfo();
                }
            }
            else if (formLogin.DialogResult == DialogResult.OK && !empleado.isAdmin && formLogin.ID > -1)
            {
                MessageBox.Show("No tiene los permisos necesarios para realizar esta acción");
            }
            darkForm.Close();
        }