Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (!Regex.IsMatch(txtNroFactura.Text, regexSoloNumeros))
            {
                MessageBox.Show("Ingrese un numero de factura valido");
            }
            else
            {
                if (this.facturaRepetida(decimal.Parse(txtNroFactura.Text)) == true)
                {
                    MessageBox.Show("La factura ya esta en la lista");
                }
                else
                {
                    Factura factura = new Factura();

                    int a;

                    if (!int.TryParse(txtNroFactura.Text, out a))
                    {
                        MessageBox.Show("La factura debe ser un numero");
                    }
                    else
                    {
                        if (FacturasRepository.GetFacturaByNro(decimal.Parse(txtNroFactura.Text)).EmpresaCuit == null)
                        {
                            MessageBox.Show("No existe una factura con ese numero, debe crearla primero");
                        }
                        else
                        {
                            factura = FacturasRepository.GetFacturaByNro(a);

                            factura.Monto = FacturasRepository.ImporteFactura(factura.Nro);

                            importePago += factura.Monto;

                            lblImporte.Text = "$" + importePago;

                            listBox1.Items.Add(factura);
                        }
                    }
                }
            }

            txtNroFactura.Text = "";

            txtNroFactura.Focus();
        }
Example #2
0
        private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
            //Editar
            if (e.ColumnIndex == 6)
            {
                decimal nroFacturaAEditar = (decimal)dataGridView1.Rows[e.RowIndex].Cells[0].Value;

                Factura factura = FacturasRepository.GetFacturaByNro(nroFacturaAEditar);

                if (factura.Estado == 0)
                {
                    EditFacturaForm editForm = new EditFacturaForm(factura);
                    this.Hide();
                    editForm.Show();
                }
                else
                {
                    MessageBox.Show("No se puede editar una factura que ya fue pagada o rendida");
                }
            }
            //Eliminar
            if (e.ColumnIndex == 7)
            {
                decimal nroFacturaAEliminar = (decimal)dataGridView1.Rows[e.RowIndex].Cells[0].Value;

                Factura factura = FacturasRepository.GetFacturaByNro(nroFacturaAEliminar);

                if (factura.Estado == 0)
                {
                    try
                    {
                        FacturasRepository.EliminarFactura(nroFacturaAEliminar);

                        MessageBox.Show("La factura fue eliminada");

                        dataGridView1.Refresh();
                    }
                    catch (Exception exc)
                    {
                        MessageBox.Show("Hubo un error al eliminar la factura");
                    }
                }
                else
                {
                    MessageBox.Show("No se puede eliminar una factura que ya fue pagada o rendida");
                }
            }
        }
Example #3
0
        private List <string> validarCamposCreateOrEdit()
        {
            List <string> errores = new List <string>();

            if (txtNroFactura.Text != "")
            {
                if (!Regex.IsMatch(txtNroFactura.Text, regexSoloNumeros))
                {
                    errores.Add("Ingrese un numero de factura valido");
                }
            }

            if (txtMotivo.Text == "")
            {
                errores.Add("Ingrese el motivo de la devolucion");
            }

            if (listBox1.Items.Count == 0)
            {
                errores.Add("Ingrese al menos una factura");
            }

            bool entro  = false;
            bool entro2 = false;
            bool entro3 = false;
            bool entro4 = false;
            bool entro5 = false;
            bool entro6 = false;

            foreach (Factura factura in listBox1.Items)
            {
                if (FacturasRepository.GetFacturaByNro(factura.Nro).EmpresaCuit == null && entro == false)
                {
                    errores.Add("No existe una factura con ese numero, debe crearla primero");

                    entro = true;
                }

                if (factura.Estado == (int)EstadoFactura.PendienteDePago && entro2 == false)
                {
                    errores.Add("Una o mas facturas estan pendiente de pago");

                    entro2 = true;
                }

                if (factura.Estado == (int)EstadoFactura.Rendida && entro3 == false)
                {
                    errores.Add("Una o mas facturas estan rendidas");

                    entro3 = true;
                }

                if (factura.ClienteDNI != ((ComboboxItem)cboClienteDNI.SelectedItem).Value && entro4 == false)
                {
                    errores.Add("Una o mas facturas no pertenecen al cliente");

                    entro4 = true;
                }

                if (factura.FechaVencimiento <= ConfiguracionFecha.FechaSistema && entro5 == false)
                {
                    errores.Add("Una o mas facturas ya vencieron");

                    entro5 = true;
                }

                if (EmpresasRepository.EmpresaEstaActiva(factura.EmpresaCuit) == false && entro6 == false)
                {
                    errores.Add("Una o mas facturas pertenecen a una empresa que esta inactiva");

                    entro6 = true;
                }
            }

            return(errores);
        }
Example #4
0
        private List <string> validarCamposCreateOrEdit()
        {
            List <string> errores = new List <string>();

            if (txtNroFactura.Text != "")
            {
                if (!Regex.IsMatch(txtNroFactura.Text, regexSoloNumeros))
                {
                    errores.Add("Ingrese un numero de factura valido");
                }
            }

            if (listBox1.Items.Count == 0)
            {
                errores.Add("Ingrese al menos una factura");
            }

            if (Sucursal.SucursalActual != null && Sucursal.SucursalActual.CodigoPostal != ((ComboboxItem)cboSucursal.SelectedItem).Value)
            {
                errores.Add("El usuario no pertenece a la sucursal seleccionada");
            }

            if (Sucursal.SucursalActual != null && Sucursal.SucursalActual.Activa == false)
            {
                errores.Add("La sucursal esta inactiva");
            }

            if (ClientesRepository.GetClienteByDNI(((ComboboxItem)cboClienteDNI.SelectedItem).Value).Activo == false)
            {
                errores.Add("El cliente esta inactivo");
            }

            bool entro  = false;
            bool entro2 = false;
            bool entro3 = false;
            bool entro4 = false;

            foreach (Factura factura in listBox1.Items)
            {
                if (factura.FechaVencimiento <= ConfiguracionFecha.FechaSistema)
                {
                    errores.Add("Una o mas facturas ya vencieron");
                }

                if (factura.Monto <= 0)
                {
                    errores.Add("Una o mas facturas tienen monto menor o igual a cero");
                }

                if (FacturasRepository.GetFacturaByNro(factura.Nro).EmpresaCuit == null && entro == false)
                {
                    errores.Add("No existe una factura con ese numero, debe crearla primero");

                    entro = true;
                }

                if (FacturasRepository.FacturaEstaPaga(factura.Nro) == true && entro2 == false)
                {
                    errores.Add("Una o mas facturas ya fueron pagadas");

                    entro2 = true;
                }

                if (FacturasRepository.FacturaEstaRendida(factura.Nro) == true && entro3 == false)
                {
                    errores.Add("Una o mas facturas ya fueron rendidas");

                    entro3 = true;
                }

                if (FacturasRepository.FacturaEsDeCliente(factura.Nro, ((ComboboxItem)cboClienteDNI.SelectedItem).Value) == false && entro4 == false)
                {
                    errores.Add("Una o mas facturas no pertenecen al cliente");

                    entro4 = true;
                }

                if (EmpresasRepository.EmpresaEstaActiva(FacturasRepository.GetFacturaByNro(factura.Nro).EmpresaCuit) == false)
                {
                    errores.Add("Una o mas facturas pertenecen a una empresa que esta inactiva");
                }
            }

            return(errores);
        }