Пример #1
0
        private void UpdateItem()
        {
            if (isChkListSingle() == true)
            {
                string stID = GetFirstID();
                if (stID != null)
                {
                    SOItem        clsSOItem        = new SOItem();
                    SOItemDetails clsSOItemDetails = clsSOItem.Details(Convert.ToInt64(stID));
                    clsSOItem.CommitAndDispose();

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

                    cboProductCode.Items.Add(new ListItem(clsSOItemDetails.ProductCode, clsSOItemDetails.ProductID.ToString()));
                    cboProductCode.SelectedIndex = 0;
                    if (clsSOItemDetails.VariationMatrixID == 0)
                    {
                        cboVariation.Items.Add(new ListItem("No Variation", "0"));
                    }
                    else
                    {
                        cboVariation.Items.Add(new ListItem(clsSOItemDetails.MatrixDescription, clsSOItemDetails.VariationMatrixID.ToString()));
                    }
                    cboVariation.SelectedIndex = 0;
                    cboProductUnit.Items.Add(new ListItem(clsSOItemDetails.ProductUnitCode, clsSOItemDetails.ProductUnitID.ToString()));
                    cboProductUnit.SelectedIndex = 0;
                    txtQuantity.Text             = clsSOItemDetails.Quantity.ToString("###0.#0");
                    txtPrice.Text    = clsSOItemDetails.UnitCost.ToString("###0.#0");
                    txtDiscount.Text = clsSOItemDetails.Discount.ToString("###0.#0");
                    if (clsSOItemDetails.DiscountType == DiscountTypes.Percentage)
                    {
                        chkInPercent.Checked = true;
                    }
                    else
                    {
                        chkInPercent.Checked = false;
                    }
                    txtAmount.Text       = clsSOItemDetails.Amount.ToString("###0.#0");
                    txtRemarks.Text      = clsSOItemDetails.Remarks;
                    lblSOItemID.Text     = stID;
                    chkIsTaxable.Checked = clsSOItemDetails.IsVatable;

                    //Added Jul 1, 2010 4:20PM : For selling information
                    txtSellingQuantity.Text = "1";
                    decimal decMargin = clsSOItemDetails.SellingPrice - clsSOItemDetails.UnitCost;
                    try { decMargin = decMargin / clsSOItemDetails.UnitCost; }
                    catch { decMargin = 1; }
                    decMargin      = decMargin * 100;
                    txtMargin.Text = decMargin.ToString("#,##0.##0");
                    //txtMargin.Text = decimal.Parse(Convert.ToString(((clsSOItemDetails.SellingPrice - clsSOItemDetails.UnitCost) / clsSOItemDetails.UnitCost) * 100)).ToString("###0.#0");
                    txtSellingPrice.Text = clsSOItemDetails.SellingPrice.ToString("###0.#0");
                    txtVAT.Text          = clsSOItemDetails.SellingVAT.ToString("###0.#0");
                    txtEVAT.Text         = clsSOItemDetails.SellingEVAT.ToString("###0.#0");
                    txtLocalTax.Text     = clsSOItemDetails.SellingLocalTax.ToString("###0.#0");
                }
            }
            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);
            }
        }
Пример #2
0
        private void SaveRecord()
        {
            SOItemDetails clsDetails = new SOItemDetails();

            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.SOID            = Convert.ToInt64(lblSOID.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);

                //if (!clsTerminalDetails.IsVATInclusive) clsDetails.Amount += (clsDetails.VAT + clsDetails.LocalTax);
                //if (!clsTerminalDetails.EnableEVAT) clsDetails.Amount += clsDetails.EVAT;
            }
            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;

            // Added Jul 1, 2010 4:20PM : for suggested selling information
            clsDetails.SellingPrice    = decimal.Parse(txtSellingPrice.Text);
            clsDetails.SellingVAT      = decimal.Parse(txtVAT.Text);
            clsDetails.SellingEVAT     = decimal.Parse(txtEVAT.Text);
            clsDetails.SellingLocalTax = decimal.Parse(txtLocalTax.Text);

            SOItem clsSOItem = new SOItem();

            if (lblSOItemID.Text != "0")
            {
                clsDetails.SOItemID = Convert.ToInt64(lblSOItemID.Text);
                clsSOItem.Update(clsDetails);
            }
            else
            {
                clsSOItem.Insert(clsDetails);
            }

            SODetails clsSODetails = new SODetails();

            clsSODetails.SOID            = clsDetails.SOID;
            clsSODetails.DiscountApplied = Convert.ToDecimal(txtSODiscountApplied.Text);
            clsSODetails.DiscountType    = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboSODiscountType.SelectedItem.Value);

            SO clsSO = new SO(clsSOItem.Connection, clsSOItem.Transaction);

            clsSO.UpdateDiscount(clsDetails.SOID, clsSODetails.DiscountApplied, clsSODetails.DiscountType);

            clsSODetails = clsSO.Details(clsDetails.SOID);
            clsSOItem.CommitAndDispose();

            UpdateFooter(clsSODetails);
        }