Exemple #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);
        }
Exemple #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();
            }
        }
Exemple #3
0
        public static void Anular_Recibo(RECIBOS_COBRADOS obj)
        {
            D_Factura Metodo = new D_Factura();

            Metodo.Anular_Recibo(obj);
        }
Exemple #4
0
        public static void Insertar_Recibo_Cobros(RECIBOS_COBRADOS obj)
        {
            D_Factura Metodo = new D_Factura();

            Metodo.Insertar_Recibo_Cobros(obj);
        }
Exemple #5
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);
            }
        }