Ejemplo n.º 1
0
        public void Actualizar_Montos()
        {
            BD_JSYSEntities  db          = new BD_JSYSEntities();
            FACTURAS         obj_factura = new FACTURAS();
            DETALLES_CUOTAS  obj_detalle = new DETALLES_CUOTAS();
            RECIBOS_COBRADOS obj_recibo  = new RECIBOS_COBRADOS();

            //actualizar detalle cxc
            if (ch_pago_total.Checked == true)
            {
                obj_detalle.MONTO_PAGADO    = Convert.ToDecimal(txt_monto_cuota.Text);
                obj_detalle.MONTO_PENDIENTE = 0;
                obj_recibo.VALOR_PAGADO     = Convert.ToDecimal(txt_monto_cuota.Text);
                obj_factura.MONTO_PAGADO    = Convert.ToDecimal(txt_monto_cuota.Text);
                obj_recibo.VALOR_PENDIENTE  = 0;
            }
            else if (ch_pago_total.Checked == false && Convert.ToDecimal(txt_valor_a_pagar.Text) >= Convert.ToDecimal(txt_monto_cuota.Text))
            {
                obj_detalle.MONTO_PAGADO    = Convert.ToDecimal(txt_monto_cuota.Text);
                obj_detalle.MONTO_PENDIENTE = 0;
                obj_recibo.VALOR_PAGADO     = Convert.ToDecimal(txt_monto_cuota.Text);
                obj_factura.MONTO_PAGADO    = Convert.ToDecimal(txt_monto_cuota.Text);
                obj_recibo.VALOR_PENDIENTE  = 0;
            }
            else if (ch_pago_total.Checked == false && Convert.ToDecimal(txt_valor_a_pagar.Text) < Convert.ToDecimal(txt_monto_cuota.Text))
            {
                obj_detalle.MONTO_PAGADO    = Convert.ToDecimal(txt_valor_a_pagar.Text);
                obj_detalle.MONTO_PENDIENTE = Convert.ToDecimal(txt_monto_cuota.Text) - Convert.ToDecimal(txt_valor_a_pagar.Text);
                obj_recibo.VALOR_PAGADO     = Convert.ToDecimal(txt_valor_a_pagar.Text);
                obj_factura.MONTO_PAGADO    = Convert.ToDecimal(txt_valor_a_pagar.Text);
                obj_recibo.VALOR_PENDIENTE  = Convert.ToDecimal(txt_monto_cuota.Text) - Convert.ToDecimal(txt_valor_a_pagar.Text);
            }

            obj_detalle.NUMERO_CUOTA = Convert.ToInt32(txt_no_cuota.Text);
            obj_detalle.ID_FACTURA   = Convert.ToInt32(txt_no_factura.Text);
            S_Factura.Cobrar_Cuota(obj_detalle);

            //insertar recibo
            obj_recibo.ANULADO_POR = "";
            obj_recibo.CREADO_POR  = S_Utilidades.Datos_Usuario.USUARIO;
            int ID_FACTURA     = Convert.ToInt32(txt_no_factura.Text);
            var obj_encabezado = db.ENCABEZADO_CUOTAS.Where(a => a.ID_FACTURA == ID_FACTURA).Single();

            obj_recibo.CANTIDAD_CUOTAS = obj_encabezado.CANTIADA_CUOTA;
            obj_recibo.CUOTA_COBRADA   = Convert.ToInt32(txt_no_cuota.Text);
            obj_recibo.ESTADO          = "V";
            obj_recibo.FECHA_ANULADO   = "";
            obj_recibo.FECHA_CREADO    = DateTime.Now;
            obj_recibo.ID_FACTURA      = ID_FACTURA;
            var obj_fact = db.FACTURAS.Where(f => f.ID_FACTURA == ID_FACTURA).Single();

            obj_recibo.NOTA_ANULACION = "";
            obj_recibo.VALOR_CUOTA    = Convert.ToDecimal(txt_monto_cuota.Text);
            S_Factura.Insertar_Recibo_Cobros(obj_recibo);

            //actualizar monto factura
            obj_factura.ID_FACTURA = ID_FACTURA;
            S_Factura.Actualizar_Montos_Factura(obj_factura);
        }
Ejemplo n.º 2
0
        private void btn_anular_Click(object sender, EventArgs e)
        {
            if (DG.Rows.Count == 0)
            {
                return;
            }
            if (txt_observacion.Text == "")
            {
                S_Utilidades.Mensaje_Informacion("La Observación es Obligatoria");
                return;
            }
            DialogResult Resultado = MessageBox.Show("Deseas Anular Recibo(s)", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (Resultado == DialogResult.Yes)
            {
                FACTURAS         obj_factura = new FACTURAS();
                DETALLES_CUOTAS  obj_detelle = new DETALLES_CUOTAS();
                RECIBOS_COBRADOS obj_recibo  = new RECIBOS_COBRADOS();

                foreach (DataGridViewRow row in DG.Rows)
                {
                    if (Convert.ToBoolean(row.Cells[6].Value) == true)
                    {
                        int     id_factura   = Convert.ToInt32(row.Cells[2].Value);
                        decimal valor_pagado = Convert.ToDecimal(row.Cells[4].Value);

                        obj_factura.ID_FACTURA   = id_factura;
                        obj_factura.MONTO_PAGADO = valor_pagado;
                        S_Factura.Actualizar_Montos_Factura_Recibo_Anulado(obj_factura);

                        obj_detelle.ID_FACTURA   = id_factura;
                        obj_detelle.NUMERO_CUOTA = Convert.ToInt32(row.Cells[3].Value);
                        obj_detelle.MONTO_PAGADO = valor_pagado;
                        S_Factura.Anular_Detalle_Cuota(obj_detelle);

                        obj_recibo.ID_RECIBO      = Convert.ToInt32(row.Cells[0].Value);
                        obj_recibo.ESTADO         = "A";
                        obj_recibo.FECHA_ANULADO  = DateTime.Now.ToString();
                        obj_recibo.ANULADO_POR    = S_Utilidades.Datos_Usuario.USUARIO;
                        obj_recibo.NOTA_ANULACION = txt_observacion.Text.Trim();
                        S_Factura.Anular_Recibo(obj_recibo);
                    }
                }

                S_Utilidades.Mensaje_Informacion("Recibos Anulados Correctamente");
                Close();
            }
        }
Ejemplo n.º 3
0
        public static void Insertar_Detalle_Cuota(DETALLES_CUOTAS obj)
        {
            D_Factura Metodo = new D_Factura();

            Metodo.Insertar_Detalle_Cuota(obj);
        }
Ejemplo n.º 4
0
        public static void Actualizar_Cuotas(DETALLES_CUOTAS obj)
        {
            D_Factura Metodo = new D_Factura();

            Metodo.Actualizar_Cuotas(obj);
        }
Ejemplo n.º 5
0
        public static void Cobrar_Cuota(DETALLES_CUOTAS obj)
        {
            D_Factura Metodo = new D_Factura();

            Metodo.Cobrar_Cuota(obj);
        }
Ejemplo n.º 6
0
        public void Actualizar()
        {
            try
            {
                BD_JSYSEntities db = new BD_JSYSEntities();
                //insertar_factura
                FACTURAS obj_factura = new FACTURAS();
                obj_factura.ID_FACTURA       = Convert.ToInt32(txt_numero_factura.Text);
                obj_factura.ID_COBRADOR      = Convert.ToInt32(cb_cobrador.SelectedValue);
                obj_factura.ID_ESTADO        = Convert.ToInt32(cb_estado.SelectedValue);
                obj_factura.MONTO_TOTAL      = Convert.ToDecimal(txt_total.Text);
                obj_factura.NUMERO_LOTERIA   = cb_numero_loteria.Text;
                obj_factura.OBSERVACION      = txt_observacion.Text.Trim();
                obj_factura.GARANTIA1        = txt_garantia_1.Text.Trim();
                obj_factura.GARANTIA2        = txt_garantia_2.Text.Trim();
                obj_factura.GARANTIA3        = txt_garantia_3.Text.Trim();
                obj_factura.GARANTIA4        = txt_garantia_4.Text.Trim();
                obj_factura.GARANTIA5        = txt_garantia_5.Text.Trim();
                obj_factura.GARANTIA6        = txt_garantia_6.Text.Trim();
                obj_factura.GARANTIA7        = txt_garantia_7.Text.Trim();
                obj_factura.RUTA             = cb_ruta.Text;
                obj_factura.MONTO_DESCONTADO = Convert.ToDecimal(txt_descuento.Text);

                var factura = db.FACTURAS.Where(f => f.ID_FACTURA == obj_factura.ID_FACTURA).SingleOrDefault();
                if ((factura.FECHA_DESCUENTO == null || factura.FECHA_DESCUENTO.ToString() == "") && obj_factura.MONTO_DESCONTADO > 0)
                {
                    obj_factura.FECHA_DESCUENTO = DateTime.Now;
                }
                else
                {
                    obj_factura.FECHA_DESCUENTO = factura.FECHA_DESCUENTO;
                }
                S_Factura.Actualizar_Factura(obj_factura);

                if (cb_recalcular.Text == "Si")
                {
                    //insertar encabezado cuota
                    ENCABEZADO_CUOTAS obj_encabezado_cuota = new ENCABEZADO_CUOTAS();
                    obj_encabezado_cuota.CANTIADA_CUOTA      = Convert.ToInt32(txt_cantidad_cuota.Text);
                    obj_encabezado_cuota.ID_FACTURA          = Convert.ToInt32(txt_numero_factura.Text);
                    obj_encabezado_cuota.MODO_CALCULO        = cb_modo_calculo.Text;
                    obj_encabezado_cuota.FECHA_PRIMERA_CUOTA = dt_fecha_primera_cuota.Value;
                    S_Factura.Actualizar_Encabezado_Cuota(obj_encabezado_cuota);

                    //insertar detalles cuotas
                    S_Factura.Eliminar_Cuotas(Convert.ToInt32(txt_numero_factura.Text));



                    DETALLES_CUOTAS obj_detalle = new DETALLES_CUOTAS();

                    obj_detalle.ID_FACTURA   = Convert.ToInt32(txt_numero_factura.Text);
                    obj_detalle.RE_CALCULADO = "SI";

                    S_Factura.Actualizar_Cuotas(obj_detalle);

                    foreach (DataGridViewRow row in dg_detalle_cuotas.Rows)
                    {
                        DETALLES_CUOTAS obj_detalle_cuotas = new DETALLES_CUOTAS();

                        obj_detalle_cuotas.ID_FACTURA      = Convert.ToInt32(txt_numero_factura.Text);
                        obj_detalle_cuotas.NUMERO_CUOTA    = Convert.ToInt32(row.Cells[0].Value);
                        obj_detalle_cuotas.FECHA           = Convert.ToDateTime(row.Cells[1].Value);
                        obj_detalle_cuotas.MONTO_CUOTA     = Convert.ToDecimal(row.Cells[2].Value);
                        obj_detalle_cuotas.MONTO_PAGADO    = 0;
                        obj_detalle_cuotas.MONTO_PENDIENTE = Convert.ToDecimal(row.Cells[2].Value);
                        obj_detalle_cuotas.RE_CALCULADO    = "NO";
                        S_Factura.Insertar_Detalle_Cuota(obj_detalle_cuotas);
                    }
                }

                Close();
            }
            catch (Exception ex)
            {
                S_Utilidades.Mensaje_Error(ex.Message);
            }
        }
Ejemplo n.º 7
0
        public void Insertar()
        {
            try
            {
                //insertar_factura
                FACTURAS obj_factura = new FACTURAS();
                obj_factura.CREADO_POR          = S_Utilidades.Datos_Usuario.USUARIO;
                obj_factura.CAMBIO_ESTADO_POR   = "";
                obj_factura.FECHA               = dt_fecha_factura.Value;
                obj_factura.FECHA_CAMBIO_ESTADO = "";
                obj_factura.FECHA_CREADO        = DateTime.Now;
                obj_factura.REFERENCIA          = cb_cliente.SelectedValue.ToString();
                obj_factura.ID_COBRADOR         = Convert.ToInt32(cb_cobrador.SelectedValue);
                obj_factura.ID_ESTADO           = Convert.ToInt32(cb_estado.SelectedValue);
                obj_factura.MONTO_PAGADO        = 0;
                obj_factura.MONTO_PENDIENTE     = Convert.ToDecimal(txt_total.Text);
                obj_factura.MONTO_TOTAL         = Convert.ToDecimal(txt_total.Text);
                obj_factura.NOTA_CAMBIO_ESTADO  = "";
                obj_factura.NUMERO_LOTERIA      = cb_numero_loteria.Text;
                obj_factura.OBSERVACION         = txt_observacion.Text.Trim();
                obj_factura.GARANTIA1           = txt_garantia_1.Text.Trim();
                obj_factura.GARANTIA2           = txt_garantia_2.Text.Trim();
                obj_factura.GARANTIA3           = txt_garantia_3.Text.Trim();
                obj_factura.GARANTIA4           = txt_garantia_4.Text.Trim();
                obj_factura.GARANTIA5           = txt_garantia_5.Text.Trim();
                obj_factura.GARANTIA6           = txt_garantia_6.Text.Trim();
                obj_factura.GARANTIA7           = txt_garantia_7.Text.Trim();
                obj_factura.MONTO_DESCONTADO    = 0;
                obj_factura.RUTA = cb_ruta.Text;
                S_Factura.Insertar_Factura(obj_factura);

                BD_JSYSEntities db = new BD_JSYSEntities();

                //obtener ultimo numero de factura
                int id_factura = db.FACTURAS.Max(m => m.ID_FACTURA);


                //insertar encabezado cuota
                ENCABEZADO_CUOTAS obj_encabezado_cuota = new ENCABEZADO_CUOTAS();
                obj_encabezado_cuota.CANTIADA_CUOTA      = Convert.ToInt32(txt_cantidad_cuota.Text);
                obj_encabezado_cuota.ID_FACTURA          = id_factura;
                obj_encabezado_cuota.MODO_CALCULO        = cb_modo_calculo.Text;
                obj_encabezado_cuota.FECHA_PRIMERA_CUOTA = dt_fecha_primera_cuota.Value;
                S_Factura.Insertar_Encabezado_Cuota(obj_encabezado_cuota);

                //insertar detalles cuotas
                foreach (DataGridViewRow row in dg_detalle_cuotas.Rows)
                {
                    DETALLES_CUOTAS obj_detalle_cuotas = new DETALLES_CUOTAS();

                    obj_detalle_cuotas.ID_FACTURA      = id_factura;
                    obj_detalle_cuotas.NUMERO_CUOTA    = Convert.ToInt32(row.Cells[0].Value);
                    obj_detalle_cuotas.FECHA           = Convert.ToDateTime(row.Cells[1].Value);
                    obj_detalle_cuotas.MONTO_CUOTA     = Convert.ToDecimal(row.Cells[2].Value);
                    obj_detalle_cuotas.MONTO_PAGADO    = 0;
                    obj_detalle_cuotas.MONTO_PENDIENTE = Convert.ToDecimal(row.Cells[2].Value);
                    obj_detalle_cuotas.RE_CALCULADO    = "NO";
                    S_Factura.Insertar_Detalle_Cuota(obj_detalle_cuotas);
                }
                Close();
            }
            catch (Exception ex)
            {
                S_Utilidades.Mensaje_Error(ex.Message);
            }
        }
Ejemplo n.º 8
0
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            if (txt_total.TextLength == 0)
            {
                S_Utilidades.Mensaje_Informacion("No hay Cuota(s) Seleccionada(s)");
                return;
            }

            DETALLES_CUOTAS  obj_detalle = new DETALLES_CUOTAS();
            RECIBOS_COBRADOS obj_recibo  = new RECIBOS_COBRADOS();
            FACTURAS         obj_factura = new FACTURAS();

            try
            {
                foreach (DataGridViewRow row in dg_detalle_cuotas.Rows)
                {
                    obj_detalle.ID_FACTURA = Convert.ToInt32(Txt_ID.Text);
                    if (Convert.ToBoolean(row.Cells[3].Value) == true && Convert.ToDecimal(row.Cells[4].Value) > 0)
                    {
                        if (Convert.ToDecimal(row.Cells[4].Value) > Convert.ToDecimal(row.Cells[2].Value))
                        {
                            //actualizar totales de cuotas
                            obj_detalle.MONTO_PAGADO    = Convert.ToDecimal(row.Cells[2].Value);
                            obj_detalle.MONTO_PENDIENTE = 0;
                            obj_detalle.NUMERO_CUOTA    = Convert.ToInt32(row.Cells[0].Value);
                            S_Factura.Cobrar_Cuota(obj_detalle);

                            //actualizar totales de factura
                            obj_factura.ID_FACTURA   = Convert.ToInt32(Txt_ID.Text);
                            obj_factura.MONTO_PAGADO = obj_detalle.MONTO_PAGADO;
                            S_Factura.Actualizar_Montos_Factura(obj_factura);

                            //asignar montos de recibos
                            obj_recibo.VALOR_PAGADO    = Convert.ToDecimal(row.Cells[2].Value);
                            obj_recibo.VALOR_PENDIENTE = 0;
                        }
                        else
                        {
                            //actualizar totales de cuotas
                            obj_detalle.MONTO_PAGADO    = Convert.ToDecimal(row.Cells[4].Value);
                            obj_detalle.MONTO_PENDIENTE = Convert.ToDecimal(row.Cells[2].Value) - Convert.ToDecimal(row.Cells[4].Value);
                            obj_detalle.NUMERO_CUOTA    = Convert.ToInt32(row.Cells[0].Value);
                            S_Factura.Cobrar_Cuota(obj_detalle);

                            //actualizar totales de factura
                            obj_factura.ID_FACTURA   = Convert.ToInt32(Txt_ID.Text);
                            obj_factura.MONTO_PAGADO = obj_detalle.MONTO_PAGADO;
                            S_Factura.Actualizar_Montos_Factura(obj_factura);

                            //asignar montos de recibos
                            obj_recibo.VALOR_PAGADO    = Convert.ToDecimal(row.Cells[4].Value);
                            obj_recibo.VALOR_PENDIENTE = obj_detalle.MONTO_PENDIENTE;
                        }
                    }
                    else if (Convert.ToBoolean(row.Cells[3].Value) == true)
                    {
                        //actualizar totales de cuotas
                        obj_detalle.MONTO_PAGADO    = Convert.ToDecimal(row.Cells[2].Value);
                        obj_detalle.MONTO_PENDIENTE = 0;
                        obj_detalle.NUMERO_CUOTA    = Convert.ToInt32(row.Cells[0].Value);
                        S_Factura.Cobrar_Cuota(obj_detalle);

                        //actualizar totales de factura
                        obj_factura.ID_FACTURA   = Convert.ToInt32(Txt_ID.Text);
                        obj_factura.MONTO_PAGADO = obj_detalle.MONTO_PAGADO;
                        S_Factura.Actualizar_Montos_Factura(obj_factura);

                        //asignar montos de recibos
                        obj_recibo.VALOR_PAGADO    = Convert.ToDecimal(row.Cells[2].Value);
                        obj_recibo.VALOR_PENDIENTE = 0;
                    }

                    if (Convert.ToBoolean(row.Cells[3].Value) == true)
                    {
                        //insertar recibos de cobros
                        obj_recibo.ANULADO_POR = "";
                        obj_recibo.CREADO_POR  = S_Utilidades.Datos_Usuario.USUARIO;
                        int ID_FACTURA     = Convert.ToInt32(Txt_ID.Text);
                        var obj_encabezado = db.ENCABEZADO_CUOTAS.Where(a => a.ID_FACTURA == ID_FACTURA).Single();
                        obj_recibo.CANTIDAD_CUOTAS = obj_encabezado.CANTIADA_CUOTA;
                        obj_recibo.CUOTA_COBRADA   = Convert.ToInt32(row.Cells[0].Value);
                        obj_recibo.ESTADO          = "V";
                        obj_recibo.FECHA_ANULADO   = "";
                        obj_recibo.FECHA_CREADO    = DateTime.Now;
                        obj_recibo.ID_FACTURA      = Convert.ToInt32(Txt_ID.Text);
                        var obj_fact = db.FACTURAS.Where(f => f.ID_FACTURA == ID_FACTURA).Single();
                        obj_recibo.NOTA_ANULACION = "";
                        obj_recibo.VALOR_CUOTA    = Convert.ToDecimal(row.Cells[2].Value);
                        S_Factura.Insertar_Recibo_Cobros(obj_recibo);
                    }
                }

                String arry       = "";
                int    id_factura = Convert.ToInt32(Txt_ID.Text);

                foreach (DataGridViewRow row in dg_detalle_cuotas.Rows)
                {
                    int cuota = Convert.ToInt32(row.Cells[0].Value);
                    if (Convert.ToBoolean(row.Cells[3].Value) == true)
                    {
                        var id_recibo = db.RECIBOS_COBRADOS.Where(s => s.ID_FACTURA == id_factura && s.CUOTA_COBRADA == cuota).Max(s => s.ID_RECIBO);

                        arry += id_recibo.ToString() + ",";
                    }
                }
                String recibos = arry.TrimEnd(',');



                S_Utilidades.Mensaje_Informacion("Cobros Realizados con Correctamente por un Monto Total de: " + txt_total.Text);

                Reportes.Rep_Recibo_Pago report = new Reportes.Rep_Recibo_Pago();
                report.FilterString = "([ID_FACTURA] = " + Txt_ID.Text + " AND [ID_RECIBO] IN (" + recibos + "))";
                ReportPrintTool tool = new ReportPrintTool(report);
                tool.ShowPreview();

                Close();
            }
            catch (Exception ex)
            {
                S_Utilidades.Mensaje_Informacion(ex.Message);
            }
        }