Example #1
0
        public int getLastISN()
        {
            if (ContractRegistrationLogLastRecord != null)
            {
                return(ContractRegistrationLogLastRecord.ISN);
            }

            // Смотрим, какой наибольший номер есть в базе
            //CriteriaOperator criteriaISN = CriteriaOperator.Parse("ISN = Max(ISN)");

            //SortingCollection sorting = new SortingCollection();
            ////sorting.Add(new SortProperty("", SortingDirection.Ascending));
            //sorting.Add(new SortProperty("ISN", DevExpress.Xpo.DB.SortingDirection.Descending));
            SortProperty[] sorting = { new SortProperty("ISN", DevExpress.Xpo.DB.SortingDirection.Descending) };

            //XPCollection<crmContractRegistrationLog> crl = new XPCollection<crmContractRegistrationLog>(this.Session, criteriaISN, sorting);
            XPCollection <crmContractRegistrationLog> crl = new XPCollection <crmContractRegistrationLog>(this.Session, null, sorting);

            crl.TopReturnedObjects = 1;
            if (!crl.IsLoaded)
            {
                crl.Load();
            }

            if (crl.Count > 0)
            {
                ContractRegistrationLogLastRecord = crl[0];
                return(crl[0].ISN);
            }
            else
            {
                return(0);
            }
        }
Example #2
0
        public int getConditionalLastISN()
        {
            if (ContractRegistrationLogConditionalLastRecord != null)
            {
                return(ContractRegistrationLogConditionalLastRecord.ISN);
            }

            // Смотрим, какой наибольший номер есть в базе
            CriteriaOperator criteria = null;

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

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

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

            //CriteriaOperator criteriaDocNumberDepartment = null;
            //if (!string.IsNullOrEmpty(DocNumberDepartment)) {
            //    criteriaDocNumberDepartment = new BinaryOperator("DocNumberDepartment", DocNumberDepartment, BinaryOperatorType.Equal);
            //    ((GroupOperator)criteria).Operands.Add(criteriaDocNumberDepartment);
            //}

            CriteriaOperator criteriaDocNumberDepartment = null;

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

            SortProperty[] sorting = { new SortProperty("ISN", DevExpress.Xpo.DB.SortingDirection.Descending) };

            //XPCollection<crmContractRegistrationLog> crl = new XPCollection<crmContractRegistrationLog>(this.Session, criteriaISN, sorting);
            XPCollection <crmContractRegistrationLog> crl = new XPCollection <crmContractRegistrationLog>(this.Session, criteria, sorting);

            crl.TopReturnedObjects = 1;
            if (!crl.IsLoaded)
            {
                crl.Load();
            }

            if (crl.Count > 0)
            {
                ContractRegistrationLogConditionalLastRecord = crl[0];
                return(crl[0].ISN);
            }
            else
            {
                return(0);
            }
        }