Ejemplo n.º 1
0
 protected void ASPxGridView2_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
 {
     e.NewValues["RowStatus"] = Constant.ROWSTATUS_ACTIVE;
     if (e.NewValues["IsDefault"] == null)
     {
         e.NewValues["IsDefault"] = false;
     }
     if (Util.isExistXpoObject <AccountingPeriodType>("Name", (string)e.NewValues["Name"]))
     {
         e.Cancel = true;
         throw(new Exception("Trùng tên thể loại chu kì"));
     }
     if ((bool)e.NewValues["IsDefault"] == true)
     {
         CriteriaOperator     criteria = new BinaryOperator("IsDefault", true, BinaryOperatorType.Equal);
         AccountingPeriodType type     = session.FindObject <AccountingPeriodType>(criteria);
         e.NewValues["RowStatus"] = Constant.ROWSTATUS_ACTIVE;
         if (type != null)
         {
             if (AccountingPeriodTypeBO.IsUsedAccoutingPeriodType(session, type.AccountingPeriodTypeId))
             {
                 ASPxGridView2.CancelEdit();
                 throw new Exception("Loại chu kì nhỏ nhất " + type.Name + " đang được sử dụng nên không thể thay đổi");
             }
             type.IsDefault = false;
             type.Save();
         }
     }
 }
Ejemplo n.º 2
0
        protected void cboAccountPeriod_ItemsRequestedByFilterCondition(object source, ListEditItemsRequestedByFilterConditionEventArgs e)
        {
            ASPxComboBox combo = source as ASPxComboBox;
            XPCollection <AccountingPeriod> collection = new XPCollection <AccountingPeriod>(session);

            collection.SkipReturnedObjects = e.BeginIndex;
            collection.TopReturnedObjects  = e.EndIndex - e.BeginIndex + 1;

            AccountingPeriodTypeBO typeBO = new AccountingPeriodTypeBO();
            AccountingPeriodType   minAccountingPeriodType = typeBO.GetMinAccountingPeriodType(session);

            CriteriaOperator criteria_RowStatus = new BinaryOperator("RowStatus", Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual);
            CriteriaOperator criteria_IsActive  = new BinaryOperator("IsActive", true, BinaryOperatorType.Equal);
            CriteriaOperator criteria_Type      = new BinaryOperator("AccountingPeriodTypeId", minAccountingPeriodType, BinaryOperatorType.Equal);
            CriteriaOperator criteria           = CriteriaOperator.And(criteria_IsActive, criteria_RowStatus, criteria_Type);
            XPCollection <AccountingPeriod> AccountingPeriodCol = new XPCollection <AccountingPeriod>(session, criteria);

            criteria = CriteriaOperator.And(
                CriteriaOperator.Or(
                    new BinaryOperator("Code", String.Format("%{0}%", e.Filter), BinaryOperatorType.Like),
                    new BinaryOperator("Description", String.Format("%{0}%", e.Filter), BinaryOperatorType.Like)
                    ),
                new BinaryOperator("RowStatus", 1, BinaryOperatorType.GreaterOrEqual),
                new InOperator("this", AccountingPeriodCol)
                );

            collection.Criteria = criteria;
            collection.Sorting.Add(new SortProperty("Code", DevExpress.Xpo.DB.SortingDirection.Ascending));

            combo.DataSource = collection;
            combo.DataBindItems();
        }
Ejemplo n.º 3
0
        protected void ASPxGridView2_StartRowEditing(object sender, DevExpress.Web.Data.ASPxStartRowEditingEventArgs e)
        {
            Guid accountingPeriodTypeId = (Guid)e.EditingKeyValue;

            if (AccountingPeriodTypeBO.IsUsedAccoutingPeriodType(session, accountingPeriodTypeId))
            {
                ((ASPxGridView)sender).CancelEdit();
                throw new Exception("Loại chu kì này đang được sử dụng, không cho phép chỉnh sửa");
            }
        }
Ejemplo n.º 4
0
 protected void ASPxGridView2_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
 {
     if (Util.isExistXpoObject <AccountingPeriodType>("Name", (string)e.NewValues["Name"]))
     {
         CriteriaOperator     criteria_0 = new BinaryOperator("Name", (string)e.NewValues["Name"], BinaryOperatorType.Equal);
         CriteriaOperator     criteria_1 = new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_ACTIVE, BinaryOperatorType.GreaterOrEqual);
         CriteriaOperator     criteria_2 = new BinaryOperator("AccountingPeriodTypeId", e.Keys[0], BinaryOperatorType.NotEqual);
         CriteriaOperator     criteria   = new GroupOperator(GroupOperatorType.And, criteria_0, criteria_1, criteria_2);
         AccountingPeriodType type       = session.FindObject <AccountingPeriodType>(criteria);
         if (type != null)
         {
             e.Cancel = true;
             throw (new Exception("Trùng tên thể loại chu kì"));
         }
     }
     if (e.NewValues["IsDefault"] == null)
     {
         e.NewValues["IsDefault"] = false;
     }
     if ((bool)e.NewValues["IsDefault"] == true)
     {
         CriteriaOperator     criteria = new BinaryOperator("IsDefault", true, BinaryOperatorType.Equal);
         AccountingPeriodType type     = session.FindObject <AccountingPeriodType>(criteria);
         if (type != null)
         {
             if (AccountingPeriodTypeBO.IsUsedAccoutingPeriodType(session, type.AccountingPeriodTypeId))
             {
                 ASPxGridView2.CancelEdit();
                 throw new Exception("Loại chu kì nhỏ nhất " + type.Name + " đang được sử dụng nên không thể thay đổi");
             }
             type.IsDefault = false;
             type.Save();
         }
     }
     else
     {
         if (e.OldValues["IsDefault"].ToString() == "True")
         {
             e.Cancel = true;
             ASPxGridView2.CancelEdit();
             throw (new Exception("Phải luôn có 1 thể loại chu kì nhỏ nhất"));
         }
     }
 }