private void LoadItems() { CreditMemoItems clsCreditMemoItems = new CreditMemoItems(); lstItem.DataSource = clsCreditMemoItems.ListAsDataTable(Convert.ToInt64(lblCreditMemoID.Text)).DefaultView; lstItem.DataBind(); clsCreditMemoItems.CommitAndDispose(); }
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) { CreditMemoItems clsCreditMemoItems = new CreditMemoItems(); clsCreditMemoItems.Delete(stIDs.Substring(0, stIDs.Length - 1)); CreditMemos clsCreditMemos = new CreditMemos(clsCreditMemoItems.Connection, clsCreditMemoItems.Transaction); clsCreditMemos.SynchronizeAmount(Convert.ToInt64(lblCreditMemoID.Text)); CreditMemoDetails clsCreditMemoDetails = clsCreditMemos.Details(Convert.ToInt64(lblCreditMemoID.Text)); clsCreditMemoItems.CommitAndDispose(); UpdateFooter(clsCreditMemoDetails); } return boRetValue; }
private void UpdateItem() { if (isChkListSingle() == true) { string stID = GetFirstID(); if (stID != null) { CreditMemoItems clsCreditMemoItems = new CreditMemoItems(); CreditMemoItemDetails clsCreditMemoItemDetails = clsCreditMemoItems.Details(Convert.ToInt64(stID)); clsCreditMemoItems.CommitAndDispose(); cboProductCode.Items.Clear(); cboVariation.Items.Clear(); cboProductUnit.Items.Clear(); cboProductCode.Items.Add(new ListItem(clsCreditMemoItemDetails.ProductCode, clsCreditMemoItemDetails.ProductID.ToString())); cboProductCode.SelectedIndex = 0; if (clsCreditMemoItemDetails.VariationMatrixID == 0) { cboVariation.Items.Add(new ListItem("No Variation", "0")); } else { cboVariation.Items.Add(new ListItem(clsCreditMemoItemDetails.MatrixDescription, clsCreditMemoItemDetails.VariationMatrixID.ToString())); } cboVariation.SelectedIndex = 0; cboProductUnit.Items.Add(new ListItem(clsCreditMemoItemDetails.ProductUnitCode, clsCreditMemoItemDetails.ProductUnitID.ToString())); cboProductUnit.SelectedIndex = 0; txtQuantity.Text = clsCreditMemoItemDetails.Quantity.ToString("###0.#0"); txtPrice.Text = clsCreditMemoItemDetails.UnitCost.ToString("###0.#0"); txtDiscount.Text = clsCreditMemoItemDetails.Discount.ToString("###0.#0"); if (clsCreditMemoItemDetails.DiscountType == DiscountTypes.Percentage) chkInPercent.Checked = true; else { chkInPercent.Checked = false; } txtAmount.Text = clsCreditMemoItemDetails.Amount.ToString("###0.#0"); txtRemarks.Text = clsCreditMemoItemDetails.Remarks; lblCreditMemoItemID.Text = stID; chkIsTaxable.Checked = clsCreditMemoItemDetails.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); } }
private void SaveRecord() { CreditMemoItemDetails clsDetails = new CreditMemoItemDetails(); 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; CreditMemoItems clsCreditMemoItems = new CreditMemoItems(); if (lblCreditMemoItemID.Text != "0") { clsDetails.CreditMemoItemID = Convert.ToInt64(lblCreditMemoItemID.Text); clsCreditMemoItems.Update(clsDetails); } else clsCreditMemoItems.Insert(clsDetails); CreditMemos clsCreditMemos = new CreditMemos(clsCreditMemoItems.Connection, clsCreditMemoItems.Transaction); CreditMemoDetails clsCreditMemoDetails = clsCreditMemos.Details(clsDetails.CreditMemoID); clsCreditMemoItems.CommitAndDispose(); UpdateFooter(clsCreditMemoDetails); }