Esempio n. 1
0
		private void LoadItems()
		{
			SOReturnItems clsSOReturnItems = new SOReturnItems();
			lstItem.DataSource = clsSOReturnItems.ListAsDataTable(Convert.ToInt64(lblCreditMemoID.Text)).DefaultView;
			lstItem.DataBind();
			clsSOReturnItems.CommitAndDispose();
		}
Esempio n. 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);
        }
Esempio n. 3
0
        private void SetDataSource(ReportDocument Report)
        {
            long iID = 0;

            try
            {
                if (Request.QueryString["task"].ToString().ToLower() == "reportfromposted" && Request.QueryString["retid"].ToString() != null)
                {
                    iID = Convert.ToInt64(Request.QueryString["retid"].ToString());
                }
                else
                {
                    iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["retid"].ToString(), Session.SessionID));
                }
                lblReferrer.ToolTip = iID.ToString();
            }
            catch { iID = long.Parse(lblReferrer.ToolTip); }

            ReportDataset rptds = new ReportDataset();

            SOReturns       clsSOReturns = new SOReturns();
            MySqlDataReader myreader     = clsSOReturns.List(iID, "CreditMemoID", SortOption.Ascending);

            while (myreader.Read())
            {
                DataRow drNew = rptds.SOReturns.NewRow();

                foreach (DataColumn dc in rptds.SOReturns.Columns)
                {
                    drNew[dc] = "" + myreader[dc.ColumnName];
                }

                rptds.SOReturns.Rows.Add(drNew);
            }
            myreader.Close();


            SOReturnItems clsSOReturnItems = new SOReturnItems(clsSOReturns.Connection, clsSOReturns.Transaction);

            System.Data.DataTable dt = clsSOReturnItems.ListAsDataTable(iID);
            foreach (System.Data.DataRow dr in dt.Rows)
            {
                DataRow drNew = rptds.SOReturnItems.NewRow();

                foreach (DataColumn dc in rptds.SOReturnItems.Columns)
                {
                    drNew[dc] = "" + dr[dc.ColumnName];
                }

                rptds.SOReturnItems.Rows.Add(drNew);
            }
            clsSOReturns.CommitAndDispose();

            Report.SetDataSource(rptds);
            SetParameters(Report);
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
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);
        }