Beispiel #1
0
        private void CargarFacturas()
        {
            this.pDetalles.Visible    = true;
            this.gbRefacturar.Visible = true;
            facturas          oFactura          = new facturas();
            FacturasImplement oFacturaImplement = new FacturasImplement();
            socios            oSocio            = new socios();
            SocioImplement    oSocioImplement   = new SocioImplement();

            oSocio = oSocioImplement.Get(_idSocio);
            tarifas           oTarifa            = new tarifas();
            TarifaImplement   oTarifaImplement   = new TarifaImplement();
            cod_impuestos     oCodImpuesto       = new cod_impuestos();
            ImpuestoImplement oImpuestoImplement = new ImpuestoImplement();

            oCodImpuesto = oImpuestoImplement.Get(oSocio.iva.Value);
            oFactura     = oFacturaImplement.Get(_idFactura);
            oTarifa      = oTarifaImplement.Get(oSocio.tarifa.Value);
            this.txtNroFacturaAct.Text = oFactura.id_factura.ToString();
            _periodo = oFactura.id_factura.ToString();
            this.txtFechaAct.Text = oFactura.id_periodo.ToString();
            CargarFactura(_idFactura);
            this.txtTotalAct.Text = sumarFilas(ref this.dgDetalleAct, "colAImporte").ToString();
            CargarFacturaFutura(_periodo, _idSocio);
            this.txtTotalFut.Text = sumarFilas(ref this.dgDetalleFut, "colFImporte").ToString();
        }
Beispiel #2
0
        private void CargarSeleccion()
        {
            if (!_eliminoTarifa)
            {
                tarifas oTarifa = new tarifas();

                DataGridViewRow row = this.dgvTarifa.CurrentRow;
                int             id  = Convert.ToInt32(row.Cells[1].Value);
                oTarifa = oTarifaImplement.Get(id);

                this.lblCodigo.Text                = oTarifa.id_tarifa.ToString();
                this.txtTarifa.Text                = oTarifa.tarifa;
                this.txtAbreviatura.Text           = oTarifa.abreviatura;
                this.txtCargoFijo.Text             = oTarifa.cargo_fijo.ToString();
                this.txtM3.Text                    = oTarifa.valor_m3.ToString();
                this.txtAbono.Text                 = oTarifa.abono.ToString();
                this.chkTarifaActiva.Checked       = oTarifa.activa.Value;
                this.chkAplicarRecargo.Checked     = oTarifa.recargo_minimo.Value;
                this.chkBonicacion.Checked         = oTarifa.bonificacion.Value;
                this.CHKUsuarioResidencial.Checked = oTarifa.usuario_residencial.Value;
                this.chkVencimiento.Checked        = oTarifa.requiere_fin.Value;
                this.txtMeses.Text                 = oTarifa.meses_venc.ToString();
                Deshabilitar();
            }
        }
        public tarifas Get(int id)
        {
            try
            {
                tarifas oTarifa = new tarifas();
                using (cooperativaEntities bd = new cooperativaEntities())
                {
                    var regis = (from p in bd.tarifas
                                 where p.id_tarifa == id
                                 select p).Single();

                    oTarifa.id_tarifa           = regis.id_tarifa;
                    oTarifa.tarifa              = regis.tarifa;
                    oTarifa.abreviatura         = regis.abreviatura;
                    oTarifa.cargo_fijo          = regis.cargo_fijo;
                    oTarifa.valor_m3            = regis.valor_m3;
                    oTarifa.abono               = regis.abono;
                    oTarifa.usuario_residencial = regis.usuario_residencial;
                    oTarifa.bonificacion        = regis.bonificacion;
                    oTarifa.recargo_minimo      = regis.recargo_minimo;
                    oTarifa.requiere_fin        = regis.requiere_fin;
                    oTarifa.meses_venc          = regis.meses_venc;
                    oTarifa.activa              = regis.activa;

                    return(oTarifa);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
        public void Save(tarifas oTarifa)
        {
            cooperativaEntities bd = new cooperativaEntities();

            bd.tarifas.AddObject(oTarifa);
            bd.SaveChanges();
        }
Beispiel #5
0
        private void ModificarTarifa()
        {
            HabilitarBotones();
            this.gbTarifa.Enabled = true;

            tarifas         oTarifa          = new tarifas();
            TarifaImplement oTarifaImplement = new TarifaImplement();
            DataGridViewRow row = this.dgvTarifa.CurrentRow;
            int             id  = Convert.ToInt32(row.Cells[1].Value);

            oTarifa = oTarifaImplement.Get(id);

            this.lblCodigo.Text                = oTarifa.id_tarifa.ToString();
            this.txtTarifa.Text                = oTarifa.tarifa;
            this.txtAbreviatura.Text           = oTarifa.abreviatura;
            this.txtCargoFijo.Text             = oTarifa.cargo_fijo.ToString();
            this.txtM3.Text                    = oTarifa.valor_m3.ToString();
            this.txtAbono.Text                 = oTarifa.abono.ToString();
            this.chkTarifaActiva.Checked       = oTarifa.activa.Value;
            this.chkAplicarRecargo.Checked     = oTarifa.recargo_minimo.Value;
            this.chkBonicacion.Checked         = oTarifa.bonificacion.Value;
            this.CHKUsuarioResidencial.Checked = oTarifa.usuario_residencial.Value;
            this.chkVencimiento.Checked        = oTarifa.requiere_fin.Value;
            this.dgvTarifa.Enabled             = false;
        }
        public void CargarCombo(ComboBox combo, string InsertaFila)
        {
            IList   ListarTarifas = GetAll();
            tarifas oTarifa       = new tarifas();

            oTarifa.id_tarifa = 0;
            oTarifa.tarifa    = InsertaFila;

            ListarTarifas.Insert(0, oTarifa);

            combo.DisplayMember = "tarifa";
            combo.ValueMember   = "id_tarifa";
            combo.DataSource    = ListarTarifas;
        }
Beispiel #7
0
        private void Guardar()
        {
            TarifaImplement oTarifaImplement = new TarifaImplement();
            tarifas         oTarifa          = new tarifas();

            if (this.lblCodigo.Text == "")
            {
                oTarifa.tarifa              = this.txtTarifa.Text;
                oTarifa.abreviatura         = this.txtAbreviatura.Text;
                oTarifa.cargo_fijo          = this.txtCargoFijo.Text == "" ? 0 : decimal.Parse(this.txtCargoFijo.Text);
                oTarifa.valor_m3            = this.txtM3.Text == "" ? 0 : decimal.Parse(this.txtM3.Text);
                oTarifa.abono               = this.txtAbono.Text == "" ? 0 : decimal.Parse(this.txtAbono.Text);
                oTarifa.activa              = this.chkTarifaActiva.Checked;
                oTarifa.recargo_minimo      = this.chkAplicarRecargo.Checked;
                oTarifa.bonificacion        = this.chkBonicacion.Checked;
                oTarifa.usuario_residencial = this.CHKUsuarioResidencial.Checked;
                oTarifa.requiere_fin        = this.chkVencimiento.Checked;
                oTarifa.meses_venc          = this.txtMeses.Text == "" ? 0 : int.Parse(this.txtMeses.Text);
                oTarifaImplement.Save(oTarifa);
            }
            else
            {
                DataGridViewRow row = this.dgvTarifa.CurrentRow;
                int             id  = Convert.ToInt32(row.Cells[1].Value);
                oTarifa                     = oTarifaImplement.Get(id);
                oTarifa.tarifa              = this.txtTarifa.Text;
                oTarifa.abreviatura         = this.txtAbreviatura.Text;
                oTarifa.cargo_fijo          = this.txtCargoFijo.Text == "" ? 0 : decimal.Parse(this.txtCargoFijo.Text);
                oTarifa.valor_m3            = this.txtM3.Text == "" ? 0 : decimal.Parse(this.txtM3.Text);
                oTarifa.abono               = this.txtAbono.Text == "" ? 0 : decimal.Parse(this.txtAbono.Text);
                oTarifa.activa              = this.chkTarifaActiva.Checked;
                oTarifa.recargo_minimo      = this.chkAplicarRecargo.Checked;
                oTarifa.bonificacion        = this.chkBonicacion.Checked;
                oTarifa.usuario_residencial = this.CHKUsuarioResidencial.Checked;
                oTarifa.requiere_fin        = this.chkVencimiento.Checked;
                oTarifa.meses_venc          = this.txtMeses.Text == "" ? 0 : int.Parse(this.txtMeses.Text);
                oTarifaImplement.Update(oTarifa);
            }
            this.gbTarifa.Enabled = false;
            Deshabilitar();
            Limpiar();
            CargarGrid();
        }
        public void Update(tarifas oTarifa)
        {
            using (cooperativaEntities bd = new cooperativaEntities())
            {
                var editar = (from p in bd.tarifas
                              where p.id_tarifa == oTarifa.id_tarifa
                              select p).Single();

                editar.tarifa              = oTarifa.tarifa;
                editar.abreviatura         = oTarifa.abreviatura;
                editar.cargo_fijo          = oTarifa.cargo_fijo;
                editar.valor_m3            = oTarifa.valor_m3;
                editar.abono               = oTarifa.abono;
                editar.usuario_residencial = oTarifa.usuario_residencial;
                editar.bonificacion        = oTarifa.bonificacion;
                editar.recargo_minimo      = oTarifa.recargo_minimo;
                editar.requiere_fin        = oTarifa.requiere_fin;
                editar.meses_venc          = oTarifa.meses_venc;
                editar.activa              = oTarifa.activa;
                bd.SaveChanges();
            }
        }
Beispiel #9
0
        public decimal CalcularRecargo(int idFactura)
        {
            using (cooperativaEntities bd = new cooperativaEntities())
            {
                Commons oCommons = new Commons();


                MySqlCommand _comando = new MySqlCommand(String.Format(
                                                             "call GetTotalRecargoByFactura('{0}')", idFactura), dbConectorMySql.ObtenerConexion());

                MySqlDataReader _reader      = _comando.ExecuteReader();
                DataTable       detallesCalc = new DataTable();
                detallesCalc.Load(_reader);
                decimal Recargo = 0;
                Recargo = decimal.Parse(detallesCalc.Rows[0][0].ToString());

                /*var detallesByFact = (from d in bd.facturas_detalles
                 *                    join c in bd.cod_conceptos on d.id_concepto equals c.id_concepto
                 *                    where d.id_factura == idFactura
                 *                    select new
                 *                    {
                 *                        d.id_factura,
                 *                        d.id_detalle,
                 *                        d.id_concepto,
                 *                        d.idOrden,
                 *                        d.idTipo,
                 *                        d.importe,
                 *                        c.id_formula,
                 *                        c.orden_concepto,
                 *                        c.tipo_signo,
                 *                        c.variable,
                 *                        c.activo,
                 *                        c.aplicar_descuento,
                 *                        c.aplicar_iva,
                 *                        c.aplicar_recargo,
                 *                        c.concepto
                 *                    }).ToList();
                 * DataTable detallesCalc = oCommons.convertToTable(detallesByFact);
                 *
                 * foreach (DataRow rowDet in detallesCalc.Rows)
                 * {
                 *  if (bool.Parse(rowDet["aplicar_recargo"].ToString()))
                 *      Recargo = Recargo + decimal.Parse(rowDet["importe"].ToString());
                 * }*/
                /* periodos oPeriodo = new periodos();
                 * PeriodosImplement oPeriososImplement = new PeriodosImplement();
                 *
                 *
                 * FacturasImplement oFacturasImplement = new FacturasImplement();
                 * oPeriodo = oPeriososImplement.Get(oFacturasImplement.Get(idFactura).id_periodo.ToString());*/
                TimeSpan diferencia;
                DateTime fecha_primer_venc = new DateTime();
                fecha_primer_venc = DateTime.Parse(detallesCalc.Rows[0][1].ToString());
                if (fecha_primer_venc < DateTime.Today)
                {
                    diferencia = DateTime.Today - DateTime.Parse(fecha_primer_venc.ToString());
                }
                else
                {
                    diferencia = DateTime.Today - DateTime.Today;
                }
                cod_conceptos     oCod_conceptos     = new cod_conceptos();
                ConceptoImplement oConceptoImplement = new ConceptoImplement();
                oCod_conceptos = oConceptoImplement.Get(18);

                decimal?days      = diferencia.Days * oCod_conceptos.variable;
                decimal resultado = 0;
                if (days >= 0)
                {
                    resultado = (decimal)days;
                }

                int idSocio = 0;
                idSocio = int.Parse(detallesCalc.Rows[0][2].ToString());
                socios         oSocio          = new socios();
                SocioImplement oSocioImplement = new SocioImplement();
                oSocio = oSocioImplement.Get(idSocio);

                tarifas         oTarifa          = new tarifas();
                TarifaImplement oTarifaImplement = new TarifaImplement();
                oTarifa = oTarifaImplement.Get(oSocio.id_socio);

                Recargo = Recargo * resultado;
                DateTime fecha_segundo_venc = new DateTime();
                fecha_segundo_venc = DateTime.Parse(detallesCalc.Rows[0][3].ToString());
                if (fecha_segundo_venc > DateTime.Today)
                {
                    if (oTarifa.cargo_fijo > Recargo) //esto lo hago segun la marca en recargo en tabla tarifas?
                    {
                        Recargo = (decimal)oTarifa.cargo_fijo;
                    }
                }
                return(Recargo);
            }
        }
Beispiel #10
0
        private void Imprimir()
        {
            SysConfigImplement oSysConfigImplement = new SysConfigImplement();

            Reportes.frmReportes frmRpt             = new Reportes.frmReportes();
            Reportes.rptFacturas rpt                = new Reportes.rptFacturas();
            FacturasImplement    oFacturasImplement = new FacturasImplement();
            //DataTable dtFacturas=new DataTable();
            //if(_mostrarImpagas ==0)
            //{
            //    if(_mostrarValoresActualizados==0)
            //    {
            //        dtFacturas=_facturasNoAct;
            //    }
            //    else
            //    {
            //        dtFacturas=_facturasAct;
            //    }
            //}
            //else
            //{
            //    if(_mostrarValoresActualizados==0)
            //    {
            //        dtFacturas=_facturasNoActImp;
            //    }
            //    else
            //    {
            //        dtFacturas=_facturasActImp;
            //    }
            //}


            DataTable dtFacturas     = oFacturasImplement.GetByIdSocioDT(_idSocio, _mostrarImpagas, _mostrarValoresActualizados);
            decimal   totalfacturado = 0;
            decimal   totalrecargo   = 0;
            decimal   totalcobrado   = 0;
            decimal   totaldeuda     = 0;

            foreach (DataRow dr in dtFacturas.Rows)
            {
                dr["Total"]   = (decimal.Parse(dr["Recargo"].ToString()) + decimal.Parse(dr["IVARecargo"].ToString())) + (decimal.Parse(dr["Neto"].ToString()) + decimal.Parse(dr["IVA"].ToString())) - decimal.Parse(dr["Cobrado"].ToString());
                dr["Neto"]    = (decimal.Parse(dr["Neto"].ToString()) + decimal.Parse(dr["IVA"].ToString()));
                dr["Recargo"] = (decimal.Parse(dr["Recargo"].ToString()) + decimal.Parse(dr["IVARecargo"].ToString()));

                totalfacturado = totalfacturado + (decimal.Parse(dr["Neto"].ToString()) + decimal.Parse(dr["IVA"].ToString()));
                totalrecargo   = totalrecargo + (decimal.Parse(dr["Recargo"].ToString()) + decimal.Parse(dr["IVARecargo"].ToString()));
                totalcobrado   = totalcobrado + decimal.Parse(dr["Cobrado"].ToString());
                totaldeuda     = totaldeuda + decimal.Parse(dr["Total"].ToString());
            }

            socios             oSocio               = new socios();
            SocioImplement     oSocioImplement      = new SocioImplement();
            socios_lote        oSocio_lote          = new socios_lote();
            SocioLoteImplement oSocio_loteImplement = new SocioLoteImplement();
            tarifas            oTarifas             = new tarifas();
            TarifaImplement    oTarifaImplement     = new TarifaImplement();
            cod_barrios        oCod_Barrios         = new cod_barrios();
            BarrioImplement    oBarrioImplement     = new BarrioImplement();
            cod_calles         oCod_Calles          = new  cod_calles();
            CalleImplement     oCalleImplement      = new CalleImplement();

            oSocio      = oSocioImplement.Get(_idSocio);
            oSocio_lote = oSocio_loteImplement.Get(_idSocio);
            string calleAltura = "";
            string manzana     = "";
            string lote        = "";
            string tarifa      = "";
            string barrio      = "";

            if (oSocio.tarifa > 0)
            {
                tarifa = oTarifaImplement.Get((int)oSocio.tarifa).tarifa;
            }
            if (oSocio_lote != null)
            {
                if (oSocio_lote.barrio > 0)
                {
                    barrio = oBarrioImplement.Get((int)oSocio_lote.barrio).barrio;
                }
                if (oSocio_lote.calle_altura.Length > 0)
                {
                    calleAltura = oSocio_lote.calle_altura;
                }
                if (oSocio_lote.manzana.Length > 0)
                {
                    manzana = oSocio_lote.manzana;
                }
                if (oSocio_lote.lote.Length > 0)
                {
                    lote = oSocio_lote.lote;
                }
            }
            string calle = "";

            if (oSocio_lote.calle != null && oSocio_lote.calle > 0)
            {
                calle = oCalleImplement.Get((int)oSocio_lote.calle).calle;
            }

            //Cargo el Data Set


            DataSet ds = new DataSet("Generico");

            ds.Tables.Add(oSysConfigImplement.GetEncabezadoDT("Encabezado"));
            ds.Tables[0].TableName = "dtEncabezado";
            ds.Tables.Add(dtFacturas);
            ds.Tables[1].TableName = "dtFacturas";
            rpt.SetDataSource(ds);
            rpt.SetParameterValue("socio", oSocio.codigo_socio + "/" + oSocio.subcodigo_socio + "  " + oSocio.nombre);
            rpt.SetParameterValue("tarifa", tarifa);
            rpt.SetParameterValue("barrio", barrio);
            rpt.SetParameterValue("calle", calle);
            rpt.SetParameterValue("numero", calleAltura);
            rpt.SetParameterValue("manzana", manzana);
            rpt.SetParameterValue("lote", lote);
            rpt.SetParameterValue("totalfacturado", Math.Round(totalfacturado, 2).ToString());
            rpt.SetParameterValue("totalrecargo", Math.Round(totalrecargo, 2).ToString());
            rpt.SetParameterValue("totalcobrado", Math.Round(totalcobrado, 2).ToString());
            rpt.SetParameterValue("totaldeuda", Math.Round(totaldeuda, 2).ToString());
            frmRpt.crvGenerico.ReportSource = rpt;
            frmRpt.Show();
        }