예제 #1
0
 private void LoadItems()
 {
     SOReturnItems clsSOReturnItems = new SOReturnItems();
     lstItem.DataSource = clsSOReturnItems.ListAsDataTable(Convert.ToInt64(lblCreditMemoID.Text)).DefaultView;
     lstItem.DataBind();
     clsSOReturnItems.CommitAndDispose();
 }
예제 #2
0
        private bool DeleteItems()
        {
            bool boRetValue = false;
            string stIDs = "";

            foreach (DataListItem item in lstItem.Items)
            {
                HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList");
                if (chkList != null)
                {
                    if (chkList.Checked == true)
                    {
                        stIDs += chkList.Value + ",";
                        boRetValue = true;
                    }
                }
            }
            if (boRetValue)
            {
                SOReturnItems clsSOReturnItems = new SOReturnItems();
                clsSOReturnItems.Delete(stIDs.Substring(0, stIDs.Length - 1));

                SOReturns clsSOReturns = new SOReturns(clsSOReturnItems.Connection, clsSOReturnItems.Transaction);
                clsSOReturns.SynchronizeAmount(Convert.ToInt64(lblCreditMemoID.Text));

                SOReturnDetails clsSOReturnDetails = clsSOReturns.Details(Convert.ToInt64(lblCreditMemoID.Text));
                clsSOReturnItems.CommitAndDispose();

                UpdateFooter(clsSOReturnDetails);
            }

            return boRetValue;
        }
예제 #3
0
        private void UpdateItem()
        {
            if (isChkListSingle() == true)
            {
                string stID = GetFirstID();
                if (stID != null)
                {
                    SOReturnItems clsSOReturnItems = new SOReturnItems();
                    SOReturnItemDetails clsSOReturnItemDetails = clsSOReturnItems.Details(Convert.ToInt64(stID));
                    clsSOReturnItems.CommitAndDispose();

                    cboProductCode.Items.Clear();
                    cboVariation.Items.Clear();
                    cboProductUnit.Items.Clear();

                    cboProductCode.Items.Add(new ListItem(clsSOReturnItemDetails.ProductCode, clsSOReturnItemDetails.ProductID.ToString()));
                    cboProductCode.SelectedIndex = 0;
                    if (clsSOReturnItemDetails.VariationMatrixID == 0)
                    { cboVariation.Items.Add(new ListItem("No Variation", "0")); }
                    else
                    { cboVariation.Items.Add(new ListItem(clsSOReturnItemDetails.MatrixDescription, clsSOReturnItemDetails.VariationMatrixID.ToString())); }
                    cboVariation.SelectedIndex = 0;
                    cboProductUnit.Items.Add(new ListItem(clsSOReturnItemDetails.ProductUnitCode, clsSOReturnItemDetails.ProductUnitID.ToString()));
                    cboProductUnit.SelectedIndex = 0;
                    txtQuantity.Text = clsSOReturnItemDetails.Quantity.ToString("###0.#0");
                    txtPrice.Text = clsSOReturnItemDetails.UnitCost.ToString("###0.#0");
                    txtDiscount.Text = clsSOReturnItemDetails.Discount.ToString("###0.#0");
                    if (clsSOReturnItemDetails.DiscountType == DiscountTypes.Percentage)
                        chkInPercent.Checked = true;
                    else
                    {
                        chkInPercent.Checked = false;
                    }
                    txtAmount.Text = clsSOReturnItemDetails.Amount.ToString("###0.#0");
                    txtRemarks.Text = clsSOReturnItemDetails.Remarks;
                    lblCreditMemoItemID.Text = stID;
                    chkIsTaxable.Checked = clsSOReturnItemDetails.IsVatable;
                }
            }
            else
            {
                string stScript = "<Script>";
                stScript += "window.alert('Cannot update more than one record. Please select at least one record to update.')";
                stScript += "</Script>";
                Response.Write(stScript);
            }
        }
예제 #4
0
        private void SaveRecord()
        {
            SOReturnItemDetails clsDetails = new SOReturnItemDetails();

            Products clsProducts = new Products();
            ProductDetails clsProductDetails = clsProducts.Details1(Constants.BRANCH_ID_MAIN, Convert.ToInt64(cboProductCode.SelectedItem.Value));

            Terminal clsTerminal = new Terminal(clsProducts.Connection, clsProducts.Transaction);
            TerminalDetails clsTerminalDetails = clsTerminal.Details(Int32.Parse(Session["BranchID"].ToString()), Session["TerminalNo"].ToString());
            clsProducts.CommitAndDispose();

            clsDetails.CreditMemoID = Convert.ToInt64(lblCreditMemoID.Text);
            clsDetails.ProductID = Convert.ToInt64(cboProductCode.SelectedItem.Value);
            clsDetails.ProductCode = clsProductDetails.ProductCode;
            clsDetails.BarCode = clsProductDetails.BarCode;
            clsDetails.Description = clsProductDetails.ProductDesc;
            clsDetails.ProductUnitID = Convert.ToInt32(cboProductUnit.SelectedItem.Value);
            clsDetails.ProductUnitCode = cboProductUnit.SelectedItem.Text;
            clsDetails.Quantity = Convert.ToDecimal(txtQuantity.Text);
            clsDetails.UnitCost = Convert.ToDecimal(txtPrice.Text);
            clsDetails.Discount = getItemTotalDiscount();
            clsDetails.DiscountApplied = Convert.ToDecimal(txtDiscount.Text);
            if (clsDetails.DiscountApplied == 0)
            {
                if (chkInPercent.Checked == true)
                    clsDetails.DiscountType = DiscountTypes.Percentage;
                else
                    clsDetails.DiscountType = DiscountTypes.FixedValue;
            }
            else
            {
                clsDetails.DiscountType = DiscountTypes.NotApplicable;
            }

            clsDetails.IsVatable = chkIsTaxable.Checked;
            clsDetails.Amount = ComputeItemAmount();

            if (clsDetails.IsVatable)
            {
                clsDetails.VatableAmount = clsDetails.Amount;
                clsDetails.EVatableAmount = clsDetails.Amount;
                clsDetails.LocalTax = clsDetails.Amount;

                if (clsTerminalDetails.IsVATInclusive == false)
                {
                    if (clsDetails.VatableAmount < clsDetails.Discount) clsDetails.VatableAmount = 0;
                    if (clsDetails.EVatableAmount < clsDetails.Discount) clsDetails.EVatableAmount = 0;
                    if (clsDetails.LocalTax < clsDetails.Discount) clsDetails.LocalTax = 0;
                }
                else
                {
                    if (clsDetails.VatableAmount >= clsDetails.Discount) clsDetails.VatableAmount = (clsDetails.VatableAmount) / (1 + (clsTerminalDetails.VAT / 100)); else clsDetails.VatableAmount = 0;
                    if (clsDetails.EVatableAmount >= clsDetails.Discount) clsDetails.EVatableAmount = (clsDetails.EVatableAmount) / (1 + (clsTerminalDetails.VAT / 100)); else clsDetails.EVatableAmount = 0;
                    if (clsDetails.LocalTax >= clsDetails.Discount) clsDetails.LocalTax = (clsDetails.LocalTax) / (1 + (clsTerminalDetails.LocalTax / 100)); else clsDetails.LocalTax = 0;
                }

                clsDetails.VAT = clsDetails.VatableAmount * (clsTerminalDetails.VAT / 100);
                clsDetails.EVAT = clsDetails.EVatableAmount * (clsTerminalDetails.EVAT / 100);
                clsDetails.LocalTax = clsDetails.LocalTax * (clsTerminalDetails.LocalTax / 100);
            }
            else
            {
                clsDetails.VAT = 0;
                clsDetails.VatableAmount = 0;
                clsDetails.EVAT = 0;
                clsDetails.EVatableAmount = 0;
                clsDetails.LocalTax = 0;
            }

            clsDetails.isVATInclusive = clsTerminalDetails.IsVATInclusive;
            clsDetails.VariationMatrixID = Convert.ToInt64(cboVariation.SelectedItem.Value);
            if (clsDetails.VariationMatrixID != 0)
                clsDetails.MatrixDescription = cboVariation.SelectedItem.Text;
            clsDetails.ProductGroup = clsProductDetails.ProductGroupCode;
            clsDetails.ProductSubGroup = clsProductDetails.ProductSubGroupCode;
            clsDetails.Remarks = txtRemarks.Text;

            SOReturnItems clsSOReturnItems = new SOReturnItems();
            if (lblCreditMemoItemID.Text != "0")
            {
                clsDetails.CreditMemoItemID = Convert.ToInt64(lblCreditMemoItemID.Text);
                clsSOReturnItems.Update(clsDetails);
            }
            else
                clsSOReturnItems.Insert(clsDetails);

            SOReturns clsSOReturns = new SOReturns(clsSOReturnItems.Connection, clsSOReturnItems.Transaction);
            SOReturnDetails clsSOReturnDetails = clsSOReturns.Details(clsDetails.CreditMemoID);

            clsSOReturnItems.CommitAndDispose();

            UpdateFooter(clsSOReturnDetails);
        }