예제 #1
0
        protected void btnGuardarContrato_Click(object sender, EventArgs e)
        {
            List <ContratosDeObra> listaContrato = uow.ContratosDeObraBL.Get(p => p.ObraId == this.idObra).ToList();



            ContratosDeObra contrato;

            if (listaContrato.Count == 0)
            {
                contrato = new ContratosDeObra();

                contrato.ObraId                 = this.idObra;
                contrato.NumeroDeContrato       = txtNumContrato.Value;
                contrato.RFCcontratista         = txtRFC.Value;
                contrato.RazonSocialContratista = txtRazonSocial.Value;
                contrato.Total = decimal.Parse(txtImporteTotal.Value.ToString());

                contrato.FechaDelContrato = DateTime.Parse(dtpContrato.Value.ToString());
                contrato.FechaDeInicio    = DateTime.Parse(dtpInicio.Value.ToString());
                contrato.FechaDeTermino   = DateTime.Parse(dtpTermino.Value.ToString());

                contrato.PorcentajeDeAnticipo = double.Parse(txtPorcentajeAnticipo.Value.ToString());
                contrato.Descontar5AlMillar   = bool.Parse(chk5almillar.Checked.ToString());
                contrato.Descontar2AlMillar   = bool.Parse(chk2almillar.Checked.ToString());

                // uow.ContratosDeObraBL.Insert(contrato);
            }
            else
            {
                contrato = uow.ContratosDeObraBL.GetByID(this.idObra);

                contrato.NumeroDeContrato       = txtNumContrato.Value;
                contrato.RFCcontratista         = txtRFC.Value;
                contrato.RazonSocialContratista = txtRazonSocial.Value;
                contrato.Total = decimal.Parse(txtImporteTotal.Value.ToString());

                contrato.FechaDelContrato = DateTime.Parse(dtpContrato.Value.ToString());
                contrato.FechaDeInicio    = DateTime.Parse(dtpInicio.Value.ToString());
                contrato.FechaDeTermino   = DateTime.Parse(dtpTermino.Value.ToString());

                contrato.PorcentajeDeAnticipo = double.Parse(txtPorcentajeAnticipo.Value.ToString());
                contrato.Descontar5AlMillar   = bool.Parse(chk5almillar.Value.ToString());
                contrato.Descontar2AlMillar   = bool.Parse(chk2almillar.Value.ToString());

                // uow.ContratosDeObraBL.Update(contrato);
            }

            //Obra obra = uow.ObraBusinessLogic.GetByID(this.idObra);

            //if (obra.StatusControlFinanciero == 0)
            //{
            //    obra.StatusControlFinanciero = 1;
            //    uow.ObraBusinessLogic.Update(obra);
            //}



            //  uow.SaveChanges();
        }
예제 #2
0
        private void bindDatos()
        {
            this.idObra = int.Parse(Session["XidObra"].ToString());
            Obra obra = uow.ObraBusinessLogic.GetByID(this.idObra);

            ContratosDeObra contrato = uow.ContratosDeObraBL.Get(p => p.ObraId == this.idObra).FirstOrDefault();
            Estimaciones    anticipo = uow.EstimacionesBL.Get(p => p.ContratoDeObra.ObraId == this.idObra && p.NumeroDeEstimacion == 0).FirstOrDefault();

            txtNumObra.Value         = obra.Numero;
            txtDescripcionObra.Value = obra.Descripcion;
            txtRFC.Value             = contrato.RFCcontratista;
            txtRazonSocial.Value     = contrato.RazonSocialContratista;

            txtImporteContratado.Value = contrato.Total.ToString();
            txtPorcentaje.Value        = contrato.PorcentajeDeAnticipo.ToString() + " %";
            txtImporteAnticipo.Value   = (double.Parse(contrato.Total.ToString()) * (contrato.PorcentajeDeAnticipo / 100)).ToString();

            divBtnImprimir.Style.Add("display", "none");

            if (obra.StatusControlFinanciero > 4)//datos del anticipo
            {
                txtFolio.Value           = anticipo.FolioCL;
                dtpFecha.Value           = String.Format("{0:d}", anticipo.FechaDeEstimacion);
                txtImporteAnticipo.Value = anticipo.Total.ToString();

                divBtnGuardarAnticipo.Style.Add("display", "none");
                divBtnImprimir.Style.Add("display", "block");
            }
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            uow = new UnitOfWork(Session["IdUser"].ToString());

            this.idObra = int.Parse(Session["XidObra"].ToString());
            Obra obra = uow.ObraBusinessLogic.GetByID(idObra);

            if (!IsPostBack)
            {
                BindGrids();

                _URLVisor.Value   = ResolveClientUrl("~/rpts/wfVerReporte.aspx");
                _idContrato.Value = "0";

                if (obra.StatusControlFinanciero < 5)//no hay anticipo registrado
                {
                    DIVmostrarEstimaciones.Style.Add("display", "none");
                }
                else
                {
                    divMSGnoHayAnticipo.Style.Add("display", "none");
                    ContratosDeObra contrato = uow.ContratosDeObraBL.Get(p => p.ObraId == this.idObra).First();
                    _idContrato.Value = contrato.Id.ToString();
                }
            }
        }
예제 #4
0
        private void BindX()
        {
            //datos generales de la obra
            Obra obra = uow.ObraBusinessLogic.GetByID(this.idObra);

            txtNoObra.Value          = obra.Numero;
            txtDescripcionObra.Value = obra.Descripcion;


            if (obra.StatusControlFinanciero > 0)//datos del contrato
            {
                ContratosDeObra contrato = uow.ContratosDeObraBL.Get(p => p.ObraId == this.idObra).First();

                txtNumContrato.Value = contrato.NumeroDeContrato;

                txtRFC.Value          = contrato.RFCcontratista;
                txtRazonSocial.Value  = contrato.RazonSocialContratista;
                txtImporteTotal.Value = contrato.Total.ToString();

                dtpContrato.Value = String.Format("{0:d}", contrato.FechaDelContrato);
                dtpInicio.Value   = String.Format("{0:d}", contrato.FechaDeInicio);
                dtpTermino.Value  = String.Format("{0:d}", contrato.FechaDeTermino);

                txtPorcentajeAnticipo.Value = contrato.PorcentajeDeAnticipo.ToString();
                chk5almillar.Checked        = contrato.Descontar5AlMillar;
                chk2almillar.Checked        = contrato.Descontar2AlMillar;
            }
        }
예제 #5
0
        protected void btnGuardarProgramaDeObra_Click(object sender, EventArgs e)
        {
            int usuario = int.Parse(Session["IdUser"].ToString());

            this.idObra = int.Parse(Session["XidObra"].ToString());


            ContratosDeObra contrato = uow.ContratosDeObraBL.Get(p => p.ObraId == this.idObra).FirstOrDefault();



            List <ProgramasDeObrasTMP> listaFechas = uow.ProgramasDeObraTMPBL.Get(p => p.Usuario == usuario && p.Status == 1 && p.Cantidad > 0).ToList();

            foreach (ProgramasDeObrasTMP item in listaFechas)
            {
                ProgramasDeObras programacion = new ProgramasDeObras();

                programacion.ContratoDeObra          = contrato;
                programacion.PresupuestoContratadoId = item.PresupuestoContratadoId;
                programacion.Inicio  = item.Inicio.Value;
                programacion.Termino = item.Termino.Value;
                programacion.Status  = 1;
                uow.ProgramasDeObrasBL.Insert(programacion);
            }


            Obra obra = uow.ObraBusinessLogic.GetByID(this.idObra);

            obra.StatusControlFinanciero = 3;
            uow.ObraBusinessLogic.Update(obra);


            uow.SaveChanges();

            if (uow.Errors.Count == 0)
            {
                divMSGnoHayPresupuesto.Style.Add("display", "none");
                divCargarArchivo.Style.Add("display", "none");
                divGuardarProgramaDeObra.Style.Add("display", "none");
                divTMP.Style.Add("display", "none");
                divProgramaDeObra.Style.Add("display", "block");

                cargarProgramaDeObra();
            }
        }
예제 #6
0
        protected void grid_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                int idObra = Utilerias.StrToInt(grid.DataKeys[e.Row.RowIndex].Values["Id"].ToString());

                Obra obra = uow.ObraBusinessLogic.GetByID(idObra);


                LinkButton linkC   = (LinkButton)e.Row.FindControl("linkContrato");
                LinkButton linkP   = (LinkButton)e.Row.FindControl("LinkPresupuesto");
                LinkButton linkPdO = (LinkButton)e.Row.FindControl("LinkProgramacion");
                LinkButton linkPdE = (LinkButton)e.Row.FindControl("LinkProgramacionEstimaciones");

                linkC.Text   = "Pendiente";
                linkP.Text   = "Pendiente";
                linkPdO.Text = "Pendiente";
                linkPdE.Text = "Pendiente";

                if (obra.StatusControlFinanciero > 0)
                {
                    ContratosDeObra contrato = uow.ContratosDeObraBL.Get(p => p.ObraId == idObra).First();
                    linkC.Text = contrato.NumeroDeContrato;

                    if (obra.StatusControlFinanciero > 1)
                    {
                        linkP.Text = contrato.Total.ToString("C0");
                    }

                    if (obra.StatusControlFinanciero > 2)
                    {
                        linkPdO.Text = "Cargado...";
                    }
                    //linkPdO.CssClass = "alert-success";

                    if (obra.StatusControlFinanciero > 3)
                    {
                        linkPdE.Text = "Cargadas...";
                    }
                }
            }
        }
예제 #7
0
        private void bindDatos()
        {
            this.idObra = int.Parse(Session["XidObra"].ToString());
            Obra obra = uow.ObraBusinessLogic.GetByID(this.idObra);


            if (obra.StatusControlFinanciero > 0)//datos del contrato
            {
                ContratosDeObra contrato = uow.ContratosDeObraBL.Get(p => p.ObraId == this.idObra).First();

                txtNumContrato.Value = contrato.NumeroDeContrato;

                txtClaveContratista.Value = contrato.ClaveContratista;
                txtRFC.Value          = contrato.RFCcontratista;
                txtRazonSocial.Value  = contrato.RazonSocialContratista;
                txtImporteTotal.Value = contrato.Total.ToString("C0");

                dtpContrato.Value          = String.Format("{0:d}", contrato.FechaDelContrato);
                dtpInicio.Value            = String.Format("{0:d}", contrato.FechaDeInicio);
                dtpTermino.Value           = String.Format("{0:d}", contrato.FechaDeTermino);
                txtClavePresupuestal.Value = contrato.ClavePresupuestal;

                txtPorcentajeAnticipo.Value = contrato.PorcentajeDeAnticipo.ToString();
                chk5almillar.Checked        = contrato.Descontar5AlMillar;
                chk2almillar.Checked        = contrato.Descontar2AlMillar;
                chk2almillarSV.Checked      = contrato.Descontar2AlMillarSV;

                txtNombreAfianzadora.Value  = contrato.NombreAfianzadora;
                txtFianza.Value             = contrato.NumeroFianza;
                txtFianzaCumplimiento.Value = contrato.NumeroFianzaCumplimiento;
            }

            if (obra.StatusControlFinanciero > 3)
            {
                divBtnGuardarContrato.Style.Add("display", "none");
            }
        }
예제 #8
0
        protected void btnGuardarContrato_Click(object sender, EventArgs e)
        {
            this.idObra = int.Parse(Session["XidObra"].ToString());
            List <ContratosDeObra> listaContrato = uow.ContratosDeObraBL.Get(p => p.ObraId == this.idObra).ToList();

            ContratosDeObra contrato;

            if (listaContrato.Count == 0)
            {
                contrato = new ContratosDeObra();

                contrato.ObraId = this.idObra;

                contrato.NumeroDeContrato       = txtNumContrato.Value;
                contrato.ClaveContratista       = txtClaveContratista.Value;
                contrato.RFCcontratista         = txtRFC.Value;
                contrato.RazonSocialContratista = txtRazonSocial.Value;
                //contrato.Total = decimal.Parse(txtImporteTotal.Value.ToString());

                contrato.FechaDelContrato     = DateTime.Parse(dtpContrato.Value.ToString());
                contrato.FechaDeInicio        = DateTime.Parse(dtpInicio.Value.ToString());
                contrato.FechaDeTermino       = DateTime.Parse(dtpTermino.Value.ToString());
                contrato.ClavePresupuestal    = txtClavePresupuestal.Value;
                contrato.PorcentajeDeAnticipo = double.Parse(txtPorcentajeAnticipo.Value.ToString());
                contrato.Descontar5AlMillar   = bool.Parse(chk5almillar.Checked.ToString());
                contrato.Descontar2AlMillar   = bool.Parse(chk2almillar.Checked.ToString());
                contrato.Descontar2AlMillarSV = bool.Parse(chk2almillarSV.Checked.ToString());

                contrato.NombreAfianzadora        = txtNombreAfianzadora.Value;
                contrato.NumeroFianza             = txtFianza.Value;
                contrato.NumeroFianzaCumplimiento = txtFianzaCumplimiento.Value;


                contrato.CreatedById = int.Parse(Session["IdUser"].ToString());


                uow.ContratosDeObraBL.Insert(contrato);

                Obra obra = uow.ObraBusinessLogic.GetByID(this.idObra);

                if (obra.StatusControlFinanciero == 0)
                {
                    obra.StatusControlFinanciero = 1;
                    uow.ObraBusinessLogic.Update(obra);
                }
            }
            else
            {
                contrato = uow.ContratosDeObraBL.Get(p => p.ObraId == this.idObra).FirstOrDefault();

                contrato.NumeroDeContrato       = txtNumContrato.Value;
                contrato.ClaveContratista       = txtClaveContratista.Value;
                contrato.RFCcontratista         = txtRFC.Value;
                contrato.RazonSocialContratista = txtRazonSocial.Value;
                //contrato.Total = decimal.Parse(txtImporteTotal.Value.ToString());

                contrato.FechaDelContrato     = DateTime.Parse(dtpContrato.Value.ToString());
                contrato.FechaDeInicio        = DateTime.Parse(dtpInicio.Value.ToString());
                contrato.FechaDeTermino       = DateTime.Parse(dtpTermino.Value.ToString());
                contrato.ClavePresupuestal    = txtClavePresupuestal.Value;
                contrato.PorcentajeDeAnticipo = double.Parse(txtPorcentajeAnticipo.Value.ToString());
                contrato.Descontar5AlMillar   = bool.Parse(chk5almillar.Checked.ToString());
                contrato.Descontar2AlMillar   = bool.Parse(chk2almillar.Checked.ToString());
                contrato.Descontar2AlMillarSV = bool.Parse(chk2almillarSV.Checked.ToString());

                contrato.NombreAfianzadora        = txtNombreAfianzadora.Value;
                contrato.NumeroFianza             = txtFianza.Value;
                contrato.NumeroFianzaCumplimiento = txtFianzaCumplimiento.Value;
                contrato.EditedById = int.Parse(Session["IdUser"].ToString());

                uow.ContratosDeObraBL.Update(contrato);
            }

            uow.SaveChanges();

            if (uow.Errors.Count == 0)
            {
                Response.Redirect("wfPresupuestoContratado.aspx");
            }
        }
예제 #9
0
        protected void btnGuardarAnticipo_Click(object sender, EventArgs e)
        {
            this.idObra = int.Parse(Session["XidObra"].ToString());

            List <Estimaciones> listaAnticipos = uow.EstimacionesBL.Get(p => p.ContratoDeObra.ObraId == this.idObra && p.NumeroDeEstimacion == 0).ToList();
            ContratosDeObra     contrato       = uow.ContratosDeObraBL.Get(p => p.ObraId == this.idObra).First();

            Estimaciones anticipo;

            if (listaAnticipos.Count == 0)
            {
                anticipo = new Estimaciones();

                anticipo.ContratoDeObraId   = contrato.Id;
                anticipo.NumeroDeEstimacion = 0;
                anticipo.FolioCL            = txtFolio.Value;
                anticipo.FechaDeEstimacion  = DateTime.Parse(dtpFecha.Value.ToString());
                anticipo.ImporteEstimado    = 0;
                anticipo.IVA   = 0;
                anticipo.Total = Convert.ToDecimal(txtImporteAnticipo.Value.ToString());
                anticipo.AmortizacionAnticipo = 0;
                anticipo.Retencion2AlMillar   = 0;
                anticipo.Retencion5AlMillar   = 0;
                anticipo.Retencion2AlMillarSV = 0;
                anticipo.Sanciones            = 0;
                anticipo.Otros = 0;
                anticipo.ISR   = 0;
                anticipo.ImporteNetoACobrar = Convert.ToDecimal(txtImporteAnticipo.Value.ToString());
                anticipo.Status             = 2;

                anticipo.ConceptoDePago = "Anticipo";
                anticipo.PeriodoInicio  = DateTime.Parse(dtpFecha.Value.ToString());
                anticipo.PeriodoTermino = DateTime.Parse(dtpFecha.Value.ToString());


                uow.EstimacionesBL.Insert(anticipo);

                Obra obra = uow.ObraBusinessLogic.GetByID(this.idObra);

                if (obra.StatusControlFinanciero == 4)
                {
                    obra.StatusControlFinanciero = 5;
                    uow.ObraBusinessLogic.Update(obra);
                }
            }
            else
            {
                anticipo = uow.EstimacionesBL.Get(p => p.ContratoDeObraId == contrato.Id && p.NumeroDeEstimacion == 0).First();

                anticipo.FolioCL            = txtFolio.Value;
                anticipo.FechaDeEstimacion  = DateTime.Parse(dtpFecha.Value.ToString());
                anticipo.Total              = Convert.ToDecimal(txtImporteAnticipo.Value.ToString());
                anticipo.ImporteNetoACobrar = Convert.ToDecimal(txtImporteAnticipo.Value.ToString());
                anticipo.Status             = 1;

                uow.EstimacionesBL.Update(anticipo);
            }


            uow.SaveChanges();

            if (uow.Errors.Count == 0)
            {
                divBtnImprimir.Style.Add("display", "block");
                divBtnGuardarAnticipo.Style.Add("display", "none");
            }
        }
        protected void grid_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                int idObra = Utilerias.StrToInt(grid.DataKeys[e.Row.RowIndex].Values["Id"].ToString());

                Obra obra = uow.ObraBusinessLogic.GetByID(idObra);



                HtmlGenericControl divAvFisico     = (HtmlGenericControl)e.Row.FindControl("DIVAvanceFisico");
                HtmlGenericControl divAvFinanciero = (HtmlGenericControl)e.Row.FindControl("DIVAvanceFinanciero");

                System.Web.UI.HtmlControls.HtmlGenericControl spanAvanceFisico     = new System.Web.UI.HtmlControls.HtmlGenericControl("SPAN");
                System.Web.UI.HtmlControls.HtmlGenericControl spanAvanceFinanciero = new System.Web.UI.HtmlControls.HtmlGenericControl("SPAN");


                LinkButton linkAnt = (LinkButton)e.Row.FindControl("linkAnticipo");
                LinkButton linkEst = (LinkButton)e.Row.FindControl("linkEstimaciones");

                linkAnt.Text = "Pendiente";
                linkEst.Text = "Pendiente";



                HtmlGenericControl progresoA = (HtmlGenericControl)e.Row.FindControl("ProgresoA");
                HtmlGenericControl progresoB = (HtmlGenericControl)e.Row.FindControl("ProgresoB");


                if (obra.StatusControlFinanciero > 4)
                {
                    ContratosDeObra     contrato = uow.ContratosDeObraBL.Get(p => p.ObraId == idObra).First();
                    Estimaciones        anticipo = uow.EstimacionesBL.Get(p => p.ContratoDeObra.ObraId == idObra && p.NumeroDeEstimacion == 0).First();
                    List <Estimaciones> listaEstimaciones;

                    linkAnt.Text = anticipo.Total.ToString("C2");



                    if (obra.StatusControlFinanciero > 5)
                    {
                        listaEstimaciones = uow.EstimacionesBL.Get(p => p.ContratoDeObra.ObraId == idObra && p.NumeroDeEstimacion > 0).ToList();
                        string cad = " ";
                        foreach (Estimaciones item in listaEstimaciones)
                        {
                            cad = cad + item.NumeroDeEstimacion + "-";
                        }
                        cad = cad.Substring(0, cad.Length - 1);

                        linkEst.Text = "EST: " + cad;
                    }



                    decimal suma;
                    decimal avance;
                    int     porcentaje;

                    //Avance Fisico
                    listaEstimaciones = uow.EstimacionesBL.Get(p => p.ContratoDeObra.ObraId == idObra && p.NumeroDeEstimacion > 0).ToList();
                    suma       = listaEstimaciones.Sum(p => p.Total);
                    avance     = Math.Round(suma / contrato.Total, 2) * 100;
                    porcentaje = Convert.ToInt16(avance);

                    spanAvanceFisico.InnerText = porcentaje.ToString() + "%";
                    progresoA.Style.Add("width", porcentaje.ToString() + "%");



                    //Avance Financiero
                    listaEstimaciones = uow.EstimacionesBL.Get(p => p.ContratoDeObra.ObraId == idObra && p.Status == 2).ToList();
                    suma       = listaEstimaciones.Sum(p => p.Total - p.AmortizacionAnticipo);
                    avance     = Math.Round(suma / contrato.Total, 2) * 100;
                    porcentaje = Convert.ToInt16(avance);

                    spanAvanceFinanciero.InnerText = porcentaje.ToString() + "%";
                    progresoB.Style.Add("width", porcentaje.ToString() + "%");
                }
                else
                {
                    spanAvanceFisico.InnerText     = "0%";
                    spanAvanceFinanciero.InnerText = "0%";

                    progresoA.Style.Add("width", 0.ToString() + "%");
                    progresoB.Style.Add("width", 0.ToString() + "%");
                }


                divAvFisico.Controls.Add(spanAvanceFisico);
                divAvFinanciero.Controls.Add(spanAvanceFinanciero);
            }
        }
        protected void btnAddEstimacion_Click(object sender, EventArgs e)
        {
            DateTime fechaEstimacion;

            idObra = int.Parse(Session["XidObra"].ToString());

            ContratosDeObra contrato = uow.ContratosDeObraBL.Get(p => p.ObraId == idObra).First();

            fechaEstimacion = DateTime.Parse(dtpFecha.Value);

            List <ProgramasDeObras> listaConceptos = uow.ProgramasDeObrasBL.Get(p => p.ContratoDeObra.ObraId == idObra && p.Status == 1 && p.Termino <= fechaEstimacion).ToList();

            if (listaConceptos.Count == 0)
            {
                return;
            }



            EstimacionesProgramadas estimacion = new EstimacionesProgramadas();
            PresupuestosContratados concepto;

            decimal importeEstimado, iva, total;
            decimal amortizacion, ret5, ret2, ret2bis;

            importeEstimado = 0;



            foreach (ProgramasDeObras item in listaConceptos)
            {
                concepto        = uow.PresupuestosContratadosBL.GetByID(item.PresupuestoContratadoId);
                importeEstimado = importeEstimado + concepto.Subtotal;
            }

            iva   = importeEstimado * decimal.Parse("0.16");
            total = importeEstimado * decimal.Parse("1.16");

            amortizacion = decimal.Parse(contrato.PorcentajeDeAnticipo.ToString()) / decimal.Parse("100");
            if (contrato.Descontar5AlMillar)
            {
                ret5 = decimal.Parse("0.005");
            }
            else
            {
                ret5 = 0;
            }
            if (contrato.Descontar2AlMillar)
            {
                ret2 = decimal.Parse("0.002");
            }
            else
            {
                ret2 = 0;
            }
            if (contrato.Descontar2AlMillarSV)
            {
                ret2bis = decimal.Parse("0.002");
            }
            else
            {
                ret2bis = 0;
            }

            amortizacion = total * amortizacion;
            ret5         = total * ret5;
            ret2         = total * ret2;
            ret2bis      = total * ret2bis;

            List <EstimacionesProgramadas> listaEstimacionesProgramadas = uow.EstimacionesProgramadasBL.Get(p => p.ContratoDeObra.ObraId == this.idObra).ToList();
            int NumEstimacion = 0;

            if (listaEstimacionesProgramadas.Count > 0)
            {
                NumEstimacion = listaEstimacionesProgramadas.Max(p => p.NumeroDeEstimacion);
            }

            NumEstimacion++;


            estimacion.ContratoDeObraId   = contrato.Id;
            estimacion.NumeroDeEstimacion = NumEstimacion;
            estimacion.FechaDeEstimacion  = fechaEstimacion;
            estimacion.ImporteEstimado    = importeEstimado;
            estimacion.IVA   = iva;
            estimacion.Total = total;
            estimacion.AmortizacionAnticipo  = amortizacion;
            estimacion.Retencion5AlMillar    = ret5;
            estimacion.Retencion2AlMillar    = ret2;
            estimacion.Retencion2AlMillarSyV = ret2bis;
            estimacion.ImporteAPagar         = total - (amortizacion + ret5 + ret2 + ret2bis);

            uow.EstimacionesProgramadasBL.Insert(estimacion);


            foreach (ProgramasDeObras item in listaConceptos)
            {
                EstimacionesProgramadasConceptos conceptoProgramado = new EstimacionesProgramadasConceptos();

                conceptoProgramado.EstimacionProgramada    = estimacion;
                conceptoProgramado.PresupuestoContratadoId = item.PresupuestoContratadoId;
                conceptoProgramado.Cantidad = item.PresupuestoContratado.Cantidad;
                conceptoProgramado.Subtotal = item.PresupuestoContratado.Subtotal;

                uow.EstimacionesProgramadasConceptosBL.Insert(conceptoProgramado);

                item.Status = 2;
                uow.ProgramasDeObrasBL.Update(item);
            }

            uow.SaveChanges();

            if (uow.Errors.Count == 0)
            {
                cargarConceptosPendientes();
                cargarEstimacionesProgramadas();
                NextNumeroEstimacion();
                dtpFecha.Value = string.Empty;
            }
        }
        private void cargarConceptosPendientes()
        {
            this.idObra = int.Parse(Session["XidObra"].ToString());



            var query = from item in uow.ProgramasDeObrasBL.Get(p => p.ContratoDeObra.ObraId == this.idObra && p.Status == 1).ToList()
                        group item by new { item.Termino } into g
                select new
            {
                Key  = g.Key,
                Suma = g.Sum(p => p.PresupuestoContratado.Subtotal)
            };

            query = query.OrderBy(p => p.Key.Termino).ToList();

            DataTable table = new DataTable();

            table.Columns.Add("Id");
            table.Columns.Add("Fecha", typeof(DateTime));
            table.Columns.Add("NConceptos");
            table.Columns.Add("Subtotal", typeof(decimal));
            table.Columns.Add("IVA", typeof(decimal));
            table.Columns.Add("Total", typeof(decimal));
            table.Columns.Add("Anticipo", typeof(decimal));
            table.Columns.Add("Ret5", typeof(decimal));
            table.Columns.Add("Ret2", typeof(decimal));
            table.Columns.Add("Ret2Bis", typeof(decimal));
            table.Columns.Add("ImporteFinal", typeof(decimal));

            int i = 0;


            ContratosDeObra contrato = uow.ContratosDeObraBL.Get(p => p.ObraId == this.idObra).First();
            decimal         anticipo, ret5, ret2, ret2bis, total;

            List <ProgramasDeObras> listaConceptos;

            foreach (var item in query)
            {
                DataRow row = table.NewRow();

                anticipo = decimal.Parse(contrato.PorcentajeDeAnticipo.ToString()) / decimal.Parse("100");
                if (contrato.Descontar5AlMillar)
                {
                    ret5 = decimal.Parse("0.005");
                }
                else
                {
                    ret5 = 0;
                }
                if (contrato.Descontar2AlMillar)
                {
                    ret2 = decimal.Parse("0.002");
                }
                else
                {
                    ret2 = 0;
                }
                if (contrato.Descontar2AlMillarSV)
                {
                    ret2bis = decimal.Parse("0.002");
                }
                else
                {
                    ret2bis = 0;
                }

                i++;

                total    = item.Suma * decimal.Parse("1.16");
                anticipo = total * anticipo;
                ret5     = total * ret5;
                ret2     = total * ret2;
                ret2bis  = total * ret2bis;

                listaConceptos = uow.ProgramasDeObrasBL.Get(p => p.ContratoDeObra.ObraId == this.idObra && p.Status == 1 && p.Termino == item.Key.Termino).ToList();

                row["Id"]           = i;
                row["Fecha"]        = item.Key.Termino;
                row["NConceptos"]   = listaConceptos.Count;
                row["Subtotal"]     = item.Suma;
                row["IVA"]          = item.Suma * decimal.Parse("0.16");
                row["Total"]        = total;
                row["Anticipo"]     = anticipo;
                row["Ret5"]         = ret5;
                row["Ret2"]         = ret2;
                row["Ret2Bis"]      = ret2bis;
                row["ImporteFinal"] = total - (anticipo + ret5 + ret2 + ret2bis);

                table.Rows.Add(row);
            }


            this.grid.DataSource = table;
            this.grid.DataBind();

            if (table.Rows.Count == 0)
            {
                this.divAgregarEstimacion.Style.Add("display", "none");
                this.divGuardarEstimacionesProgramadas.Style.Add("display", "block");
            }
            else
            {
                this.divAgregarEstimacion.Style.Add("display", "block");
                this.divGuardarEstimacionesProgramadas.Style.Add("display", "none");
            }
        }
예제 #13
0
        protected void btnGuardarPresupuestoContratado_Click(object sender, EventArgs e)
        {
            idObra = int.Parse(Session["XidObra"].ToString());

            Obra            obra     = uow.ObraBusinessLogic.GetByID(idObra);
            ContratosDeObra contrato = uow.ContratosDeObraBL.Get(p => p.ObraId == idObra).FirstOrDefault();

            int idContratoDeObra = contrato.Id;

            var wb           = new XLWorkbook(_R.Value);
            var ws           = wb.Worksheet(1);
            var firstRowUsed = ws.FirstRow();
            var lastRowUsed  = ws.LastRowUsed();
            var rows         = ws.FirstRow();

            int nregistros = lastRowUsed.RowNumber() - firstRowUsed.RowNumber();


            nregistros++;
            int i = 0;

            decimal importe;
            decimal cantidad;

            PresupuestosContratados padre = null;

            while (nregistros > 0)
            {
                if (i > 9)
                {
                    PresupuestosContratados presupuesto = new PresupuestosContratados();

                    try
                    {
                        cantidad = decimal.Parse(rows.Cell("E").GetString());
                        importe  = decimal.Parse(rows.Cell("F").GetString());
                    }
                    catch
                    {
                        cantidad = 0;
                        importe  = 0;
                    }



                    if (cantidad == 0 && importe == 0)
                    {
                        presupuesto.ContratoDeObraId = idContratoDeObra;
                        presupuesto.Nivel            = 1;
                        presupuesto.Orden            = i;
                        presupuesto.Numero           = double.Parse(rows.Cell("A").GetString());
                        presupuesto.Descripcion      = rows.Cell("C").GetString();

                        padre = presupuesto;

                        uow.PresupuestosContratadosBL.Insert(presupuesto);
                    }
                    else
                    {
                        presupuesto.ContratoDeObraId = idContratoDeObra;
                        presupuesto.Nivel            = 2;
                        presupuesto.Orden            = i;
                        presupuesto.Numero           = double.Parse(rows.Cell("A").GetString());
                        presupuesto.Inciso           = rows.Cell("B").GetString();
                        presupuesto.Descripcion      = rows.Cell("C").GetString();
                        presupuesto.UnidadDeMedida   = rows.Cell("D").GetString();
                        presupuesto.Cantidad         = double.Parse(cantidad.ToString());
                        presupuesto.PrecioUnitario   = importe;
                        presupuesto.Subtotal         = (cantidad * importe);
                        presupuesto.Parent           = padre;
                        uow.PresupuestosContratadosBL.Insert(presupuesto);
                    }
                }
                rows = rows.RowBelow();
                nregistros--;
                i++;
            }



            contrato.Subtotal = contrato.detallePresupuesto.Sum(p => p.Subtotal);
            contrato.IVA      = (contrato.Subtotal * decimal.Parse("0.16"));
            contrato.Total    = (contrato.Subtotal * decimal.Parse("1.16"));
            uow.ContratosDeObraBL.Update(contrato);

            obra.StatusControlFinanciero = 2;
            uow.ObraBusinessLogic.Update(obra);

            uow.SaveChanges();

            if (uow.Errors.Count == 0)
            {
                divMSGnoHayContrato.Style.Add("display", "none");
                divCargarArchivo.Style.Add("display", "none");
                divGuardarPresupuesto.Style.Add("display", "none");
                divTMP.Style.Add("display", "none");

                divPresupuesto.Style.Add("display", "block");

                cargarPresupuestoContratado();
            }
        }
예제 #14
0
        protected void btnCargarConceptosDeObra_Click(object sender, EventArgs e)
        {
            string R;
            int    usuario = int.Parse(Session["IdUser"].ToString());

            if (fileUpload.PostedFile.FileName.Equals(string.Empty))//vacio
            {
                return;
            }

            if (fileUpload.FileBytes.Length > 10485296)//Validar el tamaño del archivo
            {
                return;
            }

            R = CargarArchivoExcel(fileUpload.PostedFile); //Se guarda el archivo

            if (R == "error")
            {
                return;
            }


            _R.Value = R;
            var wb           = new XLWorkbook(R);
            var ws           = wb.Worksheet(1);
            var firstRowUsed = ws.FirstRow();
            var lastRowUsed  = ws.LastRowUsed();
            var rows         = ws.FirstRow();

            int nregistros = lastRowUsed.RowNumber() - firstRowUsed.RowNumber();

            BorrarTMPbyUsuario();

            this.idObra = int.Parse(Session["XidObra"].ToString());


            ContratosDeObra contrato = uow.ContratosDeObraBL.Get(p => p.ObraId == this.idObra).FirstOrDefault();

            nregistros++;
            int i = 0;

            decimal  cantidad;
            DateTime?inicio, termino;

            while (nregistros > 0)
            {
                if (i > 9)
                {
                    ProgramasDeObrasTMP obj = new ProgramasDeObrasTMP();

                    try
                    {
                        cantidad = decimal.Parse(rows.Cell("E").GetString());
                        inicio   = DateTime.Parse(rows.Cell("F").GetString());
                        termino  = DateTime.Parse(rows.Cell("G").GetString());
                    }
                    catch
                    {
                        cantidad = 0;
                        inicio   = null;
                        termino  = null;
                    }

                    obj.Usuario          = usuario;
                    obj.ContratoDeObraId = contrato.Id;

                    obj.Numero         = double.Parse(rows.Cell("A").GetString());
                    obj.Inciso         = rows.Cell("B").GetString();
                    obj.Descripcion    = rows.Cell("C").GetString();
                    obj.UnidadDeMedida = rows.Cell("D").GetString();
                    obj.Cantidad       = double.Parse(cantidad.ToString());
                    obj.Inicio         = inicio;
                    obj.Termino        = termino;

                    uow.ProgramasDeObraTMPBL.Insert(obj);
                }


                rows = rows.RowBelow();
                nregistros--;
                i++;
            }

            uow.SaveChanges();


            //evaluar los registros

            SqlConnection sqlConnection1 = new SqlConnection(uow.Contexto.Database.Connection.ConnectionString.ToString());
            SqlCommand    cmd            = new SqlCommand();
            SqlDataReader reader;

            cmd.CommandText = "sp_evaluarProgramDeObra";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection  = sqlConnection1;

            cmd.Parameters.Add("@usuario", usuario);
            cmd.Parameters.Add("@contrato", contrato.Id);
            sqlConnection1.Open();

            reader = cmd.ExecuteReader();
            sqlConnection1.Close();


            uow = new UnitOfWork(Session["IdUser"].ToString());



            this.grid.DataSource = uow.ProgramasDeObraTMPBL.Get(p => p.Usuario == usuario).ToList();
            this.grid.DataBind();

            this.divTMP.Style.Add("display", "block");

            List <ProgramasDeObrasTMP> listaFechas = uow.ProgramasDeObraTMPBL.Get(p => p.Usuario == usuario && p.Status != 1).ToList();

            if (listaFechas.Count == 0)
            {
                this.divCargarArchivo.Style.Add("display", "none");
                this.divGuardarProgramaDeObra.Style.Add("display", "block");
                this.divErrorEnLosRegistros.Style.Add("display", "none");
            }
            else
            {
                this.divErrorEnLosRegistros.Style.Add("display", "block");
            }
        }
예제 #15
0
        protected void btnCargarConceptos_Click(object sender, EventArgs e)
        {
            string R;
            int    usuario = int.Parse(Session["IdUser"].ToString());

            if (fileUpload.PostedFile.FileName.Equals(string.Empty))//vacio
            {
                return;
            }

            if (fileUpload.FileBytes.Length > 10485296)//Validar el tamaño del archivo
            {
                return;
            }

            R = CargarArchivoExcel(fileUpload.PostedFile); //Se guarda el archivo

            if (R == "error")
            {
                return;
            }


            _R.Value = R;
            var wb           = new XLWorkbook(R);
            var ws           = wb.Worksheet(1);
            var firstRowUsed = ws.FirstRow();
            var lastRowUsed  = ws.LastRowUsed();
            var rows         = ws.FirstRow();

            int nregistros = lastRowUsed.RowNumber() - firstRowUsed.RowNumber();

            BorrarTMPbyUsuario();

            this.idObra = int.Parse(Session["XidObra"].ToString());

            ContratosDeObra contrato = uow.ContratosDeObraBL.Get(p => p.ObraId == this.idObra).FirstOrDefault();

            nregistros++;
            int i = 0;

            decimal cantidad;

            while (nregistros > 0)
            {
                if (i > 9)
                {
                    EstimacionesConceptosTMP obj = new EstimacionesConceptosTMP();

                    try
                    {
                        cantidad = decimal.Parse(rows.Cell("E").GetString());
                    }
                    catch
                    {
                        cantidad = 0;
                    }

                    obj.Usuario          = usuario;
                    obj.ContratoDeObraId = contrato.Id;

                    obj.Numero         = double.Parse(rows.Cell("A").GetString());
                    obj.Inciso         = rows.Cell("B").GetString();
                    obj.Descripcion    = rows.Cell("C").GetString();
                    obj.UnidadDeMedida = rows.Cell("D").GetString();
                    obj.Cantidad       = double.Parse(cantidad.ToString());

                    obj.StatusFechas       = 1;
                    obj.StatusFechasNombre = " ";
                    uow.EstimacionesConceptosTMPBL.Insert(obj);
                }


                rows = rows.RowBelow();
                nregistros--;
                i++;
            }

            uow.SaveChanges();


            //evaluar los registros

            SqlConnection sqlConnection1 = new SqlConnection(uow.Contexto.Database.Connection.ConnectionString.ToString());
            SqlCommand    cmd            = new SqlCommand();
            SqlDataReader reader;

            cmd.CommandText = "sp_evaluarConceptosDeLaNuevaEstimacion";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Connection  = sqlConnection1;

            cmd.Parameters.Add("@usuario", usuario);
            cmd.Parameters.Add("@contrato", contrato.Id);
            sqlConnection1.Open();

            reader = cmd.ExecuteReader();
            sqlConnection1.Close();

            uow = new UnitOfWork(Session["IdUser"].ToString());


            this.grid.DataSource = uow.EstimacionesConceptosTMPBL.Get(p => p.Usuario == usuario).ToList();
            this.grid.DataBind();


            List <EstimacionesConceptosTMP> listaConceptos = uow.EstimacionesConceptosTMPBL.Get(p => p.Usuario == usuario).ToList();

            decimal importeEstimado, iva, total;
            decimal amortizacion, ret5, ret2, ret2bis, sancion, importefinal;

            importeEstimado = 0;
            iva             = 0;
            total           = 0;
            amortizacion    = 0;
            ret5            = 0;
            ret2            = 0;
            ret2bis         = 0;
            sancion         = 0;
            importefinal    = 0;

            foreach (EstimacionesConceptosTMP item in listaConceptos)
            {
                importeEstimado = importeEstimado + item.subtotal;
                iva             = iva + item.iva;
                total           = total + item.total;
                amortizacion    = amortizacion + item.amortizacion;
                ret5            = ret5 + item.retencion5;
                ret2            = ret2 + item.retencion2;
                ret2bis         = ret2bis + item.retencion2SyV;
                sancion         = sancion + item.sancion;
                importefinal    = importefinal + item.importeFinal;
            }


            txtImporteEstimado.Text = importeEstimado.ToString("C2");
            txtIVA.Text             = iva.ToString("C2");
            txtImporteTotal.Text    = total.ToString("C2");
            txtAmortizacion.Text    = amortizacion.ToString("C2");
            txtRetencion5.Text      = ret5.ToString("C2");
            txtRetencion2.Text      = ret2.ToString("C2");
            txtRet2Bis.Text         = ret2bis.ToString("C2");
            txtImporteApagar.Text   = importefinal.ToString("C0");


            List <Estimaciones> listaEstimaciones = uow.EstimacionesBL.Get(p => p.ContratoDeObra.ObraId == this.idObra).ToList();

            txtNumEstimacion.Text = (listaEstimaciones.Max(p => p.NumeroDeEstimacion) + 1).ToString();

            this.divTMP.Style.Add("display", "block");
            this.divCargarArchivo.Style.Add("display", "none");
            this.divBtnImprimir.Style.Add("display", "block");
        }
예제 #16
0
        protected void btnGuardarEstimacion_Click(object sender, EventArgs e)
        {
            int usuario = int.Parse(Session["IdUser"].ToString());

            this.idObra = int.Parse(Session["XidObra"].ToString());

            Estimaciones    estimacion = new Estimaciones();
            ContratosDeObra contrato   = uow.ContratosDeObraBL.Get(p => p.ObraId == this.idObra).FirstOrDefault();



            decimal importeEstimado, iva, total;
            decimal amortizacion, ret5, ret2, ret2Bis, importefinal;

            importeEstimado = 0;
            iva             = 0;
            total           = 0;
            amortizacion    = 0;
            ret5            = 0;
            ret2            = 0;
            ret2Bis         = 0;
            importefinal    = 0;

            List <EstimacionesConceptosTMP> listaConceptos = uow.EstimacionesConceptosTMPBL.Get(p => p.Usuario == usuario && p.Status == 1).ToList();

            foreach (EstimacionesConceptosTMP item in listaConceptos)
            {
                importeEstimado = importeEstimado + item.subtotal;
                iva             = iva + item.iva;
                total           = total + item.total;
                amortizacion    = amortizacion + item.amortizacion;
                ret5            = ret5 + item.retencion5;
                ret2            = ret2 + item.retencion2;
                ret2Bis         = ret2Bis + item.retencion2SyV;
                importefinal    = importefinal + item.importeFinal;
            }

            List <Estimaciones> listaEstimaciones = uow.EstimacionesBL.Get(p => p.ContratoDeObra.ObraId == this.idObra).ToList();



            estimacion.ContratoDeObraId   = contrato.Id;
            estimacion.NumeroDeEstimacion = listaEstimaciones.Max(p => p.NumeroDeEstimacion) + 1;
            estimacion.FechaDeEstimacion  = DateTime.Parse(dtpFecha.Value.ToString());

            estimacion.ImporteEstimado      = importeEstimado;
            estimacion.IVA                  = iva;
            estimacion.Total                = total;
            estimacion.AmortizacionAnticipo = amortizacion;
            estimacion.Retencion2AlMillar   = ret2;
            estimacion.Retencion5AlMillar   = ret5;
            estimacion.Retencion2AlMillarSV = ret2Bis;
            estimacion.Sanciones            = 0;
            estimacion.ISR                  = 0;
            estimacion.Otros                = 0;
            estimacion.PeriodoInicio        = DateTime.Parse(dtpFecha.Value.ToString());
            estimacion.PeriodoTermino       = DateTime.Parse(dtpFecha.Value.ToString());
            estimacion.ImporteNetoACobrar   = importefinal;
            estimacion.ConceptoDePago       = "est" + txtNumEstimacion.Text;
            estimacion.Status               = 1;
            estimacion.FolioCL              = "123";

            uow.EstimacionesBL.Insert(estimacion);



            foreach (EstimacionesConceptosTMP item in listaConceptos)
            {
                EstimacionesConceptos concepto = new EstimacionesConceptos();

                concepto.Estimacion = estimacion;
                concepto.PresupuestoContratadoId = item.PresupuestoContratadoId;
                concepto.Cantidad = item.Cantidad;
                concepto.Subtotal = item.subtotal;

                uow.EstimacionesConceptosBL.Insert(concepto);
            }

            Obra obra = uow.ObraBusinessLogic.GetByID(this.idObra);

            obra.StatusControlFinanciero = 6;
            uow.ObraBusinessLogic.Update(obra);



            //temporal mientras no esta el modulo de registrar pagos
            Estimaciones lastEstimacion = uow.EstimacionesBL.Get(p => p.NumeroDeEstimacion < estimacion.NumeroDeEstimacion).OrderByDescending(q => q.NumeroDeEstimacion).First();

            lastEstimacion.Status = 2;
            uow.EstimacionesBL.Update(lastEstimacion);

            uow.SaveChanges();

            if (uow.Errors.Count == 0)
            {
                Response.Redirect("wfEstimaciones.aspx");
            }
        }