Exemplo n.º 1
0
        private void btnGuardar_Click(object sender, System.EventArgs e)
        {
            try
            {
                RealizarValidaciones();

                if (sbErrores.Length > 0)
                {
                    throw new PagoAgilException(sbErrores.ToString());
                }

                Guardar();

                Generico.MostrarInformacion("Se guardaron correctamente los datos.");
                DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (PagoAgilException pEx)
            {
                Generico.MostrarAdvertencia(pEx.Message);
            }
            catch (Exception ex)
            {
                Generico.MostrarError(ex);
            }
        }
Exemplo n.º 2
0
        private void txtPorcentaje_TextChanged(object sender, EventArgs e)
        {
            try
            {
                System.Text.RegularExpressions.Regex regexCodPost = new System.Text.RegularExpressions.Regex(@"[0-9]+");
                if (!regexCodPost.Match(((TextBox)sender).Text).Success)
                {
                    Generico.MostrarAdvertencia("El porcentaje debe ser numerico");
                    buttonRendir.Enabled = false;
                    return;
                }

                int Porcentaje = int.Parse(((TextBox)sender).Text);
                if (Porcentaje > 100)
                {
                    Generico.MostrarAdvertencia("El porcentaje debe estar entres 0 y 100");
                    buttonRendir.Enabled = false;
                    return;
                }


                decimal ARendir = (this.Total * Porcentaje / 100);
                txtARendir.Text = ARendir.ToString();

                buttonRendir.Enabled = true;
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(txtUsuario.Text))
                {
                    throw new PagoAgilException("Debe ingresar el nombre de usuario.");
                }
                if (String.IsNullOrWhiteSpace(txtPassword.Text))
                {
                    throw new PagoAgilException("Debe ingresar su contraseña.");
                }

                _usuario = Usuario.Loguear(txtUsuario.Text, txtPassword.Text);

                DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (PagoAgilException exN)
            {
                Generico.MostrarAdvertencia(exN.Message);
            }
            catch (Exception ex)
            {
                Generico.MostrarError(ex);
            }
        }
Exemplo n.º 4
0
        protected override void AbrirElemento(DataGridViewRow dr)
        {
            string Id = dr.Cells["id"].Value.ToString();

            Factura.BorrarPago(int.Parse(Id));

            Generico.MostrarInformacion("Se guardaron correctamente los datos.");
            CargarGrilla();
        }
Exemplo n.º 5
0
 protected override void btnNuevo_Click(object sender, EventArgs e)
 {
     Pago.Pagar(Facturas, Suc, IdFormaPago.GetValueOrDefault());
     Generico.MostrarInformacion("La operacion fue exitosa");
     dgv.DataSource = null;
     dgv.Update();
     dgv.Refresh();
     Facturas = new List <Factura>();
 }
Exemplo n.º 6
0
 protected virtual void btnNuevo_Click(object sender, EventArgs e)
 {
     try
     {
         if (AgregarElemento())
         {
             CargarGrilla();
         }
     }
     catch
     {
         Generico.MostrarError("Ocurrió un error al intentar agregar un nuevo elemento.");
     }
 }
Exemplo n.º 7
0
        private void FormListaBase_Load(object sender, EventArgs e)
        {
            try
            {
                if (DesignMode)
                {
                    return;
                }

                Seleccionar = new DataGridViewButtonColumn()
                {
                    ReadOnly         = false,
                    DefaultCellStyle = new DataGridViewCellStyle()
                    {
                        Alignment = DataGridViewContentAlignment.MiddleCenter, NullValue = "Seleccionar", WrapMode = DataGridViewTriState.False
                    }
                };
                Eliminar = new DataGridViewButtonColumn()
                {
                    ReadOnly         = false,
                    DefaultCellStyle = new DataGridViewCellStyle()
                    {
                        Alignment = DataGridViewContentAlignment.MiddleCenter, NullValue = "Eliminar", WrapMode = DataGridViewTriState.False
                    }
                };
                InicializarFormulario();
                CargarGrilla();
                //agrego las 2 columas para poder abrir y borrar elementos
                dgv.Columns.AddRange(Seleccionar, Eliminar);

                foreach (DataGridViewColumn col in dgv.Columns)
                {
                    if (col.Name.ToUpper().EndsWith("ID"))
                    {
                        col.Visible = false;
                    }
                }
            }
            catch (PagoAgilException pEx)
            {
                Generico.MostrarError("Ocurrió un error al iniciar el formulario: " + pEx.Message);
            }
            catch (Exception ex)
            {
                Generico.MostrarError("Ocurrió un error al iniciar el formulario: " + ex.Message);
            }
        }
Exemplo n.º 8
0
        private void btnNuevo_Click(object sender, EventArgs e)
        {
            StringBuilder errs = new StringBuilder();

            System.Text.RegularExpressions.Regex regexNumero = new System.Text.RegularExpressions.Regex(@"[0-9]+");
            if (String.IsNullOrEmpty(textBoxCantidad.Text))
            {
                errs.AppendLine("Ingrese la cantidad");
            }
            else
            {
                if (!regexNumero.IsMatch(textBoxCantidad.Text))
                {
                    errs.AppendLine("La cantidad debe ser numerica");
                }
            }


            if (String.IsNullOrEmpty(textBoxMonto.Text))
            {
                errs.AppendLine("Ingrese el monto");
            }
            else
            {
                if (!regexNumero.IsMatch(textBoxMonto.Text))
                {
                    errs.AppendLine("El monto debe ser numerico");
                }
            }

            if (errs.Length > 0)
            {
                Generico.MostrarAdvertencia(errs.ToString());
            }

            ItemFactura ItemFactura = new ItemFactura(int.Parse(textBoxMonto.Text), int.Parse(textBoxCantidad.Text), Factura.Id.GetValueOrDefault());

            Factura.Items.Add(ItemFactura);
            Factura.AddedItems.Add(ItemFactura);

            loadItemsFacturaList();
        }
Exemplo n.º 9
0
        protected override void btnBuscar_Click(object sender, EventArgs e)
        {
            string Nro = txtNroFactura.Text;

            System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"[0-9]+");
            if (!regex.Match(Nro).Success&& Nro != "ALL")
            {
                Generico.MostrarAdvertencia("El Numero de factura debe ser numerico o 'ALL' para ver todas");
                return;
            }

            if (Nro == "ALL")
            {
                dgv.DataSource = Factura.getPagasNoRendidas("ALL");
            }
            else
            {
                dgv.DataSource = Factura.getPagasNoRendidas(Nro);
            }
        }
Exemplo n.º 10
0
        private void EditorBase_Load(object sender, EventArgs e)
        {
            if (DesignMode)
            {
                return;
            }
            try
            {
                if (_entidad == null)
                {
                    throw new Exception("No se ha indicado la entidad");
                }
                this.Text = _entidad.EsNuevo() ? "Nuevo registro" : "Consulta";

                InicializarFormulario();
            }
            catch (Exception ex)
            {
                Generico.MostrarError(ex);
                this.Close();
            }
        }
Exemplo n.º 11
0
        protected override void btnBuscar_Click(object sender, EventArgs e)
        {
            System.Text.RegularExpressions.Regex RegexNumero = new System.Text.RegularExpressions.Regex(@"[0-9]+");
            string Numero = textNumero.Text;

            if (!RegexNumero.Match(Numero).Success)
            {
                Generico.MostrarAdvertencia("El Numero de factura debe ser numerico");
                return;
            }

            DataTable DataTable = Factura.Buscar(null, null, Numero);

            if (DataTable.Rows.Count <= 0)
            {
                Generico.MostrarAdvertencia("No se encontro la factura ingresada");
                return;
            }

            int?idEmpresa = comboBoxEmpresa.SelectedItem == null ? null : (comboBoxEmpresa.SelectedItem as dynamic).Value;

            if (idEmpresa == null)
            {
                Generico.MostrarAdvertencia("Seleccione La empresa");
                return;
            }

            if (DataTable.Rows.Count > 1)
            {
                DataTable = Factura.Buscar(null, idEmpresa, Numero);
            }

            Factura Fac = new Factura(
                DataTable.Rows[0].Field <int>("id"),
                DataTable.Rows[0].Field <decimal>("Numero").ToString(),
                DataTable.Rows[0].Field <DateTime>("fecha"),
                DataTable.Rows[0].Field <DateTime>("Vencimiento"),
                DataTable.Rows[0].Field <int>("Cliente ID"),
                DataTable.Rows[0].Field <decimal>("Cliente DNI").ToString(),
                DataTable.Rows[0].Field <int>("Empresa ID"),
                DataTable.Rows[0].Field <string>("Cuit Empresa"),
                DataTable.Rows[0].Field <int?>("Pago ID"),
                DataTable.Rows[0].Field <int?>("Rendicion ID"));

            Fac.Importe = DataTable.Rows[0].Field <decimal>("Importe");

            if (Fac.IdPago != null)
            {
                Generico.MostrarAdvertencia("La factura ya esta paga");
                return;
            }

            if (idEmpresa != Fac.IdEmpresa)
            {
                Generico.MostrarAdvertencia("La empresa ingresada no coincide con la empresa de la factura guardada");
                return;
            }

            int?idCliente = comboBoxCliente.SelectedItem == null ? null : (comboBoxCliente.SelectedItem as dynamic).Value;

            if (idCliente == null)
            {
                Generico.MostrarAdvertencia("Seleccione el cliente");
                return;
            }
            if (idCliente != Fac.IdCliente)
            {
                Generico.MostrarAdvertencia("El cliente ingresado no coincide con el cliente de la factura guardada");
                return;
            }

            if (IdFormaPago == null)
            {
                int?idFormaPago = comboBoxFormaPago.SelectedItem == null ? null : (comboBoxFormaPago.SelectedItem as dynamic).Value;
                if (idFormaPago == null)
                {
                    Generico.MostrarAdvertencia("Seleccione la forma de pago");
                    return;
                }
                IdFormaPago = idFormaPago;
                comboBoxFormaPago.Enabled = false;
            }


            DateTime DateTime = dtpVencimiento.Value;

            if (DateTime.ToString("yyyy-MM-dd") != Fac.FechaVencimiento.Value.ToString("yyyy-MM-dd"))
            {
                Generico.MostrarAdvertencia("La fecha de vencimiento ingresada no coincide con la de la factura guardada");
                return;
            }

            System.Text.RegularExpressions.Regex RegexImporte = new System.Text.RegularExpressions.Regex(@"[0-9]+\,[0-9]+");
            string Importe = textBoxImporte.Text;

            if (!RegexImporte.Match(Importe).Success)
            {
                Generico.MostrarAdvertencia("El importe de factura debe ser numerico con ,");
                return;
            }
            if (Importe != Fac.Importe.ToString())
            {
                Generico.MostrarAdvertencia("El importe ingresado no coincide con el de la factura guardada");
                return;
            }

            if (Facturas.Find(f => f.Id == Fac.Id) != null)
            {
                Generico.MostrarAdvertencia("La factura ya fue ingresada");
                return;
            }

            if (Facturas.Find(f => f.IdCliente != Fac.IdCliente) != null)
            {
                Generico.MostrarAdvertencia("El cliente de la factura no coincide con las ya ingresadas");
                return;
            }

            Facturas.Add(Fac);

            dgv.DataSource = null;
            dgv.Update();
            dgv.Refresh();
            dgv.DataSource = Facturas;

            foreach (DataGridViewColumn col in dgv.Columns)
            {
                if (col.Name.ToUpper().StartsWith("ID"))
                {
                    col.Visible = false;
                }
            }
        }
Exemplo n.º 12
0
        protected override void btnBuscar_Click(object sender, EventArgs e)
        {
            System.Text.RegularExpressions.Regex regexYear = new System.Text.RegularExpressions.Regex(@"[0-9]{4}");
            if (!regexYear.Match(txtAnio.Text).Success)
            {
                Generico.MostrarAdvertencia("El año debe ser tener 4 numeros");
                return;
            }

            switch (comboBoxTipoListado.Text)
            {
            case "Porcentaje de facturas cobradas por empresa":
                switch (comboBoxTrimestre.Text)
                {
                case "1er":
                    dgv.DataSource = Listado.PorcentajeFacturasCobradasPorEmpresa(int.Parse(txtAnio.Text), 1, 2, 3);
                    break;

                case "2do":
                    dgv.DataSource = Listado.PorcentajeFacturasCobradasPorEmpresa(int.Parse(txtAnio.Text), 4, 5, 6);
                    break;

                case "3ro":
                    dgv.DataSource = Listado.PorcentajeFacturasCobradasPorEmpresa(int.Parse(txtAnio.Text), 7, 8, 9);
                    break;

                default:
                    dgv.DataSource = Listado.PorcentajeFacturasCobradasPorEmpresa(int.Parse(txtAnio.Text), 10, 11, 12);
                    break;
                }
                break;

            case "Empresas con mayor monto rendido":
                switch (comboBoxTrimestre.Text)
                {
                case "1er":
                    dgv.DataSource = Listado.EmpresasMayorMontoRendido(int.Parse(txtAnio.Text), 1, 2, 3);
                    break;

                case "2do":
                    dgv.DataSource = Listado.EmpresasMayorMontoRendido(int.Parse(txtAnio.Text), 4, 5, 6);
                    break;

                case "3ro":
                    dgv.DataSource = Listado.EmpresasMayorMontoRendido(int.Parse(txtAnio.Text), 7, 8, 9);
                    break;

                default:
                    dgv.DataSource = Listado.EmpresasMayorMontoRendido(int.Parse(txtAnio.Text), 10, 11, 12);
                    break;
                }
                break;

            case "Clientes con mas pagos":
                switch (comboBoxTrimestre.Text)
                {
                case "1er":
                    dgv.DataSource = Listado.ClientesConMasPagos(int.Parse(txtAnio.Text), 1, 2, 3);
                    break;

                case "2do":
                    dgv.DataSource = Listado.ClientesConMasPagos(int.Parse(txtAnio.Text), 4, 5, 6);
                    break;

                case "3ro":
                    dgv.DataSource = Listado.ClientesConMasPagos(int.Parse(txtAnio.Text), 7, 8, 9);
                    break;

                default:
                    dgv.DataSource = Listado.ClientesConMasPagos(int.Parse(txtAnio.Text), 10, 11, 12);
                    break;
                }
                break;

            default:
                switch (comboBoxTrimestre.Text)
                {
                case "1er":
                    dgv.DataSource = Listado.ClientesConMayorPorcentajeDeFacturasPagas(int.Parse(txtAnio.Text), 1, 2, 3);
                    break;

                case "2do":
                    dgv.DataSource = Listado.ClientesConMayorPorcentajeDeFacturasPagas(int.Parse(txtAnio.Text), 4, 5, 6);
                    break;

                case "3ro":
                    dgv.DataSource = Listado.ClientesConMayorPorcentajeDeFacturasPagas(int.Parse(txtAnio.Text), 7, 8, 9);
                    break;

                default:
                    dgv.DataSource = Listado.ClientesConMayorPorcentajeDeFacturasPagas(int.Parse(txtAnio.Text), 10, 11, 12);
                    break;
                }
                break;
                break;
            }
        }
Exemplo n.º 13
0
        private void FormPrincipal_Load(object sender, EventArgs e)
        {
            var dtPrivilegios = new DataTable();

            try
            {
                // Tengo que mostrar si tiene mas de un rol el pop up
                var dtRoles = _usuario.ObtenerRoles();

                if (dtRoles.Rows.Count > 1)
                {
                    var roles = new List <Rol>();

                    foreach (DataRow dr in dtRoles.Rows)
                    {
                        roles.Add(new Rol
                        {
                            Id     = (int)dr["Id"],
                            Nombre = dr["nombre"].ToString()
                        });
                    }

                    var formRoles = new FormSelRol(roles);

                    if (formRoles.ShowDialog() == DialogResult.OK)
                    {
                        dtPrivilegios = _usuario.ObtenerPrivilegios(formRoles.Rol.Id.Value);
                    }
                }
                else
                {
                    dtPrivilegios = _usuario.ObtenerPrivilegios();
                }

                if (dtPrivilegios == null || dtPrivilegios.Rows.Count == 0)
                {
                    throw new PagoAgilException("No tiene ningun privilegio");
                }

                foreach (DataRow dr in dtPrivilegios.Rows)
                {
                    TreeNode nodo = treeView1.Nodes.Add(dr["nombre"].ToString());
                    nodo.Tag = dr["formulario"];
                }

                // Hacemos lo mismo que rol, pero para sucursal
                var dtSucursales = _usuario.ObtenerSucursales();

                if (dtSucursales.Rows.Count > 1)
                {
                    var sucursales = new List <Sucursal>();

                    foreach (DataRow dr in dtSucursales.Rows)
                    {
                        sucursales.Add(new Sucursal
                        {
                            Id     = (int)dr["Id"],
                            Nombre = dr["nombre"].ToString()
                        });
                    }

                    var formSucursales = new FormSelSuc(sucursales);

                    if (formSucursales.ShowDialog() == DialogResult.OK)
                    {
                        _sucursal = formSucursales.Sucursal;
                    }
                }
                else
                {
                    if (dtSucursales == null || dtSucursales.Rows.Count == 0)
                    {
                        throw new PagoAgilException("No tiene ninguna sucursal asociada.");
                    }

                    var sucursal = new Sucursal()
                    {
                        Id     = (int)dtSucursales.Rows[0]["Id"],
                        Nombre = dtSucursales.Rows[0]["nombre"].ToString()
                    };

                    _sucursal = sucursal;
                }

                this.Text = String.Format("Pago Agil Frba (Main) - Usuario Logueado: {0} Sucursal: {1}", _usuario.Username, _sucursal.Nombre);
            }
            catch (Exception ex)
            {
                Generico.MostrarError(ex);
                this.Close();
            }
        }