private void SaveRecord() { POReturnItemDetails clsDetails = new POReturnItemDetails(); 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.DebitMemoID = Convert.ToInt64(lblDebitMemoID.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; POReturnItems clsPOReturnItems = new POReturnItems(); if (lblPODebitMemoItemID.Text != "0") { clsDetails.DebitMemoItemID = Convert.ToInt64(lblPODebitMemoItemID.Text); clsPOReturnItems.Update(clsDetails); } else clsPOReturnItems.Insert(clsDetails); POReturnDetails clsPOReturnDetails = new POReturnDetails(); clsPOReturnDetails.DebitMemoID = clsDetails.DebitMemoID; clsPOReturnDetails.DiscountApplied = Convert.ToDecimal(txtPODebitMemoDiscountApplied.Text); clsPOReturnDetails.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODebitMemoDiscountType.SelectedItem.Value); clsPOReturnDetails.Discount2Applied = Convert.ToDecimal(txtPODebitMemoDiscount2Applied.Text); clsPOReturnDetails.Discount2Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODebitMemoDiscount2Type.SelectedItem.Value); clsPOReturnDetails.Discount3Applied = Convert.ToDecimal(txtPODebitMemoDiscount3Applied.Text); clsPOReturnDetails.Discount3Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODebitMemoDiscount3Type.SelectedItem.Value); POReturns clsPOReturns = new POReturns(clsPOReturnItems.Connection, clsPOReturnItems.Transaction); clsPOReturns.UpdateDiscount(clsDetails.DebitMemoID, clsPOReturnDetails.DiscountApplied, clsPOReturnDetails.DiscountType, clsPOReturnDetails.Discount2Applied, clsPOReturnDetails.Discount2Type, clsPOReturnDetails.Discount3Applied, clsPOReturnDetails.Discount3Type); clsPOReturnDetails = clsPOReturns.Details(clsDetails.DebitMemoID); clsPOReturnItems.CommitAndDispose(); UpdateFooter(clsPOReturnDetails); }
private void UpdatePODiscount() { POReturnDetails clsPOReturnDetails = new POReturnDetails(); clsPOReturnDetails.DebitMemoID = Convert.ToInt64(lblDebitMemoID.Text); clsPOReturnDetails.DiscountApplied = Convert.ToDecimal(txtPODebitMemoDiscountApplied.Text); clsPOReturnDetails.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODebitMemoDiscountType.SelectedItem.Value); clsPOReturnDetails.Discount2Applied = Convert.ToDecimal(txtPODebitMemoDiscount2Applied.Text); clsPOReturnDetails.Discount2Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODebitMemoDiscount2Type.SelectedItem.Value); clsPOReturnDetails.Discount3Applied = Convert.ToDecimal(txtPODebitMemoDiscount3Applied.Text); clsPOReturnDetails.Discount3Type = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboPODebitMemoDiscount3Type.SelectedItem.Value); POReturns clsPOReturns = new POReturns(); clsPOReturns.UpdateDiscount(clsPOReturnDetails.DebitMemoID, clsPOReturnDetails.DiscountApplied, clsPOReturnDetails.DiscountType, clsPOReturnDetails.Discount2Applied, clsPOReturnDetails.Discount2Type, clsPOReturnDetails.Discount3Applied, clsPOReturnDetails.Discount3Type); clsPOReturns.SynchronizeAmount(Convert.ToInt64(lblDebitMemoID.Text)); clsPOReturnDetails = clsPOReturns.Details(Convert.ToInt64(lblDebitMemoID.Text)); clsPOReturns.CommitAndDispose(); UpdateFooter(clsPOReturnDetails); }