Пример #1
0
        protected void spinItemTax_Load(object sender, EventArgs e)
        {
            ASPxSpinEdit      spin  = sender as ASPxSpinEdit;
            ASPxCallbackPanel panel = spin.NamingContainer as ASPxCallbackPanel;

            //Set data when in edit mode
            if (gridviewBillItem.IsEditing && !gridviewBillItem.IsNewRowEditing && !panel.IsCallback)
            {
                var billItemId = (panel.NamingContainer
                                  as DevExpress.Web.ASPxGridView.GridViewDataItemTemplateContainer).KeyValue;
                object itemId = gridviewBillItem.GetRowValuesByKeyValue(billItemId, "ItemId!Key");
                if (itemId == DBNull.Value)
                {
                    return;
                }
                ItemBO  itemBO  = new ItemBO();
                ItemTax itemTax = itemBO.GetCurrentVATOfItem(session, (Guid)itemId);
                if (itemTax != null)
                {
                    spin.Number = (decimal)itemTax.TaxId.Percentage;
                }
                else
                {
                    spin.Number = 0;
                }
            }
        }
Пример #2
0
        protected void panelItemVAT_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            ASPxCallbackPanel panel   = sender as ASPxCallbackPanel;
            ASPxSpinEdit      spin    = panel.FindControl("spinItemTax") as ASPxSpinEdit;
            ItemBO            itemBO  = new ItemBO();
            ItemTax           itemTax = itemBO.GetCurrentVATOfItem(session, Guid.Parse(e.Parameter));

            if (itemTax != null)
            {
                spin.Number = (decimal)itemTax.TaxId.Percentage;
            }
            else
            {
                spin.Number = 0;
            }
        }
Пример #3
0
        private void DisplayInfo(Guid itemId, Guid unitId)
        {
            Item item = null;

            NAS.DAL.Nomenclature.Item.Unit unit = null;

            item = session.GetObjectByKey <Item>(itemId);
            if (item != null)
            {
                lblItemCode.Text     = item.Code;
                lblItemName.Text     = item.Name;
                lblManufacturer.Text = item.ManufacturerOrgId.Name;

                //Get ItemTax
                ItemBO  itemBO  = new ItemBO();
                ItemTax itemTax = itemBO.GetCurrentVATOfItem(session, itemId);
                if (itemTax == null)
                {
                    lblTax.Text = "N/A";
                }
                else
                {
                    lblTax.Text = String.Format("{0}%", itemTax.TaxId.Percentage);
                }
            }

            unit = session.GetObjectByKey <NAS.DAL.Nomenclature.Item.Unit>(unitId);
            if (unit != null)
            {
                lblUnit.Text = unit.Code;
                if (item == null)
                {
                    return;
                }
                //Get ItemUnit
                ItemUnit          itemUnit          = item.ItemUnits.Where(r => r.UnitId.UnitId == unit.UnitId).FirstOrDefault();
                InventoryLedgerBO inventoryLedgerBO = new InventoryLedgerBO();
                double            balance           = inventoryLedgerBO.GetItemUnitBalance(session, itemUnit.ItemUnitId);
                lblBalance.Text = String.Format("{0:N0}", balance);
                //lblConvertedBalance.Text = balance.
            }
        }
Пример #4
0
        public virtual void CreateBillItem(
            DevExpress.Xpo.Session session,
            Guid billId,
            Guid itemId,
            Guid unitId,
            double quantity,
            double price,
            double promotionInPercentage,
            string comment)
        {
            try
            {
                NAS.DAL.Invoice.Bill bill =
                    session.GetObjectByKey <NAS.DAL.Invoice.Bill>(billId);
                if (bill == null)
                {
                    throw new Exception("Could not found specific bill");
                }
                //Get ItemUnit
                Item item = session.GetObjectByKey <Item>(itemId);
                Unit unit = session.GetObjectByKey <Unit>(unitId);

                ItemUnit itemUnit = session.FindObject <ItemUnit>(
                    CriteriaOperator.And(
                        new BinaryOperator("ItemId", item),
                        new BinaryOperator("UnitId", unit),
                        CriteriaOperator.Or(
                            new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_ACTIVE),
                            new BinaryOperator("RowStatus", Utility.Constant.ROWSTATUS_DEFAULT)
                            )
                        ));
                if (itemUnit == null)
                {
                    throw new Exception("Could not found item unit");
                }

                BillItem billItem = new BillItem(session)
                {
                    BillId  = bill,
                    Comment = comment,
                    //Currency
                    ItemUnitId        = itemUnit,
                    Price             = price,
                    PromotionInNumber = promotionInPercentage != -1
                        ? (price * quantity * promotionInPercentage) / 100 : 0,
                    PromotionInPercentage = promotionInPercentage,
                    Quantity   = quantity,
                    RowStatus  = Utility.Constant.ROWSTATUS_ACTIVE,
                    TotalPrice = price * quantity
                };
                billItem.Save();

                //update SumOfItemPrice
                bill.SumOfItemPrice = bill.BillItems.Sum(r => r.TotalPrice);
                bill.Save();

                if (bill.PromotionCalculationType.Equals(Utility.Constant.CALCULATION_TYPE_ON_ITEMS))
                {
                    UpdatePromotionOnItems(session, billId);
                }

                //Insert into BillItemTax...
                //Get VAT TaxType of Item
                ItemBO  itemBO  = new ItemBO();
                ItemTax itemTax = itemBO.GetCurrentVATOfItem(session, itemId);

                if (itemTax != null)
                {
                    BillItemTax billItemTax = new BillItemTax(session)
                    {
                        BillItemId      = billItem,
                        ItemTaxId       = itemTax,
                        TaxInNumber     = itemTax.TaxId.Amount,
                        TaxInPercentage = itemTax.TaxId.Percentage
                    };
                    billItemTax.Save();
                }

                UpdateSumOfTax(session, bill);

                #region Update bill Total
                bill.Total = bill.SumOfItemPrice - bill.SumOfPromotion + bill.SumOfTax;
                bill.Save();
                #endregion Update bill Total
            }
            catch (Exception ex)
            {
                throw;
            }
        }