Exemple #1
0
        private void contrasena_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsDigit(e.KeyChar) && !char.IsWhiteSpace(e.KeyChar) && e.KeyChar != '\b')
                e.Handled = true;
            if (e.KeyChar == (char)13)
            {
                if (contrasena.Text == "" || string.IsNullOrWhiteSpace(contrasena.Text))
                    return;

                string contrasena1 = contrasena.Text;
                this.BuscarAlgoenTabla("SELECT * FROM USUARIOS WHERE CONTRASENA = " + contrasena1);
                if (dt.Rows.Count == 0)
                {
                    MessageBox.Show("Error contraseña incorrecta, porfavor verifique!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                string usuario = "- Nombre : ";
                usuario = dt.Rows[0]["NOMBRE"].ToString() + " " + dt.Rows[0]["APELLIDOP"].ToString() + " -Puesto: " + dt.Rows[0]["PUESTO"].ToString();
                Factura fac = new Factura(usuario);
                fac.Show();
                this.Hide();
            }
        }
Exemple #2
0
        private void DatosCliente_cancelar_Click(object sender, EventArgs e)
        {
            if (contrasena.Text == "" || string.IsNullOrWhiteSpace(contrasena.Text) )
                return;

            string contrasena1 = contrasena.Text;
            this.BuscarAlgoenTabla("SELECT * FROM USUARIOS WHERE CONTRASENA = " + contrasena1);
            if (dt.Rows.Count == 0)
            {
                MessageBox.Show("Error contraseña incorrecta, porfavor verifique!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string usuario = "- Nombre : ";
            usuario = dt.Rows[0]["NOMBRE"].ToString() + " " + dt.Rows[0]["APELLIDOP"].ToString() + " -Puesto: " + dt.Rows[0]["PUESTO"].ToString();
            Factura fac = new Factura(usuario);
            fac.Show();
            this.Hide();
        }
Exemple #3
0
 public void Add(Factura facturaToAdd)
 {
     Facturas.Add(facturaToAdd);
     Count++;
 }
        private void ToolstGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidarT())
                {
                    if (UP == true)
                    {
                        Factura   entidad    = new Factura();
                        FacturaBl actualizar = new FacturaBl();
                    }


                    if (UP == false)
                    {
                        FacturaBl        fac     = new FacturaBl();
                        Factura          entidad = new Factura();
                        DetalleFacturaBl dtf     = new DetalleFacturaBl();
                        DetalleFacturas  entidf  = new DetalleFacturas();
                        ProductosBl      pb      = new ProductosBl();
                        Productos        pd      = new Productos();

                        // entidad.ID_Producto = ID;
                        entidad.Fecha      = Convert.ToDateTime(toolStripStatusLabel1.Text);
                        entidad.Forma_Pago = CbxForamPago.Text;
                        entidad.Vendedor   = Usu.ToString();
                        entidad.Total      = double.Parse(LblTotaApagar.Text);
                        entidad.Id_Cliente = Id_Cliente;

                        fac.RegFactura(entidad);
                        foreach (DataGridViewRow row in dgvDetalleF.Rows)
                        {
                            entidf.Monto       = Convert.ToDouble(row.Cells["Precio_Producto"].Value);
                            entidf.Cantidad    = Convert.ToInt16(row.Cells["Fecha"].Value);
                            entidf.Itbis       = Convert.ToDouble(row.Cells["Generales"].Value);
                            entidf.ID_Producto = Convert.ToInt16(row.Cells["IDProducto"].Value);

                            var dt  = fac.ObtenerIDFactura(Id_Cliente, Convert.ToDouble(LblTotaApagar.Text));
                            var Id1 = dt.Rows[0]["ID_Factura"];
                            entidf.ID_Factura = Convert.ToInt16(Id1);
                            ID_Factura        = Convert.ToInt16(Id1);

                            pd.ID_Producto = Convert.ToInt16(row.Cells["IDProducto"].Value);;
                            pd.Inventario  = Convert.ToInt16(row.Cells["Fecha"].Value);
                            pb.ActualizarInventario(pd);
                            dtf.RegDetalleFactura(entidf);
                        }
                        //  dgvClientes.Update();
                        // LlenarGrid();
                        MessageBox.Show("Registro agregado con exito.", "Agregado", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                        ToolstNuevo.PerformClick();
                        if (MessageBox.Show("¿Desea imprimir la factura? ", "Imprimir", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                        {
                            tsImprimir.PerformClick();
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Hay campos que son obligatorios que se encuentran vacios.", "Error de validación", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    if (string.IsNullOrWhiteSpace(TxtProducto.Text))
                    {
                        errorProvider1.SetError(TxtProducto, "Este Campo es requerido");
                    }
                    if (string.IsNullOrWhiteSpace(TxtCliente.Text))
                    {
                        errorProvider1.SetError(TxtCliente, "Este Campo es requerido");
                    }
                    if (string.IsNullOrWhiteSpace(CbxForamPago.Text))
                    {
                        errorProvider1.SetError(CbxForamPago, "Este Campo es requerido");
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #5
0
        private void dgv_buscar_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (modificar == 1)
            {
                Factura factura = (Factura)this.Owner;

                try
                {
                    if (factura != null)
                    {
                        // factura.agregarProductoFactura(int.Parse(dgv_buscar.Rows[0].Cells[0].Value.ToString()), dgv_buscar.Rows[0].Cells[1].Value.ToString(), 1, double.Parse(dgv_buscar.Rows[0].Cells[3].Value.ToString()));
                        factura.lbl_nombreCliente.Text = dgv_buscar.Rows[dgv_buscar.CurrentCell.RowIndex].Cells[1].Value.ToString();
                        factura.clienteId = dgv_buscar.Rows[dgv_buscar.CurrentCell.RowIndex].Cells[0].Value.ToString();
                        factura.cliente   = dgv_buscar.Rows[dgv_buscar.CurrentCell.RowIndex].Cells[1].Value.ToString();
                        modificar         = 0;
                        this.Close();

                        /* for (int i = 0; i <= (factura.dgv_factura.Rows.Count - 1); ++i)
                         * {
                         *   factura.subTotal = factura.subTotal + ((float.Parse(factura.dgv_factura.Rows[i].Cells[3].Value.ToString())) * (int.Parse(factura.dgv_factura.Rows[i].Cells[2].Value.ToString())));
                         *
                         * }
                         * factura.lbl_total.Text = factura.subTotal.ToString();*/
                    }
                    /**/

                    else
                    {
                        MessageBox.Show("No Disponible");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            else if (modificar == 0)
            {
                // se declara  (Factura)this.Owner; para que pueda enviar de regreso a Factura como padre y no como nueva form en Factura se delcara BuscarProducto.ShowDialog(this);
                Factura factura = (Factura)this.Owner;
                Login   log     = new Login();


                try
                {
                    if (factura != null)
                    {
                        if (checkBoxDescuento.Checked)
                        {
                            factura.agregarProductoFactura(int.Parse(dgv_buscar.Rows[0].Cells[0].Value.ToString()), dgv_buscar.Rows[0].Cells[1].Value.ToString(), 1, double.Parse(dgv_buscar.Rows[0].Cells[4].Value.ToString()));
                            this.Close();
                        }
                        else
                        {
                            factura.agregarProductoFactura(int.Parse(dgv_buscar.Rows[0].Cells[0].Value.ToString()), dgv_buscar.Rows[0].Cells[1].Value.ToString(), 1, double.Parse(dgv_buscar.Rows[0].Cells[3].Value.ToString()));
                            this.Close();

                            /* for (int i = 0; i <= (factura.dgv_factura.Rows.Count - 1); ++i)
                             * {
                             *   factura.subTotal = factura.subTotal + ((float.Parse(factura.dgv_factura.Rows[i].Cells[3].Value.ToString())) * (int.Parse(factura.dgv_factura.Rows[i].Cells[2].Value.ToString())));
                             *
                             * }
                             * factura.lbl_total.Text = factura.subTotal.ToString();*/
                        }
                    }



                    else
                    {
                        MessageBox.Show("No Disponible");
                    }
                }
Exemple #6
0
 public int generaFactura(Factura factura)
 {
     // TODO: ...
     return 1;
 }