Esempio n. 1
0
        protected void ASPxGridTax_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            e.Cancel = true;
            Guid ItemTaxId = (Guid)e.Keys[0];

            if (ItemTaxId != null)
            {
                NAS.DAL.Nomenclature.Item.ItemTax itemtax = session.GetObjectByKey <NAS.DAL.Nomenclature.Item.ItemTax>(ItemTaxId);
                itemtax.RowStatus = Utility.Constant.ROWSTATUS_DELETED;
                itemtax.Save();
                //ASPxGridTax.DataBind();
            }
        }
Esempio n. 2
0
        private void PopulateDefaultTaxForAllItems()
        {
            using (Session session = XpoHelper.GetNewSession())
            {
                XPCollection <Item> itemList = new XPCollection <Item>(session,
                                                                       new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_ACTIVE));

                //TaxType VATTaxType = session.FindObject<TaxType>(new BinaryOperator("Code", "GTGT"));
                TaxType VATTaxType = session.FindObject <TaxType>(new BinaryOperator("Code", "VAT"));

                CriteriaOperator defaultTaxCriteria = CriteriaOperator.And(
                    new BinaryOperator("Percentage", "5"),
                    new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_ACTIVE),
                    new BinaryOperator("TaxTypeId", VATTaxType)
                    );

                //Get default Tax
                Tax defaultTax = session.FindObject <Tax>(defaultTaxCriteria);

                if (defaultTax == null)
                {
                    throw new Exception("Could not found default tax");
                }

                foreach (var item in itemList)
                {
                    int countExistDefaultTax =
                        item.ItemTaxes.Count(r =>
                                             (r.TaxId != null &&
                                              r.TaxId.TaxTypeId == VATTaxType) &&
                                             r.RowStatus == Utility.Constant.ROWSTATUS_ACTIVE);

                    if (countExistDefaultTax != 0)
                    {
                        continue;
                    }

                    NAS.DAL.Nomenclature.Item.ItemTax itemTax = new NAS.DAL.Nomenclature.Item.ItemTax(session)
                    {
                        ItemId    = item,
                        RowStatus = Utility.Constant.ROWSTATUS_ACTIVE,
                        TaxId     = defaultTax
                    };

                    itemTax.Save();
                }
            }
        }
Esempio n. 3
0
        private bool checkIsDupplicateTax()
        {
            Session session = XpoHelper.GetNewSession();

            if (TaxId != null && ItemId != null)
            {
                CriteriaOperator criteria = CriteriaOperator.And(
                    new BinaryOperator("TaxId!Key", TaxId.TaxId),
                    new BinaryOperator("ItemId!Key", ItemId.ItemId));
                ItemTax obj = session.FindObject <ItemTax>(criteria);
                if (obj != null)
                {
                    return(true);
                }
            }

            return(false);
        }