void selectSemesterAcception_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            ObjectSpace objectSpace = Application.CreateObjectSpace();
            ListView lv = ((ListView)((WindowController)sender).Window.View);
            Semester semester = lv.SelectedObjects.Count == 0 ? null : lv.SelectedObjects[0] as Semester;
            GroupOperator classroomsOp = new GroupOperator(CriteriaOperator.Parse("1=0"));
            ContainsOperator biOperator;
            string strParse = "";
            if (semester != null)
            {

                foreach (StudentClass studentClass in View.SelectedObjects)
                {
                    Data.CreateStudentClassTimetableData(objectSpace, studentClass.ClassCode, semester.SemesterName);

                    biOperator = new ContainsOperator("StudentClasses", new BinaryOperator("ClassCode", studentClass.ClassCode));
                    classroomsOp = new GroupOperator(GroupOperatorType.Or, classroomsOp, biOperator);

                    strParse += (strParse == "" ? string.Format("ClassCode='{0}'", studentClass.ClassCode) :
                        string.Format(" or ClassCode='{0}'", studentClass.ClassCode));
                }

                ReportData reportData = objectSpace.FindObject<ReportData>(
                    new BinaryOperator("Name", "Lịch lớp biên chế"));

                ReportServiceController rsc = ((WindowController)sender).Frame.GetController<ReportServiceController>();
                rsc.ShowPreview((IReportData)reportData, CriteriaOperator.Parse(strParse)); //classroomsOp);
            }
        }
예제 #2
0
        /// <summary>
        /// 判断会员编号是否存在
        /// </summary>
        /// <param name="memberNo">会员编号</param>
        /// <returns>存在;true;不存在;false</returns>
        public bool IsExistMember(string memberNo)
        {
            bool result = false;

            if (string.IsNullOrEmpty(memberNo))
            {
                return result;
            }

            // 查询条件
            GroupOperator groupCriteria = new GroupOperator(
                GroupOperatorType.And,
                new BinaryOperator("State", 0, BinaryOperatorType.Equal),
                new BinaryOperator("Member_No", memberNo, BinaryOperatorType.Equal)
            );

            t_Member_Info memberInfo = Session.DefaultSession.FindObject<t_Member_Info>(groupCriteria);

            if (memberInfo != null)
            {
                result = true;
            }

            return result;
        }
 private static BinaryOperator getGroupOperator(out BinaryOperator binaryOperator2,
                                                out CriteriaOperator groupOperator)
 {
     var binaryOperator = new BinaryOperator("dfs", 324);
     binaryOperator2 = new BinaryOperator("sdfs", 3455);
     groupOperator = new GroupOperator(binaryOperator, binaryOperator2);
     return binaryOperator;
 }
예제 #4
0
        /// <summary>
        /// 检索消费备注项目列表
        /// </summary>
        /// <returns></returns>
        public XPCollection<t_Consume_Content> SearchConsumItems()
        {
            GroupOperator groupCriteria = new GroupOperator(
                GroupOperatorType.And,
                new BinaryOperator("State", 0, BinaryOperatorType.Equal)
            );

            XPCollection<t_Consume_Content> res = new XPCollection<t_Consume_Content>(theCriteria: groupCriteria);
            return res;
        }
 GroupOperator GetCriteria() {
     var groupOperator = new GroupOperator(GroupOperatorType.Or);
     foreach (var memberInfo in _searchAbleMemberInfos) {
         var value = memberInfo.GetValue(View.CurrentObject);
         if (value is string)
             value = "%" + value + "%";
         groupOperator.Operands.Add(new BinaryOperator(memberInfo.Name, value, value is string ? BinaryOperatorType.Like : BinaryOperatorType.Equal));
     }
     return groupOperator;
 }
        public void ExtractGroupedNullOperator()
        {
            var nullOperator1 = new NullOperator();
            var nullOperator2 = new NullOperator();
            var groupOperator = new GroupOperator(nullOperator1, nullOperator2);

            CriteriaOperatorExtractor binaryOperatorExtractor = GetBinaryOperatorExtractor(groupOperator);

            Assert.AreEqual(nullOperator1, binaryOperatorExtractor.NullOperators[0]);
            Assert.AreEqual(nullOperator2, binaryOperatorExtractor.NullOperators[1]);
        }
예제 #7
0
        public static void ClearFilter(this GridView gv, string propertyName)
        {
            var Criteria = gv.GetCriteria() == null ? new List<CriteriaOperator>() : gv.GetCriteria().ToList();
            var ActiveCriteria = new GroupOperator(Criteria.ToArray());

            if (ReferenceEquals(ActiveCriteria, null)) return;

            gv.ClearColumnsFilter();
            gv.ActiveFilterCriteria = ActiveCriteria.ClearFilter(propertyName);
            gv.ApplyColumnsFilter();
        }
예제 #8
0
        public XPCollection<t_Product_Info> SearchProductList()
        {
            GroupOperator groupCriteria = new GroupOperator(
                GroupOperatorType.And,
                new BinaryOperator("State", 0, BinaryOperatorType.Equal)
            );

            XPCollection<t_Product_Info> res = new XPCollection<t_Product_Info>(theCriteria: groupCriteria);

            return res;
        }
 GroupOperator GetCriteria() {
     var memberInfos = new DetailViewInfoNodeWrapper(View.Info).Editors.Items.Where(wrapper => wrapper.Node.GetAttributeEnumValue(SearchModeAttributeName, SearchMemberMode.Unknown) == SearchMemberMode.Include).Select(nodeWrapper => View.ObjectTypeInfo.FindMember(nodeWrapper.PropertyName));
     var groupOperator = new GroupOperator(GroupOperatorType.Or);
     foreach (var memberInfo in memberInfos) {
         var value = memberInfo.GetValue(View.CurrentObject);
         if (value is string)
             value = "%" + value + "%";
         groupOperator.Operands.Add(new BinaryOperator(memberInfo.Name,value,value is string?BinaryOperatorType.Like : BinaryOperatorType.Equal));
     }
     return groupOperator;
 }
예제 #10
0
        /// <summary>
        /// 获得店铺列表
        /// </summary>
        /// <returns>XPCollection</returns>
        public XPCollection<t_Shopping_Guide> GetGuideList()
        {
            // 拼接查询条件
            GroupOperator groupCriteria = new GroupOperator(
                GroupOperatorType.And,
                new BinaryOperator("State", RecordState.Normal, BinaryOperatorType.Equal)
                );
            // 根据条件查询店铺列表
            XPCollection<t_Shopping_Guide> xpGuideList = new XPCollection<t_Shopping_Guide>(theCriteria: groupCriteria);

            // 返回查询结果
            return xpGuideList;
        }
예제 #11
0
 public static CriteriaOperator CombineCriteria(params CriteriaOperator[] criteriaOperators)
 {
     CriteriaOperator totalCriteria = null;
     var operators = new List<CriteriaOperator>();
     foreach (CriteriaOperator op in criteriaOperators)
         if (!ReferenceEquals(null, op))
         {
             if (op.Equals(EmptyCollectionCriteria))
                 return EmptyCollectionCriteria;
             operators.Add(op);
         }
     if (operators.Count != 0)
         totalCriteria = new GroupOperator(GroupOperatorType.And, operators);
     return totalCriteria;
 }
예제 #12
0
 /// <contentfrom cref="ISecurityRule.GetSelectFilterCriteria" />
 public bool GetSelectFilterCriteria(DevExpress.Xpo.SecurityContext context, XPClassInfo classInfo, out CriteriaOperator criteria)
 {
     List<CriteriaOperator> subList = new List<CriteriaOperator>();
     CriteriaOperator subCriteria;
     foreach (ISecurityRule rule in rules)
         if (rule.GetSelectFilterCriteria(context, classInfo, out subCriteria))
             subList.Add(subCriteria);
     if (subList.Count == 0)
         criteria = null;
     else if (subList.Count == 1)
         criteria = subList[0];
     else
         criteria = new GroupOperator(GroupOperatorType.And, subList.ToArray());
     return subList.Count > 0;
 }
예제 #13
0
        /// <summary>
        /// 根据ID查询消费项目
        /// </summary>
        /// <param name="ContentID"></param>
        /// <param name="DBSession"></param>
        /// <returns></returns>
        public t_Consume_Content GetContentByID(string ContentID, Session DBSession)
        {
            if (string.IsNullOrEmpty(ContentID))
            {
                return null;
            }

            // 查询条件
            GroupOperator groupCriteria = new GroupOperator(
                GroupOperatorType.And,
                new BinaryOperator("State", 0, BinaryOperatorType.Equal),
                new BinaryOperator("Content_ID", ContentID, BinaryOperatorType.Equal)
            );

            return DBSession.FindObject<t_Consume_Content>(groupCriteria);
        }
예제 #14
0
        /// <summary>
        /// 根据会员等级ID取得会员等级信息
        /// </summary>
        /// <returns></returns>
        public t_Member_Grade GetMemberGradeByID(int gradeId)
        {
            if (gradeId == 0)
            {
                return null;
            }

            // 查询条件
            GroupOperator groupCriteria = new GroupOperator(
                GroupOperatorType.And,
                new BinaryOperator("State", 0, BinaryOperatorType.Equal),
                new BinaryOperator("Member_Grade_ID", gradeId, BinaryOperatorType.Equal)
            );

            t_Member_Grade gradeInfo = Session.DefaultSession.FindObject<t_Member_Grade>(groupCriteria);
            return gradeInfo;
        }
        public XPCollection<t_Bonus_Exchange_History> SearchExchangeHistoryByMemberId(String memberid)
        {
            if (string.IsNullOrEmpty(memberid))
            {
                return null;
            }

            // 查询条件:会员ID,数据状态正常
            GroupOperator groupCriteria = new GroupOperator(
                GroupOperatorType.And,
                new BinaryOperator("State", 0, BinaryOperatorType.Equal),
                new BinaryOperator("Member_ID", memberid, BinaryOperatorType.Equal)
            );

            XPCollection<t_Bonus_Exchange_History> exChangeHistory = new XPCollection<t_Bonus_Exchange_History>(theCriteria: groupCriteria);
            return exChangeHistory;
        }
        public void ExtractNestedGroupOperator()
        {
            BinaryOperator binaryOperator2;
            CriteriaOperator nestedGroupOperator;
            BinaryOperator binaryOperator1 = getGroupOperator(out binaryOperator2, out nestedGroupOperator);
            var groupOperator = new GroupOperator(nestedGroupOperator, binaryOperator1, binaryOperator2);
            CriteriaOperator containsOperator = new ContainsOperator("", groupOperator);

            var extractor = new CriteriaOperatorExtractor();
            extractor.Extract(containsOperator);

            Assert.AreEqual(4, extractor.BinaryOperators.Count);
            Assert.AreEqual(binaryOperator1, extractor.BinaryOperators[0]);
            Assert.AreEqual(binaryOperator2, extractor.BinaryOperators[1]);
            Assert.AreEqual(binaryOperator1, extractor.BinaryOperators[2]);
            Assert.AreEqual(binaryOperator2, extractor.BinaryOperators[3]);
        }
예제 #17
0
        /// <summary>
        /// 根据会员编号取得会员信息
        /// </summary>
        /// <param name="MemberID"></param>
        /// <returns></returns>
        public t_Member_Info GetMemberInfoByMemberNo(string MemberNo, Session DBSession)
        {
            if (string.IsNullOrEmpty(MemberNo))
            {
                return null;
            }

            // 查询条件:会员ID,数据状态正常
            GroupOperator groupCriteria = new GroupOperator(
                GroupOperatorType.And,
                new BinaryOperator("State", 0, BinaryOperatorType.Equal),
                new BinaryOperator("Member_NO", MemberNo, BinaryOperatorType.Equal)
            );

            t_Member_Info memberInfo = DBSession.FindObject<t_Member_Info>(groupCriteria);

            return memberInfo;
        }
예제 #18
0
        /// <summary>
        /// 检查消费备注是否已存在
        /// </summary>
        /// <param name="content">消费项目</param>
        /// <returns>存在;true;不存在;false</returns>
        public bool IsExitConsumeContent(string content)
        {
            bool res = false;

            // 查询条件
            GroupOperator groupCriteria = new GroupOperator(
                GroupOperatorType.And,
                new BinaryOperator("State", 0, BinaryOperatorType.Equal),
                new BinaryOperator("Content", content, BinaryOperatorType.Equal)
            );

            t_Consume_Content cc = Session.DefaultSession.FindObject<t_Consume_Content>(groupCriteria);

            if (cc != null)
            {
                res = true;
            }

            return res;
        }
예제 #19
0
 public object Visit(GroupOperator theOperator)
 {
     return BooleanCriteriaStateObject.Logical;
 }
예제 #20
0
 /// <summary>  Return the text that should be inserted for a logical <c>AND</c> or <c>OR</c> operation</summary>
 public abstract string GetOperator(GroupOperator op);
예제 #21
0
 public object Visit(GroupOperator theOperator)
 {
     return evaluatorCore.Visit(theOperator);
 }
예제 #22
0
        private void barButtonItemQuery_ItemClick(object sender, ItemClickEventArgs e)
        {
            Cursor saveCursor = Cursor.Current;

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                StaticInfo.DataAgg(this.barStaticItemInfo);

                DateTime inizio = (DateTime)this.barEditItemDalla.EditValue;
                DateTime fine   = (DateTime)this.barEditItemAlla.EditValue;

                GroupOperator criteria1 = new GroupOperator(new CriteriaOperator[]
                {
                    new BinaryOperator("DataContabile", inizio, BinaryOperatorType.GreaterOrEqual),
                    new BinaryOperator("DataContabile", fine, BinaryOperatorType.LessOrEqual)
                });

                GroupOperator criteria2 = new GroupOperator(new CriteriaOperator[]
                {
                    new BinaryOperator("Vendita.DataContabile", inizio, BinaryOperatorType.GreaterOrEqual),
                    new BinaryOperator("Vendita.DataContabile", fine, BinaryOperatorType.LessOrEqual)
                });

                GroupOperator criteriaFatture = new GroupOperator(new CriteriaOperator[]
                {
                    new BinaryOperator("DataContabile", inizio, BinaryOperatorType.GreaterOrEqual),
                    new BinaryOperator("DataContabile", fine, BinaryOperatorType.LessOrEqual)
                });

                if (this.barCheckItemUtente.Checked)
                {
                    criteria1.Operands.Add(new BinaryOperator("Utente.Oid", Program.UtenteCollegato.Oid));
                    criteria2.Operands.Add(new BinaryOperator("Vendita.Utente.Oid", Program.UtenteCollegato.Oid));
                    criteriaFatture.Operands.Add(new BinaryOperator("Utente.Oid", Program.UtenteCollegato.Oid));
                }

                if (this.barCheckItemPostazione.Checked)
                {
                    criteria1.Operands.Add(new BinaryOperator("Postazione.Oid", Program.Postazione.Oid));
                    criteria2.Operands.Add(new BinaryOperator("Vendita.Postazione.Oid", Program.Postazione.Oid));
                }
                else
                {
                    GroupOperator pos1 = new GroupOperator(GroupOperatorType.Or);
                    GroupOperator pos2 = new GroupOperator(GroupOperatorType.Or);
                    GroupOperator pos3 = new GroupOperator(GroupOperatorType.Or);

                    XPCollection <Postazione> postazioni = Program.UtenteCollegato.GetMioElencoPostazioni(this.unitOfWork1, Program.Postazione);
                    foreach (Postazione postazione in postazioni)
                    {
                        pos1.Operands.Add(new BinaryOperator("Postazione.Oid", postazione.Oid));
                        pos2.Operands.Add(new BinaryOperator("Vendita.Postazione.Oid", postazione.Oid));
                        pos3.Operands.Add(new BinaryOperator("Postazione.Oid", Program.Postazione.Oid));
                    }

                    criteria1.Operands.Add(pos1);
                    criteria2.Operands.Add(pos2);
                    criteriaFatture.Operands.Add(pos2);
                }

                this.xpServerCollectionSourceVendite.FixedFilterCriteria = criteria1;
                this.xpCollectionRigaVenditaVariante.Criteria            = criteria2;
                this.xpCollectionFatture.Criteria = criteriaFatture;

                this.gridViewVendite.BestFitMaxRowCount = 50;
                this.gridViewVendite.BestFitColumns();

                this.gridViewRigheStampa.BestFitMaxRowCount = 50;
                this.gridViewRigheStampa.BestFitColumns();

                this.gridViewFatture.BestFitMaxRowCount = 50;
                this.gridViewFatture.BestFitColumns();

                this.xtraTabPageFatture.Text = string.Format("Fatture emesse ({0})", this.xpCollectionFatture.Count);
            }
            finally
            {
                Cursor.Current = saveCursor;
            }
        }
예제 #23
0
 protected override void ApplyCriteriaCore(CriteriaOperator criteria)
 {
     ((XPView)originalCollection).Criteria = GroupOperator.Combine(GroupOperatorType.And, _fixedCriteria,
                                                                   criteria);
 }
예제 #24
0
        protected void cpBooking_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            session = XpoHelper.GetNewSession();


            switch (e.Parameter)
            {
            case "view":

                grdBooking.DetailRows.CollapseAllRows();

                if (Session["SaleBillId"] == null)
                {
                    return;
                }

                session = XpoHelper.GetNewSession();
                SalesInvoice salesInvoice = session.GetObjectByKey <SalesInvoice>(Guid.Parse(Session["SaleBillId"].ToString()));

                CriteriaOperator filter = new BinaryOperator("SalesInvoiceInventoryTransactionId", Guid.Parse(Session["SaleBillId"].ToString()), BinaryOperatorType.Equal);
                XPCollection <SalesInvoiceInventoryAccountingTransaction> saleInvoiceTransaction = new XPCollection <SalesInvoiceInventoryAccountingTransaction>(session, filter);

                if (saleInvoiceTransaction.Count > 0)
                {
                    foreach (SalesInvoiceInventoryAccountingTransaction item in saleInvoiceTransaction)
                    {
                        if (item.RowStatus == ROW_NOT_DELETE)
                        {
                            grdBooking.Columns["Thao tác"].Visible = false;
                            break;
                        }
                        else
                        {
                            grdBooking.Columns["Thao tác"].Visible = true;
                        }
                    }
                }
                else
                {
                    grdBooking.AddNewRow();
                    grdBooking.Columns["Thao tác"].Visible = true;
                }

                cpBooking.JSProperties.Add("cpEnable", "true");


                /////


                break;

            case "booking":

                salesInvoice = session.GetObjectByKey <SalesInvoice>(Guid.Parse(Session["SaleBillId"].ToString()));

                filter = new BinaryOperator("SalesInvoiceInventoryTransactionId", Guid.Parse(Session["SaleBillId"].ToString()), BinaryOperatorType.Equal);
                saleInvoiceTransaction = new XPCollection <SalesInvoiceInventoryAccountingTransaction>(session, filter);

                foreach (SalesInvoiceInventoryAccountingTransaction item in saleInvoiceTransaction)
                {
                    double credit = 0;
                    double debit  = 0;

                    filter = new GroupOperator(GroupOperatorType.And,
                                               new BinaryOperator("TransactionId", item.TransactionId, BinaryOperatorType.Equal),
                                               new BinaryOperator("RowStatus", ROW_NEW, BinaryOperatorType.Equal));
                    XPCollection <GeneralJournal> generalJournal = new XPCollection <GeneralJournal>(session, filter);

                    foreach (GeneralJournal x in generalJournal)
                    {
                        filter = new GroupOperator(GroupOperatorType.And,
                                                   new BinaryOperator("TransactionId", item.TransactionId, BinaryOperatorType.Equal),
                                                   new BinaryOperator("AccountId", x.AccountId, BinaryOperatorType.Equal),
                                                   new BinaryOperator("RowStatus", ROW_NEW, BinaryOperatorType.Equal));

                        XPCollection <GeneralJournal> generalJ = new XPCollection <GeneralJournal>(session, filter);
                        if (generalJ.Count >= 2)
                        {
                            cpBooking.JSProperties.Add("cpUnbooked", "1");
                            return;
                        }

                        credit += x.Credit;
                        debit  += x.Debit;
                    }

                    if (credit != debit)
                    {
                        cpBooking.JSProperties.Add("cpUnbooked", "2");
                        return;
                    }
                }

                foreach (SalesInvoiceInventoryAccountingTransaction item in saleInvoiceTransaction)
                {
                    item.RowStatus = ROW_NOT_DELETE;
                    item.Save();

                    filter = new BinaryOperator("TransactionId", item.TransactionId, BinaryOperatorType.Equal);
                    XPCollection <GeneralJournal> generalJournal = new XPCollection <GeneralJournal>(session, filter);
                    double milsec = 0;
                    foreach (GeneralJournal x in generalJournal)
                    {
                        NAS.DAL.Accounting.AccountChart.Account account = session.GetObjectByKey <NAS.DAL.Accounting.AccountChart.Account>(x.AccountId.AccountId);
                        //General general = new General();
                        //general.BalanceUpdate(session, account, x, false, x.Debit-x.Credit);
                        AccountingBO accountBO = new AccountingBO();
                        accountBO.CreateGeneralLedger(session, x.TransactionId.TransactionId, x.GeneralJournalId, milsec);

                        milsec += 10;
                    }
                }


                filter = new BinaryOperator("SalesInvoiceInventoryTransactionId", Guid.Parse(Session["SaleBillId"].ToString()), BinaryOperatorType.Equal);
                SalesInvoiceInventoryAccountingTransaction purchaseInvoiceInventoryTransaction = session.FindObject <SalesInvoiceInventoryAccountingTransaction>(filter);

                purchaseInvoiceInventoryTransaction.RowStatus = ROW_NOT_DELETE;
                purchaseInvoiceInventoryTransaction.Save();

                grdBooking.DetailRows.CollapseAllRows();
                grdBooking.Columns["Thao tác"].Visible = false;

                cpBooking.JSProperties.Add("cpEnable", "true");

                break;


            default:
                break;
            }
        }
예제 #25
0
        static void Main()
        {
            //
            // XPOには、LINQ to XPOの他にCriteriaOperatorを利用したクエリ方法がある。
            // CriteriaOperator系のクラスは、DevExpress.Data.Filterling名前空間に配置されている。
            //
            // CriteriaOperatorで構築した抽出条件は、XPCollectionやXPViewなどのXPOコレクションクラスにて
            // 絞り込み条件として指定できる。
            //
            // 使用方法としては、以下の2種類のやり方がある。
            //   ・BinaryOperatorなどの各Operatorクラスをインスタンス化して条件を構築.
            //   ・CriteriaOperator.Parseメソッドに対して、文字列で条件を指定して構築.
            //
            // 参考リソース
            //   http://documentation.devexpress.com/#XPO/CustomDocument2258
            //   http://documentation.devexpress.com/#XPO/CustomDocument2132
            //   http://documentation.devexpress.com/#XPO/CustomDocument2047
            //   http://documentation.devexpress.com/#XPO/CustomDocument2129
            //
            var dataStore = new InMemoryDataStore();
            var dataLayer = new SimpleDataLayer(dataStore);

            //
            // 初期データ設定
            //
            using (var uow = new UnitOfWork(dataLayer))
            {
                for (int i = 0; i < 10; i++)
                {
                    new Customer(uow)
                    {
                        Name = string.Format("Customer-{0}", i), Age = i + 20
                    };
                }

                uow.CommitChanges();
            }

            //
            // Operatorクラスを利用して条件を構築.
            //
            var opGreater = new BinaryOperator("Age", 25, BinaryOperatorType.GreaterOrEqual);

            using (var uow = new UnitOfWork(dataLayer))
            {
                foreach (var item in new XPCollection <Customer>(uow)
                {
                    Criteria = opGreater
                })
                {
                    Console.WriteLine(item.Name);
                }
            }

            //
            // CriteriaOperator.Parseメソッドを利用して条件を構築.
            //
            var criteria = CriteriaOperator.Parse("Age >= 25");

            using (var uow = new UnitOfWork(dataLayer))
            {
                foreach (var item in new XPCollection <Customer>(uow)
                {
                    Criteria = criteria
                })
                {
                    Console.WriteLine(item.Name);
                }
            }

            //
            // Operatorクラスのチェイン (複数条件の指定)
            //   条件同士をand, orするには、GroupOperatorの静的メソッドを利用する.
            //
            var opLike = new BinaryOperator("Name", "%7%", BinaryOperatorType.Like);
            var opAnd  = GroupOperator.And(opGreater, opLike);

            using (var uow = new UnitOfWork(dataLayer))
            {
                foreach (var item in new XPCollection <Customer>(uow)
                {
                    Criteria = opAnd
                })
                {
                    Console.WriteLine(new { Name = item.Name, Age = item.Age });
                }
            }

            //
            // CriteriaOperator.Parseメソッドで複数条件の指定.
            //   条件同士をand, orするには、そのまま文字列中にand, orと記述すればよい。
            //
            criteria = CriteriaOperator.Parse("Age >= 25 AND Name like '%7%'");
            using (var uow = new UnitOfWork(dataLayer))
            {
                foreach (var item in new XPCollection <Customer>(uow)
                {
                    Criteria = criteria
                })
                {
                    Console.WriteLine(new { Name = item.Name, Age = item.Age });
                }
            }
        }
예제 #26
0
 public void AddCriteria(GroupOperatorType groupOperatorType, CriteriaOperator criteriaOperator)
 {
     Criteria = new GroupOperator(groupOperatorType, Criteria, criteriaOperator);
 }
예제 #27
0
        private void SubmitXpath(object value, string expected, string attributeName, ComparisonOperator xpathOp, GroupOperator queryOp, params ResourceObject[] matchResources)
        {
            XPathQuery predicate = new XPathQuery(attributeName, xpathOp, value);
            string     xpath     = XPathFilterBuilder.CreateFilter(UnitTestHelper.ObjectTypeUnitTestObjectName, queryOp, predicate);

            Assert.AreEqual(expected, xpath);

            ISearchResultCollection results = client.GetResources(xpath);

            if (results.Count == 0)
            {
                if (matchResources != null && matchResources.Length > 0)
                {
                    Assert.Fail("The query returned no results");
                }
            }

            if (matchResources == null || matchResources.Length == 0)
            {
                Assert.Fail("The query returned results where none were expectedXpath");
            }

            if (results.Count != matchResources.Length)
            {
                Assert.Fail("The query returned an unexpected number of results");
            }

            if (!results.All(t => matchResources.Any(u => u.ObjectID == t.ObjectID)))
            {
                Assert.Fail("The query did not return the correct results");
            }
        }
예제 #28
0
 /// <summary>
 /// Factory method that creates a new IPredicateGroup predicate.
 /// Predicate groups can be joined together with other predicate groups.
 /// </summary>
 /// <param name="op">The grouping operator to use when joining the predicates (AND / OR).</param>
 /// <param name="predicate">A list of predicates to group.</param>
 /// <returns>An instance of IPredicateGroup.</returns>
 public static IPredicateGroup Group(GroupOperator op, params IPredicate[] predicate) =>
 new PredicateGroup
 {
     Operator = op, Predicates = predicate
 };
예제 #29
0
        private void simpleButtonReport_Click(object sender, EventArgs e)
        {
            _AnnoInCorso = this.dateEditInizio.DateTime.Year;
            _Inizio      = this.dateEditInizio.DateTime;
            _Fine        = this.dateEditFine.DateTime;
            //_Soggetto = this.lookUpEdit1.EditValue as SoggettoEconomico;
            _Ingressi = new List <Ingresso>();
            _List     = new List <DatiReport03>();
            _Aperture = new GestoreAperture();

            //if (_Soggetto == null)
            //{
            //    XtraMessageBox.Show("Selezionare un soggetto");
            //    return;
            //}

            foreach (var item in this.checkedListBoxControl1.CheckedItems)
            {
                Ingresso ingresso = item as Ingresso;
                if (ingresso != null)
                {
                    _Ingressi.Add(ingresso);
                }
            }

            if (_Ingressi.Count == 0)
            {
                XtraMessageBox.Show("Selezionare un ingresso");
                return;
            }

            if (this.dateEditFine.DateTime.Date >= DateTime.Now.Date)
            {
                XtraMessageBox.Show("Data Fine non può essere maggiore della data odierna", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Cursor saveCursor = Cursor.Current;

            try
            {
                Cursor.Current = Cursors.WaitCursor;

                InitList(_Inizio);

                _Aperture.CaricaApertureIngressi(_Inizio, _Fine, this.unitOfWork1);
                _Aperture.CaricaApertureIngressi(_Inizio.AddYears(-1), _Fine.AddYears(-1), this.unitOfWork1);

                XPCollection <Vendita> vendite = new XPCollection <Vendita>(this.unitOfWork1);

                GroupOperator periodo1 = new GroupOperator(GroupOperatorType.And, new CriteriaOperator[] {
                    new BinaryOperator("DataContabile", _Inizio, BinaryOperatorType.GreaterOrEqual),
                    new BinaryOperator("DataContabile", _Fine, BinaryOperatorType.LessOrEqual)
                });
                GroupOperator periodo2 = new GroupOperator(GroupOperatorType.And, new CriteriaOperator[] {
                    new BinaryOperator("DataContabile", _Inizio.AddYears(-1), BinaryOperatorType.GreaterOrEqual),
                    new BinaryOperator("DataContabile", _Fine.AddYears(-1), BinaryOperatorType.LessOrEqual)
                });

                vendite.Criteria = new GroupOperator(GroupOperatorType.Or, new CriteriaOperator[] { periodo1, periodo2 });

                foreach (Vendita vendita in vendite)
                {
                    foreach (RigaVenditaVariante riga in vendita.RigheVenditaVariante)
                    {
                        foreach (Ingresso ingresso in riga.Variante.Biglietto.Percorso.Ingressi)
                        {
                            //if (ingresso.SoggettoEconomico == _Soggetto)
                            if (_Ingressi.Contains(ingresso))
                            {
                                AddToList(ingresso, riga.Quantita, vendita.DataContabile, riga.Variante.TipologiaEconomica, riga);
                            }
                        }
                    }
                }

                GroupOperator cardPeriodo1 = new GroupOperator(GroupOperatorType.And, new CriteriaOperator[]
                {
                    new BinaryOperator("DataOraEntrata", _Inizio, BinaryOperatorType.GreaterOrEqual),
                    new BinaryOperator("DataOraEntrata", _Fine.AddDays(1), BinaryOperatorType.Less),
                    new NotOperator(new NullOperator("RigaStampaIngresso.Stampa.Card"))
                });
                GroupOperator cardPeriodo2 = new GroupOperator(GroupOperatorType.And, new CriteriaOperator[]
                {
                    new BinaryOperator("DataOraEntrata", _Inizio.AddYears(-1), BinaryOperatorType.GreaterOrEqual),
                    new BinaryOperator("DataOraEntrata", _Fine.AddYears(-1).AddDays(1), BinaryOperatorType.Less),
                    new NotOperator(new NullOperator("RigaStampaIngresso.Stampa.Card"))
                });

                XPCollection <Entrata> entrate = new XPCollection <Entrata>(this.unitOfWork1);
                entrate.Criteria = new GroupOperator(GroupOperatorType.Or, new CriteriaOperator[]
                {
                    cardPeriodo1, cardPeriodo2
                });

                foreach (var entrata in entrate)
                {
                    if (_Ingressi.Contains(entrata.RigaStampaIngresso.Ingresso))
                    {
                        AddCardToList(entrata);
                    }
                }

                //foreach (Ingresso ingresso in _Soggetto.Ingressi)
                foreach (Ingresso ingresso in _Ingressi)
                {
                    AddToList(ingresso, _Aperture.TotaleGiornate(ingresso.Oid, _Inizio, _Fine), "ac");
                    AddToList(ingresso, _Aperture.TotaleGiornate(ingresso.Oid, _Inizio.AddYears(-1), _Fine.AddYears(-1)), "ap");
                }

                foreach (DatiReport03 datiReport03 in _List)
                {
                    datiReport03.CalcolaTotale(_List);
                }

                XtraReport03 report = new XtraReport03();

                report.Init(_List, _Inizio, _Fine, this.memoEditInfo.Text);

                report.ShowRibbonPreviewDialog();
            }
            finally
            {
                Cursor.Current = saveCursor;
            }
        }
예제 #30
0
        /// <summary>
        /// Método responsável por buscar as cores a partir de uma lista de usernames (Logins) passada.
        /// </summary>
        /// <param name="session">Sessão Corrente</param>
        /// <param name="logins">Lista com logins dos usuários</param>
        /// <returns>Lista de objetos ProjetoColaboradorCondfig</returns>
        public static List <ProjetoColaboradorConfig> GetConfigColaboradores(Session session, List <string> logins, Guid oidProjeto)
        {
            if (session == null || logins == null)
            {
                throw new ArgumentException("Os parâmetros session e login usuários não podem ser nulos.");
            }
            List <ProjetoColaboradorConfig> configs = new List <ProjetoColaboradorConfig>();

            using (XPCollection <ProjetoColaboradorConfig> colecaoConfigs = new XPCollection <ProjetoColaboradorConfig>(session, GroupOperator.And(new InOperator("Colaborador.Usuario.UserName", logins), CriteriaOperator.Parse("OidProjeto = ?", oidProjeto))))
            {
                configs = colecaoConfigs.ToList();
            }
            return(configs);
        }
예제 #31
0
 public Predicate(GroupOperator @operator)
 {
     predicateGroup = new PredicateGroup {
         Operator = @operator, Predicates = new List <IPredicate>()
     };
 }
 CriteriaOperator ICriteriaVisitor <CriteriaOperator> .Visit(GroupOperator theOperator)
 {
     return(this.VisitGroup(theOperator));
 }
예제 #33
0
 void CreateExcludeXPObjectTypeArgs(IEnumerable<SelectStatement> selectStatements, XPDictionary xpDictionary) {
     IEnumerable<string> typeNames =
         xpDictionary.Classes.OfType<XPClassInfo>().Where(classInfo => classInfo.ClassType != null).Select(
             info => info.ClassType.FullName);
     foreach (
         SelectStatement selectStatement in
             selectStatements.Where(statement => statement.TableName == "XPObjectType")) {
         List<string> values = typeNames.ToList();
         var criteriaOperator = new GroupOperator(GroupOperatorType.Or);
         foreach (string value in values) {
             criteriaOperator.Operands.Add(new QueryOperand("TypeName", selectStatement.Alias) == value);
         }
         selectStatement.Condition = criteriaOperator;
     }
 }
예제 #34
0
        protected void cpInvoiceVatList_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            string[] para = e.Parameter.Split('|');

            if (para[0] != "")
            {
                XPQuery <NAS.DAL.Accounting.LegalInvoice.LegalInvoiceArtifactType> legalInvoiceArtifactType = new XPQuery <NAS.DAL.Accounting.LegalInvoice.LegalInvoiceArtifactType>(session);
                XPQuery <BillTaxClaim>        billTaxClaim        = new XPQuery <BillTaxClaim>(session);
                XPQuery <SaleInvoiceArtiface> saleInvoiceArtiface = new XPQuery <SaleInvoiceArtiface>(session);

                char vatType = (para[0] == "01-1/GTGT" ? Constant.VAT_OUT : Constant.VAT_IN);

                var list = from liat in legalInvoiceArtifactType.Where(l => l.RowStatus >= 1).AsEnumerable()
                           join sia in saleInvoiceArtiface.Where(s => s.LegalInvoiceArtifactTypeId.Category == vatType).AsEnumerable() on liat.LegalInvoiceArtifactTypeId equals sia.LegalInvoiceArtifactTypeId.LegalInvoiceArtifactTypeId
                           join btc in billTaxClaim.AsEnumerable().DefaultIfEmpty(new BillTaxClaim(session)) on sia.BillId.BillId equals btc.BillId.BillId
                           //where g.LegalInvoiceArtifactTypeId.Category == vatType
                           //from gg in g.DefaultIfEmpty(new BillTaxClaim(session))
                           select new C011GTGT()
                {
                    Amount          = btc.Amount,
                    ClaimItem       = btc.ClaimItem,
                    Comment         = btc.Comment,
                    CreateDate      = btc.CreateDate,
                    TaxInNumber     = btc.TaxInNumber,
                    TaxInPercentage = btc.TaxInPercentage,
                    TotalAmount     = btc.TotalAmount,
                    BillCode        = sia.IssuedArtifaceCode,
                    SeriesNumber    = sia.SeriesNumber,
                    ObjectName      = btc.BillId.SourceOrganizationId.Name,
                    ObjectTax       = btc.BillId.SourceOrganizationId.TaxNumber,
                    LegalInvoiceArtifactTypeCode = liat.Code,
                    LegalInvoiceArtifactTypeName = liat.Name
                };

                try
                {
                    CriteriaOperator _filter = new GroupOperator(GroupOperatorType.And,
                                                                 new BinaryOperator("Category", vatType, BinaryOperatorType.Equal),
                                                                 new BinaryOperator("RowStatus", 1, BinaryOperatorType.GreaterOrEqual));
                    XPCollection <NAS.DAL.Accounting.LegalInvoice.LegalInvoiceArtifactType> _legalInvoiceArtifactType = new XPCollection <NAS.DAL.Accounting.LegalInvoice.LegalInvoiceArtifactType>(session);
                    _legalInvoiceArtifactType.Criteria = _filter;

                    var _result = list;

                    foreach (NAS.DAL.Accounting.LegalInvoice.LegalInvoiceArtifactType liat in _legalInvoiceArtifactType)
                    {
                        if (!list.ToList().Any(l => l.LegalInvoiceArtifactTypeCode == liat.Code))
                        {
                            C011GTGT _c011GTGT = new C011GTGT()
                            {
                                Amount          = 0,
                                ClaimItem       = "",
                                Comment         = "",
                                CreateDate      = DateTime.Now,
                                TaxInNumber     = 0,
                                TaxInPercentage = 0,
                                TotalAmount     = 0,
                                BillCode        = "",
                                SeriesNumber    = "",
                                ObjectName      = "",
                                ObjectTax       = "",
                                LegalInvoiceArtifactTypeCode = liat.Code,
                                LegalInvoiceArtifactTypeName = liat.Name
                            };

                            _result = _result.Concat(new List <C011GTGT> {
                                _c011GTGT
                            });
                        }
                    }

                    grdBillTaxClaim.DataSource = _result.ToList();
                    grdBillTaxClaim.DataBind();
                    grdBillTaxClaim.ExpandAll();

                    Session["data"] = _result.ToList();

                    cpInvoiceVatList.JSProperties.Add("cpShowForm", "show");
                }
                catch
                {
                }
            }
        }
예제 #35
0
        private CriteriaOperator SearchCriteriaObjectBuilder()
        {
            CriteriaOperator criteria    = null;
            CriteriaOperator criteriaAND = null;
            CriteriaOperator criteriaOR  = null;

            criteria = new GroupOperator();
            ((GroupOperator)criteria).OperatorType = GroupOperatorType.And;

            criteriaAND = new GroupOperator();
            ((GroupOperator)criteriaAND).OperatorType = GroupOperatorType.And;

            criteriaOR = new GroupOperator();
            ((GroupOperator)criteriaOR).OperatorType = GroupOperatorType.Or;


            // Конъюнктивные члены

            if (!string.IsNullOrEmpty(AdditionalCriterionString))
            {
                CriteriaOperator AdditionalCriterionOperator = CriteriaOperator.Parse(AdditionalCriterionString);
                ((GroupOperator)criteriaAND).Operands.Add(AdditionalCriterionOperator);
            }


            if (this.DateBegin != System.DateTime.MinValue)
            {
                CriteriaOperator criteriathisDateBegin = new BinaryOperator("ObligationUnitDateTime", this.DateBegin, BinaryOperatorType.GreaterOrEqual);
                ((GroupOperator)criteriaAND).Operands.Add(criteriathisDateBegin);
            }

            if (this.DateEnd != System.DateTime.MinValue)
            {
                CriteriaOperator criteriathisDateEnd = new BinaryOperator("ObligationUnitDateTime", this.DateEnd, BinaryOperatorType.LessOrEqual);
                ((GroupOperator)criteriaAND).Operands.Add(criteriathisDateEnd);
            }

            /*
             * // Если по месяцам
             * if ((int)(this.MonthBegin) != 0) {
             *  CriteriaOperator criteriathisMonthBegin = new BinaryOperator("ObligationUnitMonth", (int)(this.MonthBegin), BinaryOperatorType.GreaterOrEqual);
             *  ((GroupOperator)criteriaAND).Operands.Add(criteriathisMonthBegin);
             * }
             *
             * if ((int)(this.MonthEnd) != 0) {
             *  CriteriaOperator criteriathisMonthEnd = new BinaryOperator("ObligationUnitMonth", (int)(this.MonthEnd), BinaryOperatorType.LessOrEqual);
             *  ((GroupOperator)criteriaAND).Operands.Add(criteriathisMonthEnd);
             * }
             *
             * // Ограничение на квартал
             * if ((int)(this.Quarter) != 0) {
             *  CriteriaOperator criteriathisQuarter = new BinaryOperator("ObligationUnitQuarter", (int)(this.Quarter), BinaryOperatorType.Equal);
             *  ((GroupOperator)criteriaAND).Operands.Add(criteriathisQuarter);
             * }
             *
             * // Ограничение на год
             * if (this.year != 0) {
             *  CriteriaOperator criteriathisYear = new BinaryOperator("ObligationUnitYear", this.year, BinaryOperatorType.Equal);
             *  ((GroupOperator)criteriaAND).Operands.Add(criteriathisYear);
             * }
             */


            //CriteriaOperator criteriaDepartment = null;
            //if (this.Department != null) {
            //    criteriaDepartment = new BinaryOperator("DepartmentRegistrator.Oid", this.Department.Oid, BinaryOperatorType.Equal);
            //    ((GroupOperator)criteriaAND).Operands.Add(criteriaDepartment);
            //}

            //CriteriaOperator criteriaDealState = null;
            //if (this.DealState != 0) {
            //    criteriaDealState = new BinaryOperator("DealState", DealState, BinaryOperatorType.Equal);
            //    ((GroupOperator)criteriaAND).Operands.Add(criteriaDealState);
            //}

            // BEGIN
            CriteriaOperator criteriaCustomerAND = new GroupOperator();

            ((GroupOperator)criteriaCustomerAND).OperatorType = GroupOperatorType.And;


            CriteriaOperator criteriaPrimaryParty = null;

            if (this.PrimaryParty != null)
            {
                criteriaPrimaryParty = new BinaryOperator("PrimaryParty.Oid", PrimaryParty.Oid, BinaryOperatorType.Equal);
                ((GroupOperator)criteriaCustomerAND).Operands.Add(criteriaPrimaryParty);
            }

            CriteriaOperator criteriaContragentParty = null;

            if (this.ContragentParty != null)
            {
                criteriaContragentParty = new BinaryOperator("ContragentParty.Oid", ContragentParty.Oid, BinaryOperatorType.Equal);
                ((GroupOperator)criteriaCustomerAND).Operands.Add(criteriaContragentParty);
            }


            if (((GroupOperator)criteriaCustomerAND).Operands.Count > 0)
            {
                ((GroupOperator)criteriaAND).Operands.Add(criteriaCustomerAND);
            }


            CriteriaOperator criteriaContract = null;

            if (this.Contract != null)
            {
                criteriaContract = new BinaryOperator("Contract.Oid", Contract.Oid, BinaryOperatorType.Equal);
                ((GroupOperator)criteriaCustomerAND).Operands.Add(criteriaContract);
            }

            CriteriaOperator criteriaContractDeal = null;

            if (this.ContractDeal != null)
            {
                criteriaContractDeal = new BinaryOperator("ContractDeal.Oid", ContractDeal.Oid, BinaryOperatorType.Equal);
                ((GroupOperator)criteriaCustomerAND).Operands.Add(criteriaContractDeal);
            }

            CriteriaOperator criteriaCostItem = null;

            if (this.CostItem != null)
            {
                criteriaCostItem = new BinaryOperator("CostItem.Oid", CostItem.Oid, BinaryOperatorType.Equal);
                ((GroupOperator)criteriaCustomerAND).Operands.Add(criteriaCostItem);
            }

            CriteriaOperator criteriaObligationUnit = null;

            if (this.CostItem != null)
            {
                criteriaObligationUnit = new BinaryOperator("ObligationItem.Oid", this.ObligationUnit.Oid, BinaryOperatorType.Equal);
                ((GroupOperator)criteriaCustomerAND).Operands.Add(criteriaObligationUnit);
            }


            CriteriaOperator criteriaSubject = null;

            if (this.Subject != null)
            {
                criteriaSubject = new BinaryOperator("Subject.Oid", Subject.Oid, BinaryOperatorType.Equal);
                ((GroupOperator)criteriaCustomerAND).Operands.Add(criteriaSubject);
            }

            CriteriaOperator criteriafmOrder = null;

            if (this.fmOrder != null)
            {
                criteriafmOrder = new BinaryOperator("fmOrder.Oid", fmOrder.Oid, BinaryOperatorType.Equal);
                ((GroupOperator)criteriaCustomerAND).Operands.Add(criteriafmOrder);
            }

            CriteriaOperator criteriaStage = null;

            if (this.Stage != null)
            {
                criteriaStage = new BinaryOperator("Stage.Oid", Stage.Oid, BinaryOperatorType.Equal);
                ((GroupOperator)criteriaCustomerAND).Operands.Add(criteriaStage);
            }

            /*
             * CriteriaOperator criteriaStageTech = null;
             * if (this.StageTech != null) {
             *  criteriaStageTech = new BinaryOperator("StageTech.Oid", StageTech.Oid, BinaryOperatorType.Equal);
             *  ((GroupOperator)criteriaCustomerAND).Operands.Add(criteriaStageTech);
             * }
             */
            // END

            /*
             * // BEGIN
             * CriteriaOperator criteriaSupplierOR = new GroupOperator();
             * ((GroupOperator)criteriaSupplierOR).OperatorType = GroupOperatorType.Or;
             *
             * CriteriaOperator criteriaSupplier = null;
             * if (this.Supplier != null) {
             *  criteriaSupplier = new BinaryOperator("Supplier.Party.Oid", Supplier.Oid, BinaryOperatorType.Equal);
             *  ((GroupOperator)criteriaSupplierOR).Operands.Add(criteriaSupplier);
             * }
             *
             * CriteriaOperator criteriaPersonOfSupplier = null;
             * if (this.PersonOfSupplier != null) {
             *  criteriaPersonOfSupplier = new BinaryOperator("Supplier.Party.Person.Oid", PersonOfSupplier.Oid, BinaryOperatorType.Equal);
             *  ((GroupOperator)criteriaSupplierOR).Operands.Add(criteriaPersonOfSupplier);
             * }
             *
             * if (((GroupOperator)criteriaSupplierOR).Operands.Count > 0) ((GroupOperator)criteriaAND).Operands.Add(criteriaSupplierOR);
             * // END
             *
             * CriteriaOperator criteriaCurator = null;
             * if (this.Curator != null) {
             *  criteriaCurator = new BinaryOperator("Curator.Oid", Curator.Oid, BinaryOperatorType.Equal);
             *  ((GroupOperator)criteriaAND).Operands.Add(criteriaCurator);
             * }
             *
             * CriteriaOperator criteriaUserRegistrator = null;
             * if (this.UserRegistrator != null) {
             *  criteriaUserRegistrator = new BinaryOperator("UserRegistrator.Oid", UserRegistrator.Oid, BinaryOperatorType.Equal);
             *  ((GroupOperator)criteriaAND).Operands.Add(criteriaUserRegistrator);
             * }
             */

            CriteriaOperator criteriaValuta = null;

            if (this.Valuta != null)
            {
                criteriaValuta = new BinaryOperator("Valuta.Oid", Valuta.Oid, BinaryOperatorType.Equal);
                ((GroupOperator)criteriaAND).Operands.Add(criteriaValuta);
            }

            /*
             * if (this.PriceFrom != 0) {
             *  CriteriaOperator criteriathisPriceFrom = new BinaryOperator("CostInRUR", this.PriceFrom, BinaryOperatorType.GreaterOrEqual);
             *  ((GroupOperator)criteriaAND).Operands.Add(criteriathisPriceFrom);
             * }
             *
             * if (this.PriceTo != 0) {
             *  CriteriaOperator criteriathisPriceTo = new BinaryOperator("CostInRUR", this.PriceTo, BinaryOperatorType.LessOrEqual);
             *  ((GroupOperator)criteriaAND).Operands.Add(criteriathisPriceTo);
             * }
             */

            /*
             * CriteriaOperator criteriaPaymentValuta = null;
             * if (this.PaymentValuta != null) {
             *  criteriaPaymentValuta = new BinaryOperator("PaymentValuta.Oid", PaymentValuta.Oid, BinaryOperatorType.Equal);
             *  ((GroupOperator)criteriaAND).Operands.Add(criteriaPaymentValuta);
             * }
             *
             * if (this.PaymentPriceFrom != 0) {
             *  CriteriaOperator criteriaPaymentPriceFrom = new BinaryOperator("PaymentCost", this.PaymentPriceFrom, BinaryOperatorType.GreaterOrEqual);
             *  ((GroupOperator)criteriaAND).Operands.Add(criteriaPaymentPriceFrom);
             * }
             *
             * if (this.PaymentPriceTo != 0) {
             *  CriteriaOperator criteriaPaymentPriceTo = new BinaryOperator("PaymentCost", this.PaymentPriceTo, BinaryOperatorType.LessOrEqual);
             *  ((GroupOperator)criteriaAND).Operands.Add(criteriaPaymentPriceTo);
             * }
             */

            //if (this.PlaneFact != 0) {
            //    CriteriaOperator criteriaPlaneFact = new BinaryOperator("PlaneFact ", this.PlaneFact, BinaryOperatorType.Equal);
            //    ((GroupOperator)criteriaAND).Operands.Add(criteriaPlaneFact);
            //}

            // Совокупность критериев OR добавляем через AND к общей совокупности поисковых членов
            if (((GroupOperator)criteriaAND).Operands.Count > 0)
            {
                ((GroupOperator)criteria).Operands.Add(criteriaAND);
            }


            // Дизъюнктивные члены
            //CriteriaOperator criteriaDocumentNumber = null;
            //if (!string.IsNullOrEmpty(this.DocumentNumber)) {
            //    //criteriaDocumentNumber = new BinaryOperator("DealVersion.ContractDocument.Number", "%" + this.DocumentNumber + "%", BinaryOperatorType.Like);
            //    criteriaDocumentNumber = new BinaryOperator("ContractDocument.Number", "%" + this.DocumentNumber + "%", BinaryOperatorType.Like);
            //    ((GroupOperator)criteriaOR).Operands.Add(criteriaDocumentNumber);
            //}

            //CriteriaOperator criteriaDescriptionShort = null;
            //if (!string.IsNullOrEmpty(this.Description)) {
            //    //criteriaDescriptionShort = new BinaryOperator("DealVersion.DescriptionShort", "%" + this.Description + "%", BinaryOperatorType.Like);
            //    criteriaDescriptionShort = new BinaryOperator("DescriptionShort", "%" + this.Description + "%", BinaryOperatorType.Like);
            //    ((GroupOperator)criteriaOR).Operands.Add(criteriaDescriptionShort);
            //}

            //// Совокупность критериев OR добавляем через AND к общей совокупности поисковых членов
            //if (((GroupOperator)criteriaOR).Operands.Count > 0) {
            //    ((GroupOperator)criteria).Operands.Add(criteriaOR);
            //}



            if (((GroupOperator)criteria).Operands.Count > 0)
            {
                return(criteria);
            }
            else
            {
                return(null);
            }
        }
예제 #36
0
        /*
         * AND
         *      Human Case ID = 'AAA'
         *      Human Case ID = 'BBB'
         *      Exists Human Case Test
         *          AND
         *              Human case Test Type = 6618590000000 ('Anaplasma test')
         */

        private void CreateFilterCondition1(QueryFilterControl filter, out GroupOperator rootGroup, out GroupOperator aggrGroup)
        {
            CriteriaOperator criteria;

            rootGroup = QueryFilterControl.AddGroupOperator(null, null, null, out criteria);
            QueryFilterControl.AddFieldOperator(rootGroup, CaseIDAlias, StrValue1, SearchOperator.Binary, BinaryOperatorType.Equal, false);
            QueryFilterControl.AddFieldOperator(rootGroup, CaseIDAlias, StrValue2, SearchOperator.Binary, BinaryOperatorType.Equal, false);
            AggregateOperand aggrOp = QueryFilterControl.AddAggregateOperand(rootGroup, "<Human Case Test>", false);
            CriteriaOperator aggrCriteria;

            aggrGroup = QueryFilterControl.AddGroupOperator(null, null, null, out aggrCriteria);
            QueryFilterControl.AddFieldOperator(aggrGroup, TestNameAlias, TestNameIdValue, SearchOperator.Binary, BinaryOperatorType.Equal,
                                                false);
            aggrOp.Condition      = aggrCriteria;
            filter.FilterCriteria = criteria;
            filter.HasChanges     = true;
        }
예제 #37
0
        public static Expression <Func <TClass, bool> > CreateLambdaFilterExpression <TClass>(JqGridSearchModel search)
        {
            if (search != null)
            {
                if (search.Filters != null)
                {
                    //lists for filters
                    List <MethodCallExpression> lambdaBodyArray       = new List <MethodCallExpression>();
                    List <BinaryExpression>     lambdaBinaryBodyArray = new List <BinaryExpression>();

                    //p =>
                    var item = Expression.Parameter(typeof(TClass), "p");

                    //create expression for each filter
                    for (var i = 0; i < search.Filters.Rules.Count; i++)
                    {
                        Type t = typeof(TClass);

                        PropertyInfo propInfo = t.GetProperty(search.Filters.Rules[i].Field);

                        var type           = propInfo.PropertyType;
                        var underlyingType = Nullable.GetUnderlyingType(type);//will be null if type is not nullable

                        if (propInfo.PropertyType.FullName == typeof(System.Int32).ToString())
                        {
                            int  value;
                            bool isParsed;

                            isParsed = int.TryParse(search.Filters.Rules[i].Data, out value);

                            if (isParsed)
                            {
                                if (search.Filters.Rules[i].Op == "lt")
                                {
                                    Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                    Expression right    = Expression.Constant(value, typeof(int));
                                    var        bodyItem = Expression.LessThan(left, right);

                                    lambdaBinaryBodyArray.Add(bodyItem);
                                }
                                else if (search.Filters.Rules[i].Op == "le")
                                {
                                    Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                    Expression right    = Expression.Constant(value, typeof(int));
                                    var        bodyItem = Expression.LessThanOrEqual(left, right);

                                    lambdaBinaryBodyArray.Add(bodyItem);
                                }
                                else if (search.Filters.Rules[i].Op == "gt")
                                {
                                    Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                    Expression right    = Expression.Constant(value, typeof(int));
                                    var        bodyItem = Expression.GreaterThan(left, right);

                                    lambdaBinaryBodyArray.Add(bodyItem);
                                }
                                else if (search.Filters.Rules[i].Op == "ge")
                                {
                                    Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                    Expression right    = Expression.Constant(value, typeof(int));
                                    var        bodyItem = Expression.GreaterThanOrEqual(left, right);

                                    lambdaBinaryBodyArray.Add(bodyItem);
                                }
                                else if (search.Filters.Rules[i].Op == "ne")
                                {
                                    Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                    Expression right    = Expression.Constant(value, typeof(int));
                                    var        bodyItem = Expression.NotEqual(left, right);

                                    lambdaBinaryBodyArray.Add(bodyItem);
                                }
                                else
                                {
                                    //p.Property
                                    Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                    Expression right    = Expression.Constant(value, typeof(int));
                                    var        bodyItem = Expression.Equal(left, right);

                                    lambdaBinaryBodyArray.Add(bodyItem);
                                }
                            }
                        }
                        else if (propInfo.PropertyType.FullName == typeof(System.Double).ToString())
                        {
                            double value;
                            bool   isParsed;

                            isParsed = double.TryParse(search.Filters.Rules[i].Data, out value);

                            if (isParsed)
                            {
                                if (search.Filters.Rules[i].Op == "lt")
                                {
                                    Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                    Expression right    = Expression.Constant(value, typeof(double));
                                    var        bodyItem = Expression.LessThan(left, right);

                                    lambdaBinaryBodyArray.Add(bodyItem);
                                }
                                else if (search.Filters.Rules[i].Op == "le")
                                {
                                    Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                    Expression right    = Expression.Constant(value, typeof(double));
                                    var        bodyItem = Expression.LessThanOrEqual(left, right);

                                    lambdaBinaryBodyArray.Add(bodyItem);
                                }
                                else if (search.Filters.Rules[i].Op == "gt")
                                {
                                    Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                    Expression right    = Expression.Constant(value, typeof(double));
                                    var        bodyItem = Expression.GreaterThan(left, right);

                                    lambdaBinaryBodyArray.Add(bodyItem);
                                }
                                else if (search.Filters.Rules[i].Op == "ge")
                                {
                                    Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                    Expression right    = Expression.Constant(value, typeof(double));
                                    var        bodyItem = Expression.GreaterThanOrEqual(left, right);

                                    lambdaBinaryBodyArray.Add(bodyItem);
                                }
                                else if (search.Filters.Rules[i].Op == "ne")
                                {
                                    Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                    Expression right    = Expression.Constant(value, typeof(double));
                                    var        bodyItem = Expression.NotEqual(left, right);

                                    lambdaBinaryBodyArray.Add(bodyItem);
                                }
                                else
                                {
                                    //p.Property
                                    Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                    Expression right    = Expression.Constant(value, typeof(double));
                                    var        bodyItem = Expression.Equal(left, right);

                                    lambdaBinaryBodyArray.Add(bodyItem);
                                }
                            }
                        }
                        else if (propInfo.PropertyType.FullName == typeof(System.Guid).ToString())
                        {
                            //do nothing
                        }
                        else if (propInfo.PropertyType.FullName == typeof(System.DateTime).ToString())
                        {
                            bool     isDateTime = false;
                            DateTime dt         = new DateTime();

                            try
                            {
                                dt         = Convert.ToDateTime(search.Filters.Rules[i].Data);
                                isDateTime = true;
                            }
                            catch (Exception e)
                            {
                            }

                            if (isDateTime && search.Filters.Rules[i].Op == "lt")
                            {
                                Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                Expression right    = Expression.Constant(dt, typeof(DateTime));
                                var        bodyItem = Expression.LessThan(left, right);

                                lambdaBinaryBodyArray.Add(bodyItem);
                            }

                            else if (isDateTime && search.Filters.Rules[i].Op == "le")
                            {
                                DateTime   dt1      = new DateTime(dt.Year, dt.Month, dt.Day, 23, 59, 59);
                                Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                Expression right    = Expression.Constant(dt1, typeof(DateTime));
                                var        bodyItem = Expression.LessThanOrEqual(left, right);

                                lambdaBinaryBodyArray.Add(bodyItem);
                            }

                            else if (isDateTime && search.Filters.Rules[i].Op == "ne")
                            {
                                Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                Expression right    = Expression.Constant(dt, typeof(DateTime));
                                var        bodyItem = Expression.NotEqual(left, right);

                                lambdaBinaryBodyArray.Add(bodyItem);
                            }

                            else if (isDateTime && search.Filters.Rules[i].Op == "gt")
                            {
                                DateTime   dt1      = new DateTime(dt.Year, dt.Month, dt.Day, 23, 59, 59);
                                Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                Expression right    = Expression.Constant(dt1, typeof(DateTime));
                                var        bodyItem = Expression.GreaterThan(left, right);

                                lambdaBinaryBodyArray.Add(bodyItem);
                            }

                            else if (isDateTime && search.Filters.Rules[i].Op == "ge")
                            {
                                Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                Expression right    = Expression.Constant(dt, typeof(DateTime));
                                var        bodyItem = Expression.GreaterThanOrEqual(left, right);

                                lambdaBinaryBodyArray.Add(bodyItem);
                            }

                            else if (isDateTime)
                            {
                                Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                Expression right    = Expression.Constant(dt, typeof(DateTime));
                                var        bodyItem = Expression.GreaterThanOrEqual(left, right);

                                DateTime   dt1       = new DateTime(dt.Year, dt.Month, dt.Day, 23, 59, 59);
                                Expression right1    = Expression.Constant(dt1, typeof(DateTime));
                                var        bodyItem1 = Expression.LessThanOrEqual(left, right1);

                                var combinedLambda = Expression.AndAlso(bodyItem, bodyItem1);

                                lambdaBinaryBodyArray.Add(combinedLambda);
                            }
                        }
                        else if (underlyingType != null && underlyingType.FullName == typeof(System.DateTime).ToString())
                        {
                            bool     isDateTime = false;
                            DateTime dt         = new DateTime();

                            try
                            {
                                dt         = Convert.ToDateTime(search.Filters.Rules[i].Data);
                                isDateTime = true;
                            }
                            catch (Exception e)
                            {
                            }

                            if (isDateTime)
                            {
                                Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                Expression right    = Expression.Constant(dt, typeof(DateTime?));
                                var        bodyItem = Expression.GreaterThanOrEqual(left, right);

                                DateTime?  dt1       = new DateTime(dt.Year, dt.Month, dt.Day, 23, 59, 59);
                                Expression right1    = Expression.Constant(dt1, typeof(DateTime?));
                                var        bodyItem1 = Expression.LessThanOrEqual(left, right1);

                                var combinedLambda = Expression.AndAlso(bodyItem, bodyItem1);

                                lambdaBinaryBodyArray.Add(combinedLambda);
                            }
                        }
                        else
                        {
                            //p.Property

                            if (search.Filters.Rules[i].Op == "ne")
                            {
                                Expression left     = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                Expression right    = Expression.Constant(search.Filters.Rules[i].Data, typeof(string));
                                var        bodyItem = Expression.NotEqual(left, right);

                                lambdaBinaryBodyArray.Add(bodyItem);
                            }

                            else
                            {
                                var property = Expression.PropertyOrField(item, search.Filters.Rules[i].Field);
                                var toLower  = typeof(string).GetMethod("ToLower", System.Type.EmptyTypes);
                                var method   = GetMethod(search.Filters.Rules[i].Op);
                                var argument = Expression.Constant(search.Filters.Rules[i].Data);

                                var tempBodyItem = Expression.Call(property, toLower);
                                var bodyItem     = Expression.Call(tempBodyItem, method, argument);

                                lambdaBodyArray.Add(bodyItem);
                            }
                        }
                    }

                    Expression tempLambdaBody = null;

                    //join filters to one expression
                    string searchString = search.Filters.Rules.FirstOrDefault().Data;

                    if (!String.IsNullOrEmpty(searchString))
                    {
                        GroupOperator ope = search.Filters.GroupOp;

                        if (ope == GroupOperator.AND)
                        {
                            if (lambdaBodyArray != null && lambdaBodyArray.Count != 0)
                            {
                                tempLambdaBody = lambdaBodyArray[0];

                                for (var j = 0; j < lambdaBodyArray.Count - 1; j++)
                                {
                                    var second     = lambdaBodyArray[j + 1];
                                    var lambdaBody = Expression.AndAlso(tempLambdaBody, second);
                                    tempLambdaBody = lambdaBody;
                                }
                            }

                            if (lambdaBinaryBodyArray != null && lambdaBinaryBodyArray.Count > 0)
                            {
                                if (tempLambdaBody == null)
                                {
                                    tempLambdaBody = lambdaBinaryBodyArray[0];
                                }

                                for (var j = 0; j < lambdaBinaryBodyArray.Count - 1; j++)
                                {
                                    var binaryItem = lambdaBinaryBodyArray[j + 1];
                                    var lambdaBody = Expression.AndAlso(tempLambdaBody, binaryItem);
                                    tempLambdaBody = lambdaBody;
                                }
                            }
                        }
                        else
                        {
                            if (lambdaBodyArray != null && lambdaBodyArray.Count != 0)
                            {
                                tempLambdaBody = lambdaBodyArray[0];

                                for (var j = 0; j < lambdaBodyArray.Count - 1; j++)
                                {
                                    var second     = lambdaBodyArray[j + 1];
                                    var lambdaBody = Expression.OrElse(tempLambdaBody, second);
                                    tempLambdaBody = lambdaBody;
                                }
                            }

                            if (lambdaBinaryBodyArray != null && lambdaBinaryBodyArray.Count > 0)
                            {
                                if (tempLambdaBody == null)
                                {
                                    tempLambdaBody = lambdaBinaryBodyArray[0];
                                }

                                for (var j = 0; j < lambdaBinaryBodyArray.Count; j++)
                                {
                                    var binaryItem = lambdaBinaryBodyArray[j];
                                    var lambdaBody = Expression.OrElse(tempLambdaBody, binaryItem);
                                    tempLambdaBody = lambdaBody;
                                }
                            }
                        }
                    }

                    //create final expression
                    if (tempLambdaBody != null)
                    {
                        var lambda = (Expression <Func <TClass, bool> >)Expression.Lambda(tempLambdaBody, item);

                        return(lambda);
                    }
                }
            }
            return(null);
        }
예제 #38
0
 public GroupCondition(GroupOperator op, IEnumerable <Condition> group)
 {
     _op    = op;
     _group = new List <Condition>(group);
 }
예제 #39
0
        /// <summary>
        /// Recursive function for pagination
        /// </summary>
        /// <param name="pEntry"></param>
        /// <param name="dialog"></param>
        /// <returns></returns>
        public int PopuDialogMore(Entry pEntry, PosSelectRecordDialog <XPCollection, XPGuidObject, T2> dialog)
        {
            DialogResponseType response = (DialogResponseType)dialog.Run();

            // Recapture RowActivated : DoubleClick and trigger dialog.Respond
            dialog.GenericTreeView.TreeView.RowActivated += delegate
            {
                SelectRecord(pEntry, dialog);
            };
            if (DialogResponseType.Ok.Equals(response))
            {
                SelectRecord(pEntry, dialog);
            }

            //Pagination response
            if (DialogResponseType.LoadMore.Equals(response))
            {
                dialog.GenericTreeView.DataSource.TopReturnedObjects = (SettingsApp.PaginationRowsPerPage * dialog.GenericTreeView.CurrentPageNumber);
                dialog.GenericTreeView.Refresh();
                PopuDialogMore(pEntry, dialog);
            }

            //Filter  response
            else if (DialogResponseType.Filter.Equals(response))
            {
                //Reset current page to 1 ( Pagination go to defined initialy )


                // Filter SellDocuments
                string filterField = string.Empty;
                string statusField = string.Empty;
                string extraFilter = string.Empty;

                List <string> result = new List <string>();

                PosReportsQueryDialog dialogFilter   = new PosReportsQueryDialog(dialog, DialogFlags.DestroyWithParent, ReportsQueryDialogMode.FILTER_DOCUMENTS_PAGINATION, "fin_documentfinancemaster");
                DialogResponseType    responseFilter = (DialogResponseType)dialogFilter.Run();

                //If button Clean Filter Clicked
                if (DialogResponseType.CleanFilter.Equals(responseFilter))
                {
                    dialog.GenericTreeView.CurrentPageNumber             = 1;
                    dialog.GenericTreeView.DataSource.Criteria           = CriteriaOperatorLastFilter;
                    dialog.GenericTreeView.DataSource.TopReturnedObjects = SettingsApp.PaginationRowsPerPage * dialog.GenericTreeView.CurrentPageNumber;
                    dialog.GenericTreeView.Refresh();
                    dialogFilter.Destroy();
                    PopuDialogMore(pEntry, dialog);
                }
                //If OK filter clicked
                else if (DialogResponseType.Ok.Equals(responseFilter))
                {
                    dialog.GenericTreeView.CurrentPageNumber = 1;
                    filterField = "DocumentType";
                    statusField = "DocumentStatusStatus";

                    /* IN009066 - FS and NC added to reports */
                    //extraFilter = $@" AND ({statusField} <> 'A') AND (
                    //   {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypeInvoice}' OR
                    //   {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypeSimplifiedInvoice}' OR
                    //   {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypeInvoiceAndPayment}' OR
                    //   {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypeConsignationInvoice}' OR
                    //   {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypeDebitNote}' OR
                    //   {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypeCreditNote}' OR
                    //   {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypePayment}'
                    //   OR
                    //   {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypeCurrentAccountInput}'
                    //   )".Replace(Environment.NewLine, string.Empty);
                    /* IN009089 - # TO DO: above, we need to check with business this condition:  {filterField} = '{SettingsApp.XpoOidDocumentFinanceTypeCurrentAccountInput}' */

                    //Assign Dialog FilterValue to Method Result Value
                    result.Add($"{dialogFilter.FilterValue}");
                    result.Add(dialogFilter.FilterValueHumanReadble);
                    //string addFilter = FilterValue;

                    CriteriaOperator criteriaOperatorLast = dialog.GenericTreeView.DataSource.Criteria;
                    CriteriaOperator criteriaOperator     = GroupOperator.And(CriteriaOperatorLastFilter, CriteriaOperator.Parse(result[0]));

                    //lastData = dialog.GenericTreeView.DataSource;

                    dialog.GenericTreeView.DataSource.Criteria           = criteriaOperator;
                    dialog.GenericTreeView.DataSource.TopReturnedObjects = SettingsApp.PaginationRowsPerPage * dialog.GenericTreeView.CurrentPageNumber;
                    dialog.GenericTreeView.Refresh();

                    //se retornar zero resultados apresenta dados anteriores ao filtro
                    if (dialog.GenericTreeView.DataSource.Count == 0)
                    {
                        dialog.GenericTreeView.DataSource.Criteria           = criteriaOperatorLast;
                        dialog.GenericTreeView.DataSource.TopReturnedObjects = SettingsApp.PaginationRowsPerPage * dialog.GenericTreeView.CurrentPageNumber;
                        dialog.GenericTreeView.Refresh();
                    }
                    dialogFilter.Destroy();
                    PopuDialogMore(pEntry, dialog);
                }
                //If Cancel Filter Clicked
                else
                {
                    dialogFilter.Destroy();
                    PopuDialogMore(pEntry, dialog);
                }
            }
            //Button Close clicked
            else
            {
                dialog.Destroy();
            }

            return((int)response);
        }
예제 #40
0
 public void AddCriteria(GroupOperatorType groupOperatorType, CriteriaOperator criteriaOperator)
 {
     Criteria = new GroupOperator(groupOperatorType, Criteria, criteriaOperator);
 }
예제 #41
0
 /// <summary>  Constructs a ConditionGroup</summary>
 /// <param name="ops">	The Boolean operator to use when joining conditions in this
 /// group; either <c>Condition.AND</c> or <c>Condition.OR</c>
 /// </param>
 public ConditionGroup(GroupOperator ops)
 {
     fOp = ops;
 }
예제 #42
0
 object ICriteriaVisitor.Visit(GroupOperator theOperator)
 {
     bool res = theOperator.OperatorType == GroupOperatorType.And;
     int count = theOperator.Operands.Count;
     for(int i = 0; i < count; i++)
         if(res != (bool)Process((CriteriaOperator)theOperator.Operands[i]))
             return GetBool(!res);
     return GetBool(res);
 }
 /// <contentfrom cref="ICriteriaVisitor.Visit(GroupOperator)"/>
 public object Visit(GroupOperator theOperator)
 {
     Process(theOperator.Operands);
     return theOperator;
 }
예제 #44
0
        /// <summary>
        /// Получение очередного номера для сортировки Пока алгоритм не отличается от алгоритма получения ISN
        /// </summary>
        public int getDocNumber()
        {
            // Вариант 2 (с XPCollection)

            Session ssn = this.Session;   // new Session(this.Session.Dictionary);

            XPCollection <RegistrationLogDocNumberCounter> xpCounterCol = new XPCollection <RegistrationLogDocNumberCounter>(ssn);

            // Условия
            CriteriaOperator criteria = null;

            criteria = new GroupOperator();
            ((GroupOperator)criteria).OperatorType = GroupOperatorType.And;

            CriteriaOperator criteriaYear = new BinaryOperator("Year", DocNumberYear, BinaryOperatorType.Equal);

            ((GroupOperator)criteria).Operands.Add(criteriaYear);

            CriteriaOperator criteriaDepartment = null;

            if (DepartmentRegistrator != null)
            {
                criteriaDepartment = new BinaryOperator("Department", DepartmentRegistrator, BinaryOperatorType.Equal);
                ((GroupOperator)criteria).Operands.Add(criteriaDepartment);
            }

            xpCounterCol.Criteria = criteria;

            if (!xpCounterCol.IsLoaded)
            {
                xpCounterCol.Load();
            }


            if (xpCounterCol.Count == 0)
            {
                // SHU 2011-11-03 ПЕРЕДЕЛАТЬ НА Session!
                // Другой работающий вариант. Здесь плохо с Connection (надо явно прописывать).
                // ssn.BeginNestedUnitOfWork не даёт желаемого результата
                using (UnitOfWork uow = new UnitOfWork(this.Session.Dictionary)) {
                    uow.Connection = ssn.Connection;
                    //if (uow.Connection.State == System.Data.ConnectionState.Closed) uow.Connect();
                    RegistrationLogDocNumberCounter newCounter = new RegistrationLogDocNumberCounter(uow);
                    newCounter.Year = this.DocNumberYear;

                    hrmDepartment dep = uow.GetObjectByKey(this.DepartmentRegistrator.GetType(), this.DepartmentRegistrator.ClassInfo.GetId(this.DepartmentRegistrator)) as hrmDepartment;

                    newCounter.Department = dep;   // this.DepartmentRegistrator;
                    newCounter.Save();
                    uow.FlushChanges();
                    //if (uow.Connection.State == System.Data.ConnectionState.Open) uow.Connection.Close();
                    xpCounterCol.Reload();
                    if (!xpCounterCol.IsLoaded)
                    {
                        xpCounterCol.Load();
                    }
                }
            }

            // Номер документа
            return(xpCounterCol[0].ReserveDocNumber());
        }
예제 #45
0
        public void BillTransactionInit(Session session,
                                        Guid BillId,
                                        double TotalAmount,
                                        double DiscountAmount,
                                        double TaxAmount,
                                        double ItemAmount
                                        )
        {
            CriteriaOperator filter = new GroupOperator(GroupOperatorType.And,
                                                        new BinaryOperator("Code", "", BinaryOperatorType.Equal),
                                                        //new BinaryOperator("SalesInvoiceId", BillId, BinaryOperatorType.Equal),
                                                        new BinaryOperator("SalesInvoiceId", BillId, BinaryOperatorType.Equal));

            SaleInvoiceTransaction saleInvoiceTransaction = session.FindObject <SaleInvoiceTransaction>(filter);

            if (saleInvoiceTransaction != null)
            {
                filter = new BinaryOperator("TransactionId", saleInvoiceTransaction.TransactionId, BinaryOperatorType.Equal);
                TransactionObject transactionO = session.FindObject <TransactionObject>(filter);

                if (transactionO != null)
                {
                    transactionO.Delete();
                    transactionO.Save();
                }

                filter = new BinaryOperator("GeneralJournalId.TransactionId", saleInvoiceTransaction.TransactionId, BinaryOperatorType.Equal);
                XPCollection <GeneralJournalObject> collectGeneralJournalObject = new XPCollection <GeneralJournalObject>(session, filter);

                if (collectGeneralJournalObject.Count > 0)
                {
                    session.Delete(collectGeneralJournalObject);
                    session.Save(collectGeneralJournalObject);
                }

                filter = new BinaryOperator("TransactionId", saleInvoiceTransaction.TransactionId, BinaryOperatorType.Equal);
                XPCollection <GeneralJournal> collectGeneralJournal = new XPCollection <GeneralJournal>(session, filter);
                if (collectGeneralJournal.Count > 0)
                {
                    session.Delete(collectGeneralJournal);
                    session.Save(collectGeneralJournal);
                }

                Transaction transaction = session.GetObjectByKey <Transaction>(saleInvoiceTransaction.TransactionId);
                if (transaction != null)
                {
                    transaction.Delete();
                    transaction.Save();
                }

                saleInvoiceTransaction.Delete();
                saleInvoiceTransaction.Save();
            }



            saleInvoiceTransaction = new SaleInvoiceTransaction(session);

            saleInvoiceTransaction.Code           = "";
            saleInvoiceTransaction.TransactionId  = Guid.NewGuid();
            saleInvoiceTransaction.CreateDate     = saleInvoiceTransaction.IssueDate = DateTime.Now;
            saleInvoiceTransaction.Amount         = TotalAmount;
            saleInvoiceTransaction.RowStatus      = Utility.Constant.ROWSTATUS_ACTIVE;
            saleInvoiceTransaction.SalesInvoiceId = session.GetObjectByKey <SalesInvoice>(BillId);

            saleInvoiceTransaction.Save();

            ObjectBO objectBO = new ObjectBO();

            NAS.DAL.CMS.ObjectDocument.Object transactionCMSObject =
                objectBO.CreateCMSObject(session,
                                         DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);

            TransactionObject transactionObject = new TransactionObject(session)
            {
                ObjectId      = transactionCMSObject,
                TransactionId = saleInvoiceTransaction
            };

            transactionObject.Save();

            filter = new BinaryOperator("Code", DefaultAccountEnum.NAAN_DEFAULT.ToString(), BinaryOperatorType.Equal);
            Account account = session.FindObject <Account>(filter);

            // total
            GeneralJournal generalJournal = new GeneralJournal(session);

            generalJournal.GeneralJournalId = Guid.NewGuid();
            generalJournal.TransactionId    = saleInvoiceTransaction;
            generalJournal.RowStatus        = Utility.Constant.ROWSTATUS_ACTIVE;
            generalJournal.JournalType      = 'A';

            generalJournal.AccountId = account;
            generalJournal.Debit     = TotalAmount;
            generalJournal.Save();

            GeneralJournalObject debitGeneralJournalObject = null;

            NAS.DAL.CMS.ObjectDocument.Object debitJounalCMSObject =
                objectBO.CreateCMSObject(session,
                                         DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);
            debitGeneralJournalObject = new GeneralJournalObject(session)
            {
                GeneralJournalId = generalJournal,
                ObjectId         = debitJounalCMSObject
            };

            debitGeneralJournalObject.Save();

            // Discount
            generalJournal = new GeneralJournal(session);
            generalJournal.GeneralJournalId = Guid.NewGuid();
            generalJournal.TransactionId    = saleInvoiceTransaction;
            generalJournal.RowStatus        = Utility.Constant.ROWSTATUS_ACTIVE;
            generalJournal.JournalType      = 'A';

            generalJournal.AccountId = account;
            generalJournal.Credit    = DiscountAmount;
            generalJournal.Save();

            debitJounalCMSObject =
                objectBO.CreateCMSObject(session,
                                         DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);
            debitGeneralJournalObject = new GeneralJournalObject(session)
            {
                GeneralJournalId = generalJournal,
                ObjectId         = debitJounalCMSObject
            };

            debitGeneralJournalObject.Save();

            // Tax

            generalJournal = new GeneralJournal(session);
            generalJournal.GeneralJournalId = Guid.NewGuid();
            generalJournal.TransactionId    = saleInvoiceTransaction;
            generalJournal.RowStatus        = Utility.Constant.ROWSTATUS_ACTIVE;
            generalJournal.JournalType      = 'A';

            generalJournal.AccountId = account;
            generalJournal.Credit    = TaxAmount;
            generalJournal.Save();

            debitJounalCMSObject =
                objectBO.CreateCMSObject(session,
                                         DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);
            debitGeneralJournalObject = new GeneralJournalObject(session)
            {
                GeneralJournalId = generalJournal,
                ObjectId         = debitJounalCMSObject
            };

            debitGeneralJournalObject.Save();

            // Item
            generalJournal = new GeneralJournal(session);
            generalJournal.GeneralJournalId = Guid.NewGuid();
            generalJournal.TransactionId    = session.GetObjectByKey <Transaction>(saleInvoiceTransaction.TransactionId);
            generalJournal.RowStatus        = Utility.Constant.ROWSTATUS_ACTIVE;
            generalJournal.JournalType      = 'A';

            generalJournal.AccountId = account;
            generalJournal.Credit    = ItemAmount;
            generalJournal.Save();

            debitJounalCMSObject =
                objectBO.CreateCMSObject(session,
                                         DAL.CMS.ObjectDocument.ObjectTypeEnum.INVOICE_SALE);
            debitGeneralJournalObject = new GeneralJournalObject(session)
            {
                GeneralJournalId = generalJournal,
                ObjectId         = debitJounalCMSObject
            };

            debitGeneralJournalObject.Save();
        }
예제 #46
0
 void ApplyCondition(SelectStatement statement, FilterProviderBase providerBase, string nodeAlias) {
     if (providerBase.FilterValue is IList) {
         CriteriaOperator criteriaOperator = ((IEnumerable)providerBase.FilterValue).Cast<object>().Aggregate<object, CriteriaOperator>(null, (current, value)
             => current | new QueryOperand(providerBase.FilterMemberName, nodeAlias) == value.ToString());
         criteriaOperator = new GroupOperator(criteriaOperator);
         statement.Condition &= criteriaOperator;
     } else
         statement.Condition &= new QueryOperand(providerBase.FilterMemberName, nodeAlias) == (providerBase.FilterValue == null ? null : providerBase.FilterValue.ToString());
 }
예제 #47
0
 public object Visit(GroupOperator theOperator)
 {
     foreach (CriteriaOperator co in theOperator.Operands) {
         BooleanCriteriaState coRes = Process(co);
         if (coRes == BooleanCriteriaState.Value) throw new ArgumentException(MustBeLogical);
     }
     return BooleanCriteriaStateObject.Logical;
 }
        public void ReplaceNestedOperator()
        {
            var unaryOperator = new UnaryOperator(UnaryOperatorType.BitwiseNot, "pro");
            CriteriaOperator criteriaOperator = new GroupOperator(new BinaryOperator(), unaryOperator);

            var binaryOperatorExtractor = new CriteriaOperatorExtractor();
            var notOperator = new NotOperator();
            binaryOperatorExtractor.Replace(ref criteriaOperator, unaryOperator.ToString(), notOperator);

            Assert.AreEqual(((GroupOperator) criteriaOperator).Operands[1], notOperator);
        }
예제 #49
0
 public virtual object Visit(GroupOperator theOperator)
 {
     Validate(theOperator.Operands);
     return null;
 }
예제 #50
0
        private void CreaTabellaVersamenti(Session session)
        {
            XPCollection <Versamento> versamenti = new XPCollection <Versamento>(session);

            versamenti.Sorting = new SortingCollection(new SortProperty[] { new SortProperty("DataVersamento", DevExpress.Xpo.DB.SortingDirection.Ascending) });
            GroupOperator tipo =
                new GroupOperator(GroupOperatorType.Or, new CriteriaOperator[] {
                new BinaryOperator("Tipologia", EnumTipologiaVersamento.Incasso_Pos),
                new BinaryOperator("Tipologia", EnumTipologiaVersamento.Incasso_Contanti),
                new BinaryOperator("Tipologia", EnumTipologiaVersamento.Incasso_Contanti_AltriEnti),
                new BinaryOperator("Tipologia", EnumTipologiaVersamento.FondoCassa_Trattenuta),
                new BinaryOperator("Tipologia", EnumTipologiaVersamento.FondoCassa_Versamento)
            });

            versamenti.Criteria =
                new GroupOperator(GroupOperatorType.And, new CriteriaOperator[] {
                new BinaryOperator("Struttura.Oid", _Struttura.Oid),
                new BinaryOperator("InizioPeriodo", _Inizio, BinaryOperatorType.GreaterOrEqual),
                new BinaryOperator("FinePeriodo", _Fine, BinaryOperatorType.LessOrEqual),
                tipo
            });

            decimal fondocassaTrattenuta = 0;
            decimal fondocassaVersata    = 0;

            decimal[] totali    = new decimal[4];
            bool      primariga = true;

            foreach (Versamento versamento in versamenti)
            {
                if (versamento.Tipologia == EnumTipologiaVersamento.FondoCassa_Trattenuta)
                {
                    fondocassaTrattenuta += versamento.ImportoVersato;
                }
                else
                {
                    if (versamento.Tipologia == EnumTipologiaVersamento.FondoCassa_Versamento)
                    {
                        fondocassaVersata += versamento.ImportoVersato;
                    }

                    XRTableRow row = this.xrTableVersamenti.Rows[this.xrTableVersamenti.Rows.Count - 1];
                    if (!primariga)
                    {
                        this.xrTableVersamenti.InsertRowBelow(row);
                    }

                    row = this.xrTableVersamenti.Rows[this.xrTableVersamenti.Rows.Count - 1];

                    row.Cells[0].Text          = versamento.DataVersamento.ToString("d");
                    row.Cells[0].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
                    row.Cells[0].Padding       = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);

                    totali[1]                 += versamento.Incassi;
                    row.Cells[1].Text          = versamento.Incassi == 0 ? string.Empty : versamento.Incassi.ToString("c");
                    row.Cells[1].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
                    row.Cells[1].Padding       = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);

                    totali[2]                 += versamento.Pos;
                    row.Cells[2].Text          = versamento.Pos == 0 ? string.Empty : versamento.Pos.ToString("c");
                    row.Cells[2].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
                    row.Cells[2].Padding       = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);

                    totali[3]                 += versamento.ImportoVersato;
                    row.Cells[3].Text          = versamento.ImportoVersato == 0 ? string.Empty : versamento.ImportoVersato.ToString("c");
                    row.Cells[3].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
                    row.Cells[3].Padding       = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);

                    //if (versamento.Tipologia == EnumTipologiaVersamento.Incassso_Contanti_AltriEnti)
                    //{
                    //    row.Cells[1].ForeColor = Color.Red;
                    //    row.Cells[2].ForeColor = Color.Red;
                    //    row.Cells[3].ForeColor = Color.Red;
                    //    row.Cells[2].Text = "PROV.FE";
                    //}

                    primariga = false;
                }
            }
            // totali

            XRTableRow lastrow = this.xrTableVersamenti.Rows[this.xrTableVersamenti.Rows.Count - 1];

            this.xrTableVersamenti.InsertRowBelow(lastrow);
            lastrow = this.xrTableVersamenti.Rows[this.xrTableVersamenti.Rows.Count - 1];

            lastrow.Cells[0].Text          = "TOTALI";
            lastrow.Cells[0].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            lastrow.Cells[0].Font          = xrLabelTitoloTabVersamenti.Font;
            lastrow.Cells[0].Padding       = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);

            lastrow.Cells[1].Text          = totali[1].ToString("c");
            lastrow.Cells[1].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
            lastrow.Cells[1].Font          = xrLabelTitoloTabVersamenti.Font;
            lastrow.Cells[1].Padding       = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);

            lastrow.Cells[2].Text          = totali[2].ToString("c");
            lastrow.Cells[2].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
            lastrow.Cells[2].Font          = xrLabelTitoloTabVersamenti.Font;
            lastrow.Cells[2].Padding       = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);

            lastrow.Cells[3].Text          = totali[3].ToString("c");
            lastrow.Cells[3].TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
            lastrow.Cells[3].Font          = xrLabelTitoloTabVersamenti.Font;
            lastrow.Cells[3].Padding       = new DevExpress.XtraPrinting.PaddingInfo(5, 5, 5, 5);

            totalone = totali[2] + totali[3] + fondocassaTrattenuta - fondocassaVersata;

            if (totali[1] != totalone)
            {
                this.xrLabelErr.Visible = true;
            }

            if (fondocassaTrattenuta > 0)
            {
                this.xrLabelNote.Text += string.Format("Trattenuti {0:c} per fondo cassa", fondocassaTrattenuta) + Environment.NewLine;
            }
            if (fondocassaVersata > 0)
            {
                this.xrLabelNote.Text += string.Format("Versato Fondo Cassa di {0:c}", fondocassaVersata) + Environment.NewLine;
            }
        }
예제 #51
0
 public override Object Visit(GroupOperator theOperator)
 {
     return base.Visit(theOperator);
 }
 public virtual void Reset()
 {
     criteriaCore = null;
     searchResultsCore.Criteria = EmptyCollectionCriteria;
 }
예제 #53
0
 public SqlWhereStatement(bool addWhereText, GroupOperator groupOperator = GroupOperator.And)
 {
     AddWhereText  = addWhereText;
     GroupOperator = groupOperator;
 }
예제 #54
0
        public static void AssignToProjects(Session session, Inventory productionRecord, int?itemId, int?quantity)
        {
            if (itemId.HasValue == false || quantity.HasValue == false)
            {
                return;
            }

            ProjectDetails           OverrunnableProject = null;
            ProjectDetails           currentProject      = null;
            ProductionProjectDetails productionDeail     = null;
            Items item = session.GetObjectByKey <Items>(itemId);

            double unitsPerCase       = 0;
            int?   bagsPerCase        = null;
            double casesPerPallet     = 0;
            int    unassignedQuantity = quantity.Value;
            int    acceptableQuantity = 0;

            if (item == null)
            {
                return;
            }
            else
            {
                unitsPerCase   = item.intUnitsPerCase;
                casesPerPallet = item.intCasesPerPallet;
                bagsPerCase    = item.BagsPerCase;
                if (bagsPerCase.HasValue == false)
                {
                    bagsPerCase = 0;
                }

                item = null;
            }

            GroupOperator theCriteria = new GroupOperator(GroupOperatorType.And, new BinaryOperator(ProjectDetails.Fields.ProjectItem.ItemID.PropertyName, (object)itemId, BinaryOperatorType.Equal), new BinaryOperator(ProjectDetails.Fields.UnitsRequested, ProjectDetails.Fields.UnitsProduced, BinaryOperatorType.Greater), new BinaryOperator(ProjectDetails.Fields.Project.ProjectStatus.PropertyName, ProjectStatus.Completed, BinaryOperatorType.NotEqual));

            using (XPCollection <ProjectDetails> itemProject = new XPCollection <ProjectDetails>(session, theCriteria, new SortProperty(ProjectDetails.Fields.Project.Oid.PropertyName, DevExpress.Xpo.DB.SortingDirection.Ascending), new SortProperty(ProjectDetails.Fields.Oid.PropertyName, DevExpress.Xpo.DB.SortingDirection.Ascending)))
            {
                if (itemProject.Count == 0)
                {
                    return;
                }

                for (int i = 0; i < itemProject.Count; i++)
                {
                    currentProject = itemProject[i];
                    if (currentProject.AllowOverrun == true)
                    {
                        OverrunnableProject = currentProject;
                    }

                    acceptableQuantity = currentProject.UnitsRequested - currentProject.UnitsProduced;

                    productionDeail = new ProductionProjectDetails(session)
                    {
                        Production      = productionRecord,
                        ProjectDetail   = currentProject,
                        BagsProduced    = 0,
                        PalletsProduced = 0,
                        IsOverrun       = false
                    };

                    if (acceptableQuantity > unassignedQuantity)
                    {
                        productionDeail.UnitsProduced = unassignedQuantity;

                        if (unitsPerCase > 0)
                        {
                            productionDeail.BagsProduced = Convert.ToInt32((unassignedQuantity / unitsPerCase) * bagsPerCase);
                        }
                        if (unitsPerCase > 0 && casesPerPallet > 0)
                        {
                            productionDeail.PalletsProduced = Convert.ToInt32(unassignedQuantity / unitsPerCase / casesPerPallet);
                        }

                        unassignedQuantity = 0;
                    }
                    else
                    {
                        productionDeail.UnitsProduced = acceptableQuantity;

                        if (unitsPerCase > 0)
                        {
                            productionDeail.BagsProduced = Convert.ToInt32((acceptableQuantity / unitsPerCase) * bagsPerCase);
                        }
                        if (unitsPerCase > 0 && casesPerPallet > 0)
                        {
                            productionDeail.PalletsProduced = Convert.ToInt32(acceptableQuantity / unitsPerCase / casesPerPallet);
                        }

                        unassignedQuantity -= acceptableQuantity;
                    }

                    productionDeail.Save();

                    if (unassignedQuantity == 0)
                    {
                        break;
                    }
                }

                if (unassignedQuantity > 0 && OverrunnableProject != null)
                {
                    productionDeail = new ProductionProjectDetails(session)
                    {
                        Production      = productionRecord,
                        ProjectDetail   = OverrunnableProject,
                        UnitsProduced   = unassignedQuantity,
                        BagsProduced    = 0,
                        PalletsProduced = 0,
                        IsOverrun       = true
                    };
                    if (unitsPerCase > 0)
                    {
                        productionDeail.BagsProduced = Convert.ToInt32((unassignedQuantity / unitsPerCase) * bagsPerCase);
                    }
                    if (unitsPerCase > 0 && casesPerPallet > 0)
                    {
                        productionDeail.PalletsProduced = Convert.ToInt32(unassignedQuantity / unitsPerCase / casesPerPallet);
                    }

                    productionDeail.Save();
                }
            }
        }
        public void RemoveNestedOperator()
        {
            var unaryOperator = new UnaryOperator(UnaryOperatorType.IsNull, "prop2");
            CriteriaOperator groupOperator = new GroupOperator(new BinaryOperator("pro1", 1), unaryOperator);

            var binaryOperatorExtractor = new CriteriaOperatorExtractor();
            binaryOperatorExtractor.Remove(ref groupOperator, unaryOperator.ToString());

            Assert.AreEqual(new BinaryOperator("pro1", 1).ToString(), groupOperator.ToString());
        }
예제 #56
0
        private void simpleActionRprtCntbl_Execute(object sender, DevExpress.ExpressApp.Actions.SimpleActionExecuteEventArgs e)
        {
            if (View != null)
            {
                int     i   = 5;
                Empresa emp = View.ObjectSpace.FindObject <Empresa>(null);

                // Servicios Profesionales
                Workbook book  = new Workbook();
                var      sheet = book.Worksheets.ActiveWorksheet;
                sheet.Cells[0, 0].Value = emp.Compania.Nombre;
                sheet.Cells[0, 3].Value = emp.Compania.Rfc;
                sheet.Cells[1, 0].Value =
                    (emp.Regimenes != null && emp.Regimenes.Count > 0)
                    ? (emp.Regimenes[0] as RegimenEmpresa).Rgmn.Dscrpcn
                    : string.Empty;
                // emp.Regimen; TIT Sep 2018

                int ano = DateTime.Today.Month == 1 ? DateTime.Today.Year - 1 : DateTime.Today.Year;

                sheet.Cells["A4"].Value   = string.Format("Ejercicio {0}.", ano);
                sheet.Cells[i++, 0].Value = "ENERO";
                sheet.Cells[i++, 0].Value = "FEBRERO";
                sheet.Cells[i++, 0].Value = "Acumulado";
                sheet.Cells[i++, 0].Value = "MARZO";
                sheet.Cells[i++, 0].Value = "Acumulado";
                sheet.Cells[i++, 0].Value = "ABRIL";
                sheet.Cells[i++, 0].Value = "Acumulado";
                sheet.Cells[i++, 0].Value = "MAYO";
                sheet.Cells[i++, 0].Value = "Acumulado";
                sheet.Cells[i++, 0].Value = "JUNIO";
                sheet.Cells[i++, 0].Value = "Acumulado";
                sheet.Cells[i++, 0].Value = "JULIO";
                sheet.Cells[i++, 0].Value = "Acumulado";
                sheet.Cells[i++, 0].Value = "AGOSTO";
                sheet.Cells[i++, 0].Value = "Acumulado";
                sheet.Cells[i++, 0].Value = "SEPTIEMBRE";
                sheet.Cells[i++, 0].Value = "Acumulado";
                sheet.Cells[i++, 0].Value = "OCTUBRE";
                sheet.Cells[i++, 0].Value = "Acumulado";
                sheet.Cells[i++, 0].Value = "NOVIEMBRE";
                sheet.Cells[i++, 0].Value = "Acumulado";
                sheet.Cells[i++, 0].Value = "DICIEMBRE";
                sheet.Cells[i++, 0].Value = "Tota Acumulado";

                sheet.Cells["c3"].Value          = "ISR";
                sheet.Cells["c3"].Font.FontStyle = SpreadsheetFontStyle.Bold;


                // Access the range of cells to be formatted.
                CellRange range = sheet.Range["C4:G4"];

                // Begin updating of the range formatting.
                DevExpress.Spreadsheet.Formatting rangeFormatting = range.BeginUpdateFormatting();

                // Specify font settings (font name, color, size and style).
                rangeFormatting.Font.Name = "Arial";
                // rangeFormatting.Font.Color = Color.Blue;
                rangeFormatting.Font.Size = 8;
                // rangeFormatting.Font.FontStyle = SpreadsheetFontStyle.Bold;

                // Specify cell background color.
                rangeFormatting.Fill.BackgroundColor = Color.LightGray;

                // Specify text alignment in cells.
                rangeFormatting.Alignment.Vertical   = SpreadsheetVerticalAlignment.Center;
                rangeFormatting.Alignment.Horizontal = SpreadsheetHorizontalAlignment.Center;
                rangeFormatting.Alignment.WrapText   = true;
                // End updating of the range formatting.
                range.EndUpdateFormatting(rangeFormatting);



                range = sheet.Range["G3:K3"];

                // Begin updating of the range formatting.
                rangeFormatting = range.BeginUpdateFormatting();

                // Specify font settings (font name, color, size and style).
                rangeFormatting.Font.Name = "Arial";
                // rangeFormatting.Font.Color = Color.Blue;
                rangeFormatting.Font.Size = 8;
                // rangeFormatting.Font.FontStyle = SpreadsheetFontStyle.Bold;

                // Specify cell background color.
                rangeFormatting.Fill.BackgroundColor = Color.LightGray;

                // Specify text alignment in cells.
                rangeFormatting.Alignment.Vertical   = SpreadsheetVerticalAlignment.Center;
                rangeFormatting.Alignment.Horizontal = SpreadsheetHorizontalAlignment.Center;
                rangeFormatting.Alignment.WrapText   = true;

                // End updating of the range formatting.
                range.EndUpdateFormatting(rangeFormatting);


                sheet.Cells["c4"].Value = string.Format("INGRESOS{0}(Cobrados por sus{0}ventas o servicios){0}Sin incluir IVA",
                                                        Environment.NewLine);

                /*
                 * sheet.Cells["c4"].Alignment.Vertical = SpreadsheetVerticalAlignment.Justify;
                 * sheet.Cells["c4"].Alignment.Horizontal = SpreadsheetHorizontalAlignment.Center;
                 * sheet.Cells["c4"].Alignment.ShrinkToFit = true;
                 * sheet.Cells["c4"].Alignment.WrapText = true;*/

                sheet.Columns[2].Width = 350;
                sheet.Columns[3].Width = 340;
                sheet.Columns[4].Width = 340;

                sheet.Columns[6].Width  = 330;
                sheet.Columns[7].Width  = 330;
                sheet.Columns[8].Width  = 330;
                sheet.Columns[9].Width  = 330;
                sheet.Columns[10].Width = 330;


                sheet.Cells["d4"].Value = string.Format("DEDUCCIONES{0}(Compras y/o{0}gastos, sin incluir{0}IVA",
                                                        Environment.NewLine);
                sheet.Cells["e4"].Value = string.Format("INGRESOS ACUMULABLES -{0}DEDUCCIONES ACUMULABLES ={0}BASE",
                                                        Environment.NewLine);
                sheet.Cells["f4"].Value = "ISR RETENIDO";

                sheet.Cells["g3"].Value = "PAGOS (Provisionales)";
                sheet.Cells["g4"].Value = "ISR";
                sheet.Rows[3].Height    = 260;

                sheet.Cells["h3"].Value = string.Format("IVA{0}(Causado por{0}sus ventas o{0}servicios)",
                                                        Environment.NewLine);
                sheet.Cells["i3"].Value = string.Format("IVA{0}(Acreditable por{0}sus compras y/o{0}gastos)",
                                                        Environment.NewLine);
                sheet.Cells["j3"].Value = string.Format("IVA{0}RETENIDO", Environment.NewLine);
                sheet.Cells["k3"].Value = string.Format("IVA PAGADO (+){0}O{0}A FAVOR (-)", Environment.NewLine);
                sheet.Cells["l3"].Value = "DIOT";
                sheet.Rows[2].Height    = 240;

                decimal[] total     = new decimal[12];
                decimal[] reten     = new decimal[12];
                decimal[] ivaTras   = new decimal[12];
                decimal[] ivaRet    = new decimal[12];
                decimal[] ivaAcr    = new decimal[12];
                decimal[] totAcm    = new decimal[12];
                decimal[] retAcm    = new decimal[12];
                decimal[] totalDdc  = new decimal[12];
                decimal[] totAcmDdc = new decimal[12];

                CriteriaOperator[] operands = new CriteriaOperator[2];

                i           = 5;
                operands[1] = new BinaryOperator("Status", DocumentoStatus.Sellada, BinaryOperatorType.Equal);
                for (int mesini = 1; mesini < 13; mesini++)
                {
                    DateTime mFechaIni = apl.Log.Fecha.FechaInicial(mesini, ano);
                    DateTime mFechaFin = apl.Log.Fecha.FechaFinal(mesini, ano);

                    operands[0] = GroupOperator.And(
                        new BinaryOperator("FechaDoc", mFechaIni, BinaryOperatorType.GreaterOrEqual),
                        new BinaryOperator("FechaDoc", mFechaFin, BinaryOperatorType.LessOrEqual));
                    operands[1] = new BinaryOperator("Status", DocumentoStatus.Sellada, BinaryOperatorType.Equal);

                    IList arr = ((XPObjectSpace)View.ObjectSpace).CreateCollection(typeof(DocumentoSalida), new GroupOperator(operands), null);

                    total[mesini - 1]     = 0;
                    totAcm[mesini - 1]    = 0;
                    reten[mesini - 1]     = 0;
                    retAcm[mesini - 1]    = 0;
                    ivaTras[mesini - 1]   = 0;
                    ivaRet[mesini - 1]    = 0;
                    ivaAcr[mesini - 1]    = 0;
                    totalDdc[mesini - 1]  = 0;
                    totAcmDdc[mesini - 1] = 0;

                    if (arr.Count > 0)
                    {
                        foreach (DocumentoSalida doc in arr)
                        {
                            total[mesini - 1]   += doc.SubTotal;
                            reten[mesini - 1]   += doc.RetenISR;
                            ivaTras[mesini - 1] += doc.Impuesto04;
                            ivaRet[mesini - 1]  += doc.RetenIVA;
                        }
                    }


                    operands[0] = GroupOperator.And(
                        new BinaryOperator("FechaDoc", mFechaIni, BinaryOperatorType.GreaterOrEqual),
                        new BinaryOperator("FechaDoc", mFechaFin, BinaryOperatorType.LessOrEqual));
                    operands[1] = null;

                    arr = ((XPObjectSpace)View.ObjectSpace).CreateCollection(typeof(Recepcion), new GroupOperator(operands), null);

                    if (arr.Count > 0)
                    {
                        foreach (Recepcion doc in arr)
                        {
                            totalDdc[mesini - 1] += doc.SubTotal;
                            ivaAcr[mesini - 1]   += doc.Impuesto04;
                        }
                    }


                    if ((mesini - 1) > 0)
                    {
                        //     1, 2, ...,11          0, 1, ...,10        1, 2, ...,11
                        totAcm[mesini - 1]    += totAcm[mesini - 2] + total[mesini - 1];
                        retAcm[mesini - 1]    += retAcm[mesini - 2] + reten[mesini - 1];
                        totAcmDdc[mesini - 1] += totAcmDdc[mesini - 2] + totalDdc[mesini - 1];
                    }
                    else
                    {
                        //     0                   0
                        totAcm[mesini - 1]    = total[mesini - 1];
                        retAcm[mesini - 1]    = reten[mesini - 1];
                        totAcmDdc[mesini - 1] = totalDdc[mesini - 1];
                    }



                    if (total[mesini - 1] != 0)
                    {
                        sheet.Cells[i, 2].SetValue(total[mesini - 1]);
                        sheet.Cells[i, 2].NumberFormat = "$#,##0.00;[Red]$#,##0.00";
                    }
                    if (totalDdc[mesini - 1] != 0)
                    {
                        sheet.Cells[i, 3].SetValue(totalDdc[mesini - 1]);
                        sheet.Cells[i, 3].NumberFormat = "$#,##0.00;[Red]$#,##0.00";
                    }

                    if (reten[mesini - 1] != 0)
                    {
                        sheet.Cells[i, 5].SetValue(reten[mesini - 1]);
                        sheet.Cells[i, 5].NumberFormat = "$#,##0.00;[Red]$#,##0.00";
                    }

                    if (ivaTras[mesini - 1] != 0)
                    {
                        sheet.Cells[i, 7].SetValue(ivaTras[mesini - 1]);
                        sheet.Cells[i, 7].NumberFormat = "$#,##0.00;[Red]$#,##0.00";
                    }
                    if (ivaAcr[mesini - 1] != 0)
                    {
                        sheet.Cells[i, 8].SetValue(ivaAcr[mesini - 1]);
                        sheet.Cells[i, 8].NumberFormat = "$#,##0.00;[Red]$#,##0.00";
                    }
                    if (ivaRet[mesini - 1] != 0)
                    {
                        sheet.Cells[i, 9].SetValue(ivaRet[mesini - 1]);
                        sheet.Cells[i, 9].NumberFormat = "$#,##0.00;[Red]$#,##0.00";
                    }
                    sheet.Cells[i, 10].Formula        = string.Format("=h{0}-i{0}-j{0}", i + 1);
                    sheet.Cells[i++, 10].NumberFormat = "$#,##0.00;[Red]$#,##0.00";

                    if (mesini > 1)
                    {
                        sheet.Rows[i].FillColor = Color.FromName("BurlyWood");
                        //Beige"); // AntiqueWhite"); Bisque BlanchedAlmond

                        if (totAcm[mesini - 1] != 0)
                        {
                            sheet.Cells[i, 2].SetValue(totAcm[mesini - 1]);
                            sheet.Cells[i, 2].NumberFormat = "$#,##0.00;[Red]$#,##0.00";
                        }
                        if (totAcmDdc[mesini - 1] != 0)
                        {
                            sheet.Cells[i, 3].SetValue(totAcmDdc[mesini - 1]);
                            sheet.Cells[i, 3].NumberFormat = "$#,##0.00;[Red]$#,##0.00";
                        }
                        sheet.Cells[i, 4].Formula      = string.Format("=c{0}-d{0}", i + 1);
                        sheet.Cells[i, 4].NumberFormat = "$#,##0.00;[Red]$#,##0.00";

                        if (retAcm[mesini - 1] != 0)
                        {
                            sheet.Cells[i, 5].SetValue(retAcm[mesini - 1]);
                            sheet.Cells[i++, 5].NumberFormat = "$#,##0.00;[Red]$#,##0.00";
                        }
                        else
                        {
                            i++;
                        }
                    }
                }

                book.SaveDocument(string.Format("Contable.xls"));
            }

            /*
             * Workbook book = new Workbook();
             * var sheet = book.Worksheets.ActiveWorksheet;
             * sheet.Cells[0, 0].Value = "Carlos Javier Lopez Cruz";
             * sheet.Cells[1, 0].Value = "LOCC670416JI8";
             * // sheet.Cells[1, 1].Value = "litros67";
             * int ano = DateTime.Today.Month == 1 ? DateTime.Today.Year-1 : DateTime.Today.Year;
             *  // DateTime.Today.Year;
             *
             * sheet.Cells["A4"].Value = string.Format("Determinación del ISR provisional del Ejercicio {0}.",
             *  ano);
             *
             * sheet.Cells[5, 1].Value = "ENERO";
             * sheet.Cells[5, 4].Value = "FEBRERO";
             * sheet.Cells[5, 7].Value = "MARZO";
             * sheet.Cells[5, 10].Value = "ABRIL";
             * sheet.Cells[5, 13].Value = "MAYO";
             * sheet.Cells[5, 16].Value = "JUNIO";
             * sheet.Cells[5, 19].Value = "JULIO";
             * sheet.Cells[5, 22].Value = "AGOSTO";
             * sheet.Cells[5, 25].Value = "SEPTIEMBRE";
             * sheet.Cells[5, 28].Value = "OCTUBRE";
             * sheet.Cells[5, 31].Value = "NOVIEMBRE";
             * sheet.Cells[5, 34].Value = "DICIEMBRE";
             *
             *
             * XPObjectSpace objectSpace = (XPObjectSpace)View.ObjectSpace;
             * Empresa emp = objectSpace.FindObject<Empresa>(null);
             *
             * CriteriaOperator[] operands = new CriteriaOperator[2];
             * decimal[] total = new decimal[12];
             * decimal[] totAcm = new decimal[12];
             * decimal[] compr = new decimal[12];
             * decimal[] reten = new decimal[12];
             * decimal[] retAcm = new decimal[12];
             * decimal[] ivaTras = new decimal[12];
             * decimal[] ivaRet = new decimal[12];
             * decimal[] ivaAcr = new decimal[12];
             *
             * operands[1] = new BinaryOperator("Status", DocumentoStatus.Cancelado, BinaryOperatorType.NotEqual);
             *
             * sheet.Cells["A1"].Value = emp.Compania.Nombre;
             * sheet.Cells["B1"].Value = emp.Compania.Rfc;
             *
             * for (int mesini = 1; mesini < 13; mesini++)
             * {
             *  DateTime mFechaIni = Fecha.FechaInicial(mesini, ano);
             *  DateTime mFechaFin = Fecha.FechaFinal(mesini, ano);
             *
             *  operands[0] = GroupOperator.And(new BinaryOperator("FechaDoc", mFechaIni, BinaryOperatorType.GreaterOrEqual),
             *      new BinaryOperator("FechaDoc", mFechaFin, BinaryOperatorType.LessOrEqual));
             *
             *  IList arr = objectSpace.CreateCollection(typeof(DocumentoSalida), new GroupOperator(operands), null);
             *
             *  total[mesini - 1] = 0;
             *  totAcm[mesini - 1] = 0;
             *  reten[mesini - 1] = 0;
             *  retAcm[mesini - 1] = 0;
             *  ivaTras[mesini - 1] = 0;
             *  ivaRet[mesini - 1] = 0;
             *  ivaAcr[mesini - 1] = 0;
             *  if (arr.Count > 0)
             *  {
             *      foreach (DocumentoSalida doc in arr)
             *      {
             *          total[mesini - 1] += doc.SubTotal;
             *          reten[mesini - 1] += doc.RetenISR;
             *          ivaTras[mesini - 1] += doc.Impuesto04;
             *          ivaRet[mesini - 1] += doc.RetenIVA;
             *      }
             *
             *      if ((mesini - 1) > 0)
             *      {
             *          totAcm[mesini - 1] += totAcm[mesini - 2] + total[mesini - 2];
             *          retAcm[mesini - 1] += retAcm[mesini - 2] + reten[mesini - 2];
             *      }
             *  }
             * }
             *
             * sheet.Cells[6, 0].ColumnWidth = 470;
             * sheet.Cells["A7"].Value = "Ingresos Acumulados:";
             * sheet.Cells[6, 1].Value = 0;
             * sheet.Cells[6, 4].Value = total[0].ToString("n2");
             * sheet.Cells[6, 7].Value = (total[0] + total[1]).ToString("n2");
             * sheet.Cells[6, 10].Value = (total[0] + total[1] + total[2]).ToString("n2");
             * sheet.Cells[6, 13].Value = (total[0] + total[1] + total[2]
             + total[3]).ToString("n2");
             + sheet.Cells[6, 16].Value = (total[0] + total[1] + total[2]
             + total[3] + total[4]).ToString("n2");
             + sheet.Cells[6, 19].Value = (total[0] + total[1] + total[2]
             + total[3] + total[4] + total[5]).ToString("n2");
             + sheet.Cells[6, 22].Value = (total[0] + total[1] + total[2]
             + total[3] + total[4] + total[5] + total[6]).ToString("n2");
             + sheet.Cells[6, 25].Value = (total[0] + total[1] + total[2]
             + total[3] + total[4] + total[5] + total[6] + total[7]).ToString("n2");
             + sheet.Cells[6, 28].Value = (total[0] + total[1] + total[2]
             + total[3] + total[4] + total[5] + total[6] + total[7]
             + total[8]).ToString("n2");
             + sheet.Cells[6, 31].Value = (total[0] + total[1] + total[2]
             + total[3] + total[4] + total[5] + total[6] + total[7]
             + total[8] + total[9]).ToString("n2");
             + sheet.Cells[6, 34].Value = (total[0] + total[1] + total[2]
             + total[3] + total[4] + total[5] + total[6] + total[7]
             + total[8] + total[9] + total[10]).ToString("n2");
             +
             + sheet.Cells["A8"].Value = "Ingresos:";
             + sheet.Cells[7, 1].Value = total[0].ToString("n2");
             + sheet.Cells[7, 4].Value = total[1].ToString("n2");
             + sheet.Cells[7, 7].Value = total[2].ToString("n2");
             + sheet.Cells[7, 10].Value = total[3].ToString("n2");
             + sheet.Cells[7, 13].Value = total[4].ToString("n2");
             + sheet.Cells[7, 16].Value = total[5].ToString("n2");
             + sheet.Cells[7, 19].Value = total[6].ToString("n2");
             + sheet.Cells[7, 22].Value = total[7].ToString("n2");
             + sheet.Cells[7, 25].Value = total[8].ToString("n2");
             + sheet.Cells[7, 28].Value = total[9].ToString("n2");
             + sheet.Cells[7, 31].Value = total[10].ToString("n2");
             + sheet.Cells[7, 34].Value = total[11].ToString("n2");
             +
             + sheet.Cells["A9"].Value = "Total de Ingresos:";
             + sheet.Cells[8, 2].Value = (total[0] + totAcm[0]).ToString("n2");
             + sheet.Cells[8, 5].Value = (total[1] + totAcm[1]).ToString("n2");
             + sheet.Cells[8, 8].Value = (total[2] + totAcm[2]).ToString("n2");
             + sheet.Cells[8, 11].Value = (total[3] + totAcm[3]).ToString("n2");
             + sheet.Cells[8, 14].Value = (total[4] + totAcm[4]).ToString("n2");
             + sheet.Cells[8, 17].Value = (total[5] + totAcm[5]).ToString("n2");
             + sheet.Cells[8, 20].Value = (total[6] + totAcm[6]).ToString("n2");
             + sheet.Cells[8, 23].Value = (total[7] + totAcm[7]).ToString("n2");
             + sheet.Cells[8, 26].Value = (total[8] + totAcm[8]).ToString("n2");
             + sheet.Cells[8, 29].Value = (total[9] + totAcm[9]).ToString("n2");
             + sheet.Cells[8, 32].Value = (total[10] + totAcm[10]).ToString("n2");
             + sheet.Cells[8, 35].Value = (total[11] + totAcm[11]).ToString("n2");
             +
             +
             +
             + decimal[] totalDdc = new decimal[12];
             + decimal[] totAcmDdc = new decimal[12];
             + for (int mesini = 1; mesini < 13; mesini++)
             + {
             +  DateTime mFechaIni = Fecha.FechaInicial(mesini, ano);
             +  DateTime mFechaFin = Fecha.FechaFinal(mesini, ano);
             +
             +  operands[0] = GroupOperator.And(new BinaryOperator("FechaDoc", mFechaIni, BinaryOperatorType.GreaterOrEqual),
             +      new BinaryOperator("FechaDoc", mFechaFin, BinaryOperatorType.LessOrEqual));
             +
             +  IList arr = objectSpace.CreateCollection(typeof(Recepcion), new GroupOperator(operands), null);
             +
             +  totalDdc[mesini - 1] = 0;
             +  totAcmDdc[mesini - 1] = 0;
             +  ivaAcr[mesini - 1] = 0;
             +  if (arr.Count > 0)
             +  {
             +      foreach (Recepcion doc in arr)
             +      {
             +          totalDdc[mesini - 1] += doc.SubTotal;
             +          ivaAcr[mesini - 1] += doc.Impuesto04;
             +      }
             +
             +      if ((mesini - 1) > 0)
             +          totAcmDdc[mesini - 1] += totAcmDdc[mesini - 2] + totalDdc[mesini - 2];
             +  }
             + }
             +
             + sheet.Cells[9, 0].Value = "Deducciones Acumuladas:";
             + sheet.Cells[9, 1].Value = totAcmDdc[0].ToString("n2");
             + sheet.Cells[9, 4].Value = totAcmDdc[1].ToString("n2");
             + sheet.Cells[9, 7].Value = totAcmDdc[2].ToString("n2");
             + sheet.Cells[9, 10].Value = totAcmDdc[3].ToString("n2");
             + sheet.Cells[9, 13].Value = totAcmDdc[4].ToString("n2");
             + sheet.Cells[9, 16].Value = totAcmDdc[5].ToString("n2");
             + sheet.Cells[9, 19].Value = totAcmDdc[6].ToString("n2");
             + sheet.Cells[9, 22].Value = totAcmDdc[7].ToString("n2");
             + sheet.Cells[9, 25].Value = totAcmDdc[8].ToString("n2");
             + sheet.Cells[9, 28].Value = totAcmDdc[9].ToString("n2");
             + sheet.Cells[9, 31].Value = totAcmDdc[10].ToString("n2");
             + sheet.Cells[9, 34].Value = totAcmDdc[11].ToString("n2");
             +
             + int ren = 10;
             + sheet.Cells[ren, 0].Value = "Deducciones:";
             + for (int i = 0; i < 12; i++)
             +  sheet.Cells[ren, 1+3*i].Value = totalDdc[i].ToString("n2");
             +
             + ren = 11;
             + sheet.Cells[ren, 0].Value = "Total de Deducciones:";
             + for (int i = 0; i < 12; i++)
             +  sheet.Cells[ren, 2+3*i].Value = (totalDdc[i] + totAcmDdc[i]).ToString("n2");
             +
             + ren++;
             + sheet.Cells[++ren, 0].Value = "Base ISR:";
             + for (int i = 0; i < 12; i++)
             + {
             +  sheet[ren, 2+3*i].Value = (total[i] + totAcm[i]- (totalDdc[i] + totAcmDdc[i])) > 0
             +      ? (total[i] + totAcm[i] - (totalDdc[i] + totAcmDdc[i])).ToString("n2") : "-";
             + }
             +
             + sheet.Cells[++ren, 0].Value = "Límite Inferior:";
             + sheet.Cells[++ren, 0].Value = "Excedente L.I.:";
             + sheet.Cells[++ren, 0].Value = "% Marginal:";
             + sheet.Cells[++ren, 0].Value = "Impuesto Marginal:";
             + sheet.Cells[++ren, 0].Value = "Cuotra fija:";
             + sheet.Cells[++ren, 0].Value = "ISR Causado:";
             +
             + ren++;
             + ren++;
             + sheet.Cells[ren, 0].Value = "Retenciones Acumuladas:";
             + for (int i = 0; i < 12; i++)
             +  sheet.Cells[ren, 1+3*i].Value = retAcm[i].ToString("n2");
             +
             + ren++;
             + sheet.Cells[ren, 0].Value = "Retención ISR:";
             + for (int i = 0; i < 12; i++)
             +  sheet.Cells[ren, 1 + 3 * i].Value = reten[i].ToString("n2");
             +
             + ren++;
             + sheet.Cells[ren, 0].Value = "Total de Retenciones:";
             + for (int i = 0; i < 12; i++)
             +  sheet.Cells[ren, 2 + 3 * i].Value = (reten[i] + retAcm[i]).ToString("n2");
             +
             + ren++;
             + sheet.Cells[++ren, 0].Value = "Determinacion del Impuesto al Valor Agregado Mensual del Ejercicio 2014";
             +
             + ren++;
             + ren++;
             + sheet.Cells[ren, 0].Value = "IVA trasladado:";
             + for (int i = 0; i < 12; i++)
             +  sheet.Cells[ren, 1 + 3 * i].Value = ivaTras[i].ToString("n2");
             +
             + ren++;
             + sheet.Cells[ren, 0].Value = "Retención IVA:";
             + for (int i = 0; i < 12; i++)
             +  sheet.Cells[ren, 1 + 3 * i].Value = ivaRet[i].ToString("n2");
             +
             + ren++;
             + sheet.Cells[ren, 0].Value = "IVA Acreditable:";
             + for (int i = 0; i < 12; i++)
             +  sheet.Cells[ren, 1 + 3 * i].Value = ivaAcr[i].ToString("n2");
             +
             + ren++;
             + sheet.Cells[ren, 0].Value = "Saldo a favor de IVA:";
             + for (int i = 0; i < 12; i++)
             +  sheet.Cells[ren, 1 + 3 * i].Value =  ivaTras[i] - ivaRet[i]-ivaAcr[i] > 0 ? "0" :
             +      Math.Round(ivaAcr[i] + ivaRet[i] - ivaTras[i]).ToString("n2");
             +
             + ren++;
             + sheet.Cells[ren, 0].Value = "Saldo a pagar de IVA:";
             + for (int i = 0; i < 12; i++)
             +  sheet.Cells[ren, 1 + 3 * i].Value = ivaTras[i] - ivaRet[i] - ivaAcr[i] > 0 ?
             +      Math.Round(ivaTras[i] - ivaRet[i] - ivaAcr[i]).ToString("n2") : "0";
             +
             + book.SaveDocument(string.Format("Contable.xls"));*/
        }
예제 #57
0
        private CriteriaOperator SearchCriteriaObjectBuilder()
        {
            CriteriaOperator criteria    = null;
            CriteriaOperator criteriaAND = null;
            CriteriaOperator criteriaOR  = null;

            criteria = new GroupOperator();
            ((GroupOperator)criteria).OperatorType = GroupOperatorType.And;

            criteriaAND = new GroupOperator();
            ((GroupOperator)criteriaAND).OperatorType = GroupOperatorType.And;

            criteriaOR = new GroupOperator();
            ((GroupOperator)criteriaOR).OperatorType = GroupOperatorType.Or;


            // Конъюнктивные члены

            if (this.DateBegin != System.DateTime.MinValue)
            {
                CriteriaOperator criteriathisDateBegin = new BinaryOperator("ObligationUnitDateTime", this.DateBegin, BinaryOperatorType.GreaterOrEqual);
                ((GroupOperator)criteriaAND).Operands.Add(criteriathisDateBegin);
            }

            if (this.DateEnd != System.DateTime.MinValue)
            {
                CriteriaOperator criteriathisDateEnd = new BinaryOperator("ObligationUnitDateTime", this.DateEnd, BinaryOperatorType.LessOrEqual);
                ((GroupOperator)criteriaAND).Operands.Add(criteriathisDateEnd);
            }

            // BEGIN
            CriteriaOperator criteriaCustomerAND = new GroupOperator();

            ((GroupOperator)criteriaCustomerAND).OperatorType = GroupOperatorType.And;


            CriteriaOperator criteriaPrimaryParty = null;

            if (this.PrimaryParty != null)
            {
                criteriaPrimaryParty = new BinaryOperator("PrimaryParty.Oid", PrimaryParty.Oid, BinaryOperatorType.Equal);
                ((GroupOperator)criteriaCustomerAND).Operands.Add(criteriaPrimaryParty);
            }

            CriteriaOperator criteriaContragentParty = null;

            if (this.ContragentParty != null)
            {
                criteriaContragentParty = new BinaryOperator("ContragentParty.Oid", ContragentParty.Oid, BinaryOperatorType.Equal);
                ((GroupOperator)criteriaCustomerAND).Operands.Add(criteriaContragentParty);
            }


            if (((GroupOperator)criteriaCustomerAND).Operands.Count > 0)
            {
                ((GroupOperator)criteriaAND).Operands.Add(criteriaCustomerAND);
            }


            CriteriaOperator criteriaContract = null;

            if (this.Contract != null)
            {
                criteriaContract = new BinaryOperator("Contract.Oid", Contract.Oid, BinaryOperatorType.Equal);
                ((GroupOperator)criteriaCustomerAND).Operands.Add(criteriaContract);
            }

            CriteriaOperator criteriaContractDeal = null;

            if (this.ContractDeal != null)
            {
                criteriaContractDeal = new BinaryOperator("ContractDeal.Oid", ContractDeal.Oid, BinaryOperatorType.Equal);
                ((GroupOperator)criteriaCustomerAND).Operands.Add(criteriaContractDeal);
            }

            CriteriaOperator criteriaStage = null;

            if (this.Stage != null)
            {
                criteriaStage = new BinaryOperator("Stage.Oid", Stage.Oid, BinaryOperatorType.Equal);
                ((GroupOperator)criteriaCustomerAND).Operands.Add(criteriaStage);
            }

            CriteriaOperator criteriaValuta = null;

            if (this.Valuta != null)
            {
                criteriaValuta = new BinaryOperator("Valuta.Oid", Valuta.Oid, BinaryOperatorType.Equal);
                ((GroupOperator)criteriaAND).Operands.Add(criteriaValuta);
            }

            // Совокупность критериев OR добавляем через AND к общей совокупности поисковых членов
            if (((GroupOperator)criteriaAND).Operands.Count > 0)
            {
                ((GroupOperator)criteria).Operands.Add(criteriaAND);
            }

            if (((GroupOperator)criteria).Operands.Count > 0)
            {
                return(criteria);
            }
            else
            {
                return(null);
            }
        }
예제 #58
0
파일: VCPresupuesto.cs 프로젝트: icpac/cap
        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);
                }
            }
        }
예제 #59
0
        private void singleChoiceActionPolz_Execute(object sender, DevExpress.ExpressApp.Actions.SingleChoiceActionExecuteEventArgs e)
        {
            XPObjectSpace objectSpace = (XPObjectSpace)View.ObjectSpace;
            int           mes         = Convert.ToInt32((e.SelectedChoiceActionItem.Data));
            int           ano         = mes == 12 && DateTime.Today.Month == 1 ? DateTime.Today.Year - 1 : DateTime.Today.Year;
            DateTime      mFechaIni   = apl.Log.Fecha.FechaInicial(mes, ano);
            DateTime      mFechaFin   = apl.Log.Fecha.FechaFinal(mes, ano);

            CriteriaOperator[] operands = new CriteriaOperator[2];
            XmlDocument        docXml   = new XmlDocument();
            Ventas             vta      = objectSpace.FindObject <Ventas>(null);

            operands[0] = GroupOperator.And(new BinaryOperator("FechaDoc", mFechaIni, BinaryOperatorType.GreaterOrEqual), new BinaryOperator("FechaDoc", mFechaFin, BinaryOperatorType.LessOrEqual));
            operands[1] = new BinaryOperator("Status", DocumentoStatus.Cancelado, BinaryOperatorType.NotEqual);

            SortProperty [] sortCollection = new SortProperty[1];
            sortCollection[0] = new SortProperty("FechaDoc", SortingDirection.Ascending);

            IList arr = objectSpace.CreateCollection(typeof(DocumentoSalida), new GroupOperator(operands), sortCollection);

            if (arr.Count > 0)
            {
                string filename = string.Format("{0}.POL", mFechaIni.Month);
                using (new apl.Log.CWaitCursor())
                {
                    XmlDeclaration declaracion = docXml.CreateXmlDeclaration("1.0", null, "yes");
                    docXml.InsertBefore(declaracion, docXml.DocumentElement);
                    // docXml.LoadXml("<?xml version=\"1.0\" standalone=\"yes\"?>");
                    XmlElement data = docXml.CreateElement("DATAPACKET");
                    data.SetAttribute("Version", "2.0");
                    docXml.AppendChild(data);

                    XmlElement meta = docXml.CreateElement("METADATA");
                    data.AppendChild(meta);

                    XmlElement fields = docXml.CreateElement("FIELDS");
                    meta.AppendChild(fields);

                    XmlElement field = docXml.CreateElement("FIELD");
                    field.SetAttribute("attrname", "VersionCOI");
                    field.SetAttribute("fieldtype", "i2");
                    fields.AppendChild(field);

                    field = docXml.CreateElement("FIELD");
                    field.SetAttribute("attrname", "TipoPoliz");
                    field.SetAttribute("fieldtype", "string");
                    field.SetAttribute("WIDTH", "2");
                    fields.AppendChild(field);

                    field = docXml.CreateElement("FIELD");
                    field.SetAttribute("attrname", "DiaPoliz");
                    field.SetAttribute("fieldtype", "string");
                    field.SetAttribute("WIDTH", "2");
                    fields.AppendChild(field);

                    field = docXml.CreateElement("FIELD");
                    field.SetAttribute("attrname", "ConcepPoliz");
                    field.SetAttribute("fieldtype", "string");
                    field.SetAttribute("WIDTH", "120");
                    fields.AppendChild(field);

                    XmlElement fieldP = docXml.CreateElement("FIELD");
                    fieldP.SetAttribute("attrname", "Partidas");
                    fieldP.SetAttribute("fieldtype", "nested");
                    fields.AppendChild(fieldP);

                    XmlElement fields2 = docXml.CreateElement("FIELDS");
                    fieldP.AppendChild(fields2);

                    field = docXml.CreateElement("FIELD");
                    field.SetAttribute("attrname", "Cuenta");
                    field.SetAttribute("fieldtype", "string");
                    field.SetAttribute("WIDTH", "21");
                    fields2.AppendChild(field);

                    field = docXml.CreateElement("FIELD");
                    field.SetAttribute("attrname", "Depto");
                    field.SetAttribute("fieldtype", "i4");
                    fields2.AppendChild(field);

                    field = docXml.CreateElement("FIELD");
                    field.SetAttribute("attrname", "ConceptoPol");
                    field.SetAttribute("fieldtype", "string");
                    field.SetAttribute("WIDTH", "120");
                    fields2.AppendChild(field);

                    field = docXml.CreateElement("FIELD");
                    field.SetAttribute("attrname", "Monto");
                    field.SetAttribute("fieldtype", "r8");
                    fields2.AppendChild(field);

                    field = docXml.CreateElement("FIELD");
                    field.SetAttribute("attrname", "TipoCambio");
                    field.SetAttribute("fieldtype", "r8");
                    fields2.AppendChild(field);

                    field = docXml.CreateElement("FIELD");
                    field.SetAttribute("attrname", "DebeHaber");
                    field.SetAttribute("fieldtype", "string");
                    field.SetAttribute("WIDTH", "1");
                    fields2.AppendChild(field);


                    XmlElement parm = docXml.CreateElement("PARAMS");
                    fieldP.AppendChild(parm);

                    XmlElement parm1 = docXml.CreateElement("PARAMS");
                    meta.AppendChild(parm1);

                    XmlElement rowd = docXml.CreateElement("ROWDATA");
                    data.AppendChild(rowd);

                    XmlElement row = docXml.CreateElement("ROW");
                    row.SetAttribute("VersionCOI", "50");
                    row.SetAttribute("TipoPoliz", "Dr");
                    row.SetAttribute("DiaPoliz", string.Format("{0}", arr.Count + 1));
                    row.SetAttribute("ConcepPoliz", string.Format("RELACION DE FACTURAS DE {0} {1}", mFechaIni.ToString("MMMM").ToUpper(), mFechaIni.ToString("yyyy")));
                    rowd.AppendChild(row);

                    XmlElement par = docXml.CreateElement("Partidas");
                    row.AppendChild(par);

                    decimal  tot = 0;
                    string[] nivs;
                    string   aux = string.Empty;

                    foreach (DocumentoSalida doc in arr)
                    {
                        XmlElement part = docXml.CreateElement("ROWPartidas");
                        nivs = string.IsNullOrEmpty(doc.Cliente.Cuenta) ? null : doc.Cliente.Cuenta.Split('-');
                        if (nivs != null)
                        {
                            aux = string.Concat(nivs);
                        }

                        part.SetAttribute("Cuenta", string.Format("{0}2", aux.PadRight(20, '0')));
                        part.SetAttribute("Depto", "0");

                        aux = string.Format("F-{0}  {1}", doc.Clave.Trim(), ((PartidaSalida)(doc.VentaItems[0])).Descripcion);
                        part.SetAttribute("ConceptoPol", aux.Length > 120 ? aux.Substring(0, 119) : aux);
                        part.SetAttribute("Monto", doc.Total.ToString("F2"));
                        part.SetAttribute("TipoCambio", "1");
                        part.SetAttribute("DebeHaber", "D");
                        par.AppendChild(part);

                        tot += doc.Total;
                    }

                    XmlElement parth = docXml.CreateElement("ROWPartidas");

                    nivs = string.IsNullOrEmpty(vta.Cuenta) ? null : vta.Cuenta.Split('-');
                    if (nivs != null)
                    {
                        aux = string.Concat(nivs);
                    }

                    parth.SetAttribute("Cuenta", string.Format("{0}2", aux.PadRight(20, '0')));
                    parth.SetAttribute("Depto", "0");
                    parth.SetAttribute("ConceptoPol", string.Format("RELACION DE FACTURAS DE {0} {1}", mFechaIni.ToString("MMMM").ToUpper(), mFechaIni.ToString("yyyy")));
                    parth.SetAttribute("Monto", tot.ToString("F2"));
                    parth.SetAttribute("TipoCambio", "1");
                    parth.SetAttribute("DebeHaber", "H");
                    par.AppendChild(parth);

                    docXml.Save(filename);
                }
            }
        }
예제 #60
0
파일: Negocio.cs 프로젝트: icpac/cap
        public static void GrabaCxc(Cxc obj, Parametros prm, IObjectSpace osp)
        {
            if (obj != null && obj.IsNewObject())
            {
                if (obj.Cliente != null)
                {
                    obj.Cliente.Saldo += obj.Cepto.Tipo == EConceptoTipo.Cargo ? obj.Monto : -obj.Monto;
                }

                if (prm == null)
                {
                    prm = obj.Session.FindObject <Parametros>(null);
                }

                if (prm != null)
                {
                    if (obj.Cepto.Tipo == EConceptoTipo.Abono)
                    {
                        if (obj.Dclrbl)
                        {
                            obj.Folio = prm.UltmPg.ToString();
                            prm.UltmPg++;
                        }
                        else
                        {
                            obj.Folio = prm.UltmPgNDclrbl.ToString();
                            prm.UltmPgNDclrbl++;
                        }
                    }
                }

                obj.Saldo += obj.Monto;
                if (obj.Cepto.Tipo == EConceptoTipo.Abono)
                {
                    decimal aux     = obj.Monto;
                    decimal totmont = 0;

                    int pos = 0;
                    while (pos < obj.Crgs.Count)
                    {
                        if (((CxcItem)(obj.Crgs[pos])).Monto <= 0)
                        {
                            CxcItem it = ((CxcItem)(obj.Crgs[pos]));
                            osp.Delete(it);
                            osp.RemoveFromModifiedObjects(it);
                            // obj.Crgs.Remove(obj.Crgs[pos]);
                            // pos++;
                        }
                        else
                        {
                            pos++;
                        }
                    }

                    /*
                     * pos = 0;
                     * while (pos < obj.Crgs.Count)
                     * {
                     *  if (((CxcItem)(obj.Crgs[pos])).Monto <= 0)
                     *  {
                     *      obj.Crgs.Remove(obj.Crgs[pos]);
                     *  }
                     *  else
                     *      pos++;
                     * }*/



                    foreach (CxcItem crgs in obj.Crgs)
                    {
                        totmont += crgs.Monto;
                    }
                    if (totmont != aux)
                    {
                        throw new Exception("El Total NO coincide con la suma de los Parciales !");
                    }

                    foreach (CxcItem crgs in obj.Crgs)
                    {
                        if (crgs.Monto > crgs.Crg.Saldo && (crgs.Monto - crgs.Crg.Saldo) > 0.009m)
                        {
                            throw new Exception("El PAGO  NO  puede ser mayor a lo que DEBE !");
                        }
                    }

                    foreach (CxcItem crgs in obj.Crgs)
                    {
                        /*
                         * if (aux > 0)
                         * {*/
                        /*
                         *  if (crgs.Monto / * aux* / >= crgs.Crg.Saldo) // crgs.Saldo)
                         *  {
                         *      aux -= crgs.Crg.Saldo; // crgs.Saldo;
                         *      crgs.Crg.Saldo = 0; // crgs.Saldo = 0;
                         *  }
                         *  else
                         *  {
                         *      crgs.Crg.Saldo -= crgs.Monto; // aux; // crgs.Saldo -= aux;
                         *      aux = 0;
                         *  }*/
                        crgs.Crg.Saldo -= crgs.Monto;
                        aux            -= crgs.Monto;

                        //---------------------------------------------------------------------
                        // Balance
                        GroupOperator fil2 = new GroupOperator();

                        string axCncpt = crgs.Crg.CncptSrvc; //.Cncpt;

                        if (string.IsNullOrEmpty(axCncpt))
                        {
                            axCncpt = crgs.Crg.Cncpt.Trim();
                            if (axCncpt.Contains("COLEGIATURA"))
                            {
                                axCncpt = "COLEGIATURA";
                            }
                            else if (axCncpt.Contains("UNIFORMES"))
                            {
                                axCncpt = "UNIFORMES";
                            }
                            else if (axCncpt.Contains("TRANSPORTE"))
                            {
                                axCncpt = "TRANSPORTE";
                            }
                            else if (axCncpt.Contains("LUNCHS Y AGUA"))
                            {
                                axCncpt = "LUNCHS Y AGUA";
                            }
                        }

                        fil2.Operands.Add(new BinaryOperator("Cncpt", axCncpt));
                        fil2.Operands.Add(new BinaryOperator("Dclrbl", obj.Dclrbl));
                        fil2.Operands.Add(new BinaryOperator("FrmPg", obj.FrmPg));
                        fil2.Operands.Add(new BinaryOperator("Fch", new DateTime(obj.FchApl.Year, obj.FchApl.Month, obj.FchApl.Day)));
                        fil2.Operands.Add(new BinaryOperator("Tp", EBalanceTipo.Cobro));
                        Balance bl = obj.Session.FindObject <Balance>(fil2);

                        if (bl == null)
                        {
                            bl = new Balance(obj.Session);

                            // Estos pueden ser diferentes
                            bl.Dclrbl = obj.Dclrbl;
                            if (obj.FrmPg != null)
                            {
                                bl.FrmPg = obj.Session.FindObject <Catalogo>(new BinaryOperator("Oid", obj.FrmPg.Oid));
                            }
                            bl.Fch = new DateTime(obj.FchApl.Year, obj.FchApl.Month, obj.FchApl.Day); // obj.FchApl;

                            bl.Mnt   = crgs.Monto;
                            bl.Cncpt = axCncpt;
                            bl.Tp    = EBalanceTipo.Cobro;
                        }
                        else
                        {
                            bl.Mnt += crgs.Monto;
                        }
                    }
                    obj.Saldo = aux;
                }
            }
        }