Example #1
0
        private void popupWindowShowActionPresupuestoReal_CustomizePopupWindowParams(object sender, DevExpress.ExpressApp.Actions.CustomizePopupWindowParamsEventArgs e)
        {
            IObjectSpace      objectSpace = Application.CreateObjectSpace();
            PresupuestoFiltro pf          = objectSpace.CreateObject <PresupuestoFiltro>();

            e.View = Application.CreateDetailView(objectSpace, "PresupuestoFiltro_DetailView", true, pf);
        }
Example #2
0
        private void popupWindowShowActionPresupuestoReal_Execute(object sender, DevExpress.ExpressApp.Actions.PopupWindowShowActionExecuteEventArgs e)
        {
            PresupuestoFiltro obj = e.PopupWindowViewCurrentObject as PresupuestoFiltro;

            if (obj != null)
            {
                IObjectSpace       objectSpace = Application.CreateObjectSpace();
                List <MovimientoB> lista;
                GroupOperator      fil  = new GroupOperator();
                Presupuesto        prsu = objectSpace.FindObject <Presupuesto>(null);

                if (prsu != null)
                {
                    decimal suma;
                    foreach (ConceptoP cp in prsu.Partidas)
                    {
                        if (cp.Concepto != null)
                        {
                            fil.Operands.Clear();
                            fil.Operands.Add(CriteriaOperator.And(new BinaryOperator("FechaAplicacion", obj.FchIncl, BinaryOperatorType.GreaterOrEqual),
                                                                  new BinaryOperator("FechaAplicacion", obj.FchFnl, BinaryOperatorType.LessOrEqual)));
                            fil.Operands.Add(new BinaryOperator("Concepto", cp.Concepto));

                            IList col = objectSpace.CreateCollection(typeof(MovimientoB), fil);
                            lista = col.Cast <MovimientoB>().ToList();
                            if (lista != null && lista.Count > 0)
                            {
                                suma     = lista.Sum(item => item.Monto);
                                cp.MntRl = suma;
                            }
                            else
                            {
                                cp.MntRl = 0;
                            }
                        }
                    }

                    IList lis = objectSpace.CreateCollection(typeof(ConceptoB));
                    foreach (ConceptoB cpt in lis)
                    {
                        prsu.Partidas.Filter = new BinaryOperator("Concepto", cpt);
                        if (prsu.Partidas.Count == 0)
                        {
                            fil.Operands.Clear();
                            fil.Operands.Add(CriteriaOperator.And(new BinaryOperator("FechaAplicacion", obj.FchIncl, BinaryOperatorType.GreaterOrEqual),
                                                                  new BinaryOperator("FechaAplicacion", obj.FchFnl, BinaryOperatorType.LessOrEqual)));
                            fil.Operands.Add(new BinaryOperator("Concepto", cpt));

                            IList col = objectSpace.CreateCollection(typeof(MovimientoB), fil);
                            lista = col.Cast <MovimientoB>().ToList();
                            if (lista != null && lista.Count > 0)
                            {
                                suma = lista.Sum(item => item.Monto);

                                ConceptoP cp = objectSpace.CreateObject <ConceptoP>();
                                cp.Concepto = cpt;
                                cp.MntRl    = suma;

                                prsu.Partidas.Add(cp);
                            }
                        }
                    }

                    objectSpace.CommitChanges();
                    View.Refresh(true);
                }
            }
        }