Ejemplo n.º 1
0
        private void SetDataSource(ReportDocument Report)
        {
            Int64 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();

            POReturns clsPOReturns = new POReturns();

            System.Data.DataTable dt = clsPOReturns.ListAsDataTable(DebitMemoID: iID);

            POReturnItems clsPOReturnItems = new POReturnItems(clsPOReturns.Connection, clsPOReturns.Transaction);

            System.Data.DataTable dtitems = clsPOReturnItems.ListAsDataTable(iID);

            clsPOReturns.CommitAndDispose();

            foreach (System.Data.DataRow dr in dt.Rows)
            {
                DataRow drNew = rptds.POReturns.NewRow();

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

                rptds.POReturns.Rows.Add(drNew);
            }

            foreach (System.Data.DataRow dr in dtitems.Rows)
            {
                DataRow drNew = rptds.POReturnItems.NewRow();

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

                rptds.POReturnItems.Rows.Add(drNew);
            }

            Report.SetDataSource(rptds);
            SetParameters(Report);
        }
Ejemplo n.º 2
0
        protected void chkIncludeIneSales_CheckedChanged(Object sender, EventArgs e)
        {
            CheckBox     chkIncludeIneSales = (CheckBox)sender;
            DataListItem item = (DataListItem)chkIncludeIneSales.NamingContainer;

            HtmlInputCheckBox chkList      = (HtmlInputCheckBox)item.FindControl("chkList");
            Int64             iDebitMemoID = Int64.Parse(chkList.Value);

            POReturns clsPOReturns = new POReturns();

            clsPOReturns.UpdateIncludeIneSales(iDebitMemoID, chkIncludeIneSales.Checked);
            clsPOReturns.CommitAndDispose();
        }
Ejemplo n.º 3
0
        private void CancelPOReturn()
        {
            long   DebitMemoID = Convert.ToInt64(lblDebitMemoID.Text);
            string Remarks     = txtRemarks.Text;

            POReturns clsPOReturns = new POReturns();

            clsPOReturns.Cancel(DebitMemoID, DateTime.Now, Remarks, Convert.ToInt64(Session["UID"].ToString()));
            clsPOReturns.CommitAndDispose();

            Common Common = new Common();

            Response.Redirect("Default.aspx?task=" + Common.Encrypt("list", Session.SessionID));
        }
Ejemplo n.º 4
0
        private void LoadRecord()
        {
            Common          Common       = new Common();
            Int64           iID          = Convert.ToInt64(Common.Decrypt(Request.QueryString["retid"], Session.SessionID));
            POReturns       clsPOReturns = new POReturns();
            POReturnDetails clsDetails   = clsPOReturns.Details(iID);

            clsPOReturns.CommitAndDispose();

            lblDebitMemoID.Text        = clsDetails.DebitMemoID.ToString();
            lblReturnNo.Text           = clsDetails.MemoNo;
            lblReturnDate.Text         = clsDetails.MemoDate.ToString("yyyy-MM-dd HH:mm:ss");
            lblRequiredReturnDate.Text = clsDetails.RequiredPostingDate.ToString("yyyy-MM-dd");
            lblSupplierID.Text         = clsDetails.SupplierID.ToString();

            lblSupplierCode.Text = clsDetails.SupplierCode.ToString();
            string stParam = "?task=" + Common.Encrypt("details", Session.SessionID) + "&id=" + Common.Encrypt(clsDetails.SupplierID.ToString(), Session.SessionID);

            lblSupplierCode.NavigateUrl = Constants.ROOT_DIRECTORY + "/PurchasesAndPayables/_Vendor/Default.aspx" + stParam;

            lblSupplierContact.Text     = clsDetails.SupplierContact;
            lblSupplierTelephoneNo.Text = clsDetails.SupplierTelephoneNo;
            lblTerms.Text = clsDetails.SupplierTerms.ToString("##0");
            switch (clsDetails.SupplierModeOfTerms)
            {
            case 0:
                lblModeOfterms.Text = "Days";
                break;

            case 1:
                lblModeOfterms.Text = "Months";
                break;

            case 2:
                lblModeOfterms.Text = "Years";
                break;
            }
            lblSupplierAddress.Text = clsDetails.SupplierAddress;
            lblBranchID.Text        = clsDetails.BranchID.ToString();
            lblBranchCode.Text      = clsDetails.BranchCode;
            lblBranchAddress.Text   = clsDetails.BranchAddress;
            lblReturnRemarks.Text   = clsDetails.Remarks;

            UpdateFooter(clsDetails);
        }
Ejemplo n.º 5
0
        private long SaveRecord()
        {
            POReturns clsPOReturns = new POReturns();

            clsPOReturns.GetConnection();
            lblReturnNo.Text = Constants.PURCHASE_RETURN_CODE + CompanyDetails.BECompanyCode + DateTime.Now.Year.ToString() + clsPOReturns.LastTransactionNo();

            POReturnDetails clsDetails = new POReturnDetails();

            clsDetails.MemoNo              = lblReturnNo.Text;
            clsDetails.MemoDate            = Convert.ToDateTime(lblReturnDate.Text);
            clsDetails.SupplierID          = Convert.ToInt64(cboSupplier.SelectedItem.Value);
            clsDetails.SupplierCode        = cboSupplier.SelectedItem.Text;
            clsDetails.SupplierContact     = txtSupplierContact.Text;
            clsDetails.SupplierAddress     = txtSupplierAddress.Text;
            clsDetails.SupplierTelephoneNo = txtSupplierTelephoneNo.Text;
            clsDetails.SupplierTerms       = Convert.ToInt32(lblTerms.Text);
            switch (lblModeOfterms.Text)
            {
            case "Days":
                clsDetails.SupplierModeOfTerms = 0;
                break;

            case "Months":
                clsDetails.SupplierModeOfTerms = 1;
                break;

            case "Years":
                clsDetails.SupplierModeOfTerms = 2;
                break;
            }
            clsDetails.RequiredPostingDate = Convert.ToDateTime(txtRequiredReturnDate.Text);
            clsDetails.BranchID            = Convert.ToInt16(cboBranch.SelectedItem.Value);
            clsDetails.PurchaserID         = Convert.ToInt64(Session["UID"].ToString());
            clsDetails.PurchaserName       = Session["Name"].ToString();
            clsDetails.ReturnStatus        = POReturnStatus.Open;
            clsDetails.Remarks             = txtRemarks.Text;

            long id = clsPOReturns.Insert(clsDetails);

            clsPOReturns.CommitAndDispose();

            return(id);
        }
Ejemplo n.º 6
0
        protected void chkIncludeIneSalesAll_CheckedChanged(Object sender, EventArgs e)
        {
            HtmlInputCheckBox chkList = null;
            CheckBox          chkIncludeIneSalesAll = (CheckBox)sender;
            CheckBox          chkIncludeIneSales    = null;
            Int64             iDebitMemoID          = 0;

            POReturns clsPOReturns = new POReturns();

            foreach (DataListItem item in lstItem.Items)
            {
                chkList = (HtmlInputCheckBox)item.FindControl("chkList");

                iDebitMemoID = Int64.Parse(chkList.Value);

                chkIncludeIneSales = (CheckBox)item.FindControl("chkIncludeIneSales");

                clsPOReturns.UpdateIncludeIneSales(iDebitMemoID, chkIncludeIneSalesAll.Checked);
                chkIncludeIneSales.Checked = chkIncludeIneSalesAll.Checked;
            }
            clsPOReturns.CommitAndDispose();
        }
Ejemplo n.º 7
0
        private void SaveRecord()
        {
            POReturnDetails clsDetails = new POReturnDetails();

            clsDetails.DebitMemoID         = Convert.ToInt64(lblDebitMemoID.Text);
            clsDetails.MemoNo              = lnkReturnNo.Text;
            clsDetails.MemoDate            = Convert.ToDateTime(lblReturnDate.Text);
            clsDetails.SupplierID          = Convert.ToInt64(cboSupplier.SelectedItem.Value);
            clsDetails.SupplierCode        = cboSupplier.SelectedItem.Text;
            clsDetails.SupplierContact     = txtSupplierContact.Text;
            clsDetails.SupplierAddress     = txtSupplierAddress.Text;
            clsDetails.SupplierTelephoneNo = txtSupplierTelephoneNo.Text;
            switch (lblModeOfterms.Text)
            {
            case "Days":
                clsDetails.SupplierModeOfTerms = 0;
                break;

            case "Months":
                clsDetails.SupplierModeOfTerms = 1;
                break;

            case "Years":
                clsDetails.SupplierModeOfTerms = 2;
                break;
            }
            clsDetails.RequiredPostingDate = Convert.ToDateTime(txtRequiredReturnDate.Text);
            clsDetails.BranchID            = Convert.ToInt16(cboBranch.SelectedItem.Value);
            clsDetails.PurchaserID         = Convert.ToInt64(Session["UID"].ToString());
            clsDetails.PurchaserName       = Session["Name"].ToString();
            clsDetails.ReturnStatus        = POReturnStatus.Open;
            clsDetails.Remarks             = txtRemarks.Text;

            POReturns clsPOReturns = new POReturns();

            clsPOReturns.Update(clsDetails);
            clsPOReturns.CommitAndDispose();
        }
Ejemplo n.º 8
0
        private void LoadRecord()
        {
            Common          Common       = new Common();
            Int64           iID          = Convert.ToInt64(Common.Decrypt(Request.QueryString["retid"], Session.SessionID));
            POReturns       clsPOReturns = new POReturns();
            POReturnDetails clsDetails   = clsPOReturns.Details(iID);

            clsPOReturns.CommitAndDispose();

            lblDebitMemoID.Text     = clsDetails.DebitMemoID.ToString();
            lnkReturnNo.Text        = clsDetails.MemoNo;
            lnkReturnNo.NavigateUrl = "Default.aspx?task=" + Common.Encrypt("details", Session.SessionID) + "&retid=" + Common.Encrypt(clsDetails.DebitMemoID.ToString(), Session.SessionID);

            lblReturnDate.Text          = clsDetails.MemoDate.ToString("yyyy-MM-dd HH:mm:ss");
            txtRequiredReturnDate.Text  = clsDetails.RequiredPostingDate.ToString("yyyy-MM-dd");
            cboSupplier.SelectedIndex   = cboSupplier.Items.IndexOf(cboSupplier.Items.FindByValue(clsDetails.SupplierID.ToString()));
            txtSupplierContact.Text     = clsDetails.SupplierContact;
            txtSupplierTelephoneNo.Text = clsDetails.SupplierTelephoneNo;
            lblTerms.Text = clsDetails.SupplierTerms.ToString("##0");
            switch (clsDetails.SupplierModeOfTerms)
            {
            case 0:
                lblModeOfterms.Text = "Days";
                break;

            case 1:
                lblModeOfterms.Text = "Months";
                break;

            case 2:
                lblModeOfterms.Text = "Years";
                break;
            }
            txtSupplierAddress.Text = clsDetails.SupplierAddress;
            cboBranch.SelectedIndex = cboBranch.Items.IndexOf(cboBranch.Items.FindByValue(clsDetails.BranchID.ToString()));
            txtBranchAddress.Text   = clsDetails.BranchAddress;
            txtRemarks.Text         = clsDetails.Remarks;
        }
Ejemplo n.º 9
0
        private void LoadList()
        {
            POReturns clsPOReturns = new POReturns();
            DataClass clsDataClass = new DataClass();
            Common    Common       = new Common();

            string SortField = "DebitMemoID";

            if (Request.QueryString["sortfield"] != null)
            {
                SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID);
            }

            SortOption sortoption = SortOption.Ascending;

            if (Request.QueryString["sortoption"] != null)
            {
                sortoption = (SortOption)Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true);
            }

            DateTime dteOrderStartDate = DateTime.MinValue;

            try { if (txtOrderStartDate.Text != string.Empty)
                  {
                      dteOrderStartDate = Convert.ToDateTime(txtOrderStartDate.Text + " " + txtOrderStartTime.Text);
                  }
            }
            catch { }

            DateTime dteOrderEndDate = DateTime.MinValue;

            try { if (txtOrderEndDate.Text != string.Empty)
                  {
                      dteOrderEndDate = Convert.ToDateTime(txtOrderEndDate.Text + " " + txtOrderEndTime.Text);
                  }
            }
            catch { }

            DateTime dtePostingStartDate = DateTime.MinValue;

            try { if (txtPostingStartDate.Text != string.Empty)
                  {
                      dtePostingStartDate = Convert.ToDateTime(txtPostingStartDate.Text + " " + txtPostingStartTime.Text);
                  }
            }
            catch { }

            DateTime dtePostingEndDate = DateTime.MinValue;

            try { if (txtPostingEndDate.Text != string.Empty)
                  {
                      dtePostingEndDate = Convert.ToDateTime(txtPostingEndDate.Text + " " + txtPostingEndTime.Text);
                  }
            }
            catch { }

            eSalesFilter clseSalesFilter = new eSalesFilter();

            clseSalesFilter.FilterIncludeIneSales = true;
            clseSalesFilter.IncludeIneSales       = true;

            string         SearchKey = txtSearch.Text;
            POReturnStatus status    = (POReturnStatus)Enum.Parse(typeof(POReturnStatus), cboStatus.SelectedItem.Value);

            PageData.DataSource = clsPOReturns.SearchAsDataTable(status, dteOrderStartDate, dteOrderEndDate, dtePostingStartDate, dtePostingEndDate, SearchKey, SortField, sortoption, 0, clseSalesFilter).DefaultView;

            clsPOReturns.CommitAndDispose();

            int iPageSize = Convert.ToInt16(Session["PageSize"]);

            PageData.AllowPaging = true;
            PageData.PageSize    = iPageSize;
            try
            {
                PageData.CurrentPageIndex = Convert.ToInt16(cboCurrentPage.SelectedItem.Value) - 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }
            catch
            {
                PageData.CurrentPageIndex = 1;
                lstItem.DataSource        = PageData;
                lstItem.DataBind();
            }

            cboCurrentPage.Items.Clear();
            for (int i = 0; i < PageData.PageCount; i++)
            {
                int iValue = i + 1;
                cboCurrentPage.Items.Add(new ListItem(iValue.ToString(), iValue.ToString()));
                if (PageData.CurrentPageIndex == i)
                {
                    cboCurrentPage.Items[i].Selected = true;
                }
                else
                {
                    cboCurrentPage.Items[i].Selected = false;
                }
            }
            lblDataCount.Text = " of " + " " + PageData.PageCount;
        }
Ejemplo n.º 10
0
        public long Insert(POReturnItemDetails Details)
        {
            try
            {
                string SQL = "INSERT INTO tblPODebitMemoItems (" +
                             "DebitMemoID, " +
                             "ProductID, " +
                             "ProductCode, " +
                             "BarCode, " +
                             "Description, " +
                             "ProductUnitID, " +
                             "ProductUnitCode, " +
                             "Quantity, " +
                             "UnitCost, " +
                             "Discount, " +
                             "DiscountApplied, " +
                             "DiscountType, " +
                             "Amount, " +
                             "VAT, " +
                             "VatableAmount, " +
                             "EVAT, " +
                             "EVatableAmount, " +
                             "LocalTax, " +
                             "isVATInclusive, " +
                             "VariationMatrixID, " +
                             "MatrixDescription, " +
                             "ProductGroup, " +
                             "ProductSubGroup, " +
                             "ItemStatus, " +
                             "IsVatable, " +
                             "Remarks, " +
                             "ChartOfAccountIDPurchase, " +
                             "ChartOfAccountIDTaxPurchase, " +
                             "ChartOfAccountIDInventory" +
                             ") VALUES (" +
                             "@DebitMemoID, " +
                             "@ProductID, " +
                             "@ProductCode, " +
                             "@BarCode, " +
                             "@Description, " +
                             "@ProductUnitID, " +
                             "@ProductUnitCode, " +
                             "@Quantity, " +
                             "@UnitCost, " +
                             "@Discount, " +
                             "@DiscountApplied, " +
                             "@DiscountType, " +
                             "@Amount, " +
                             "@VAT, " +
                             "@VatableAmount, " +
                             "@EVAT, " +
                             "@EVatableAmount, " +
                             "@LocalTax, " +
                             "@isVATInclusive, " +
                             "@VariationMatrixID, " +
                             "@MatrixDescription, " +
                             "@ProductGroup, " +
                             "@ProductSubGroup, " +
                             "@ItemStatus, " +
                             "@IsVatable, " +
                             "@Remarks, " +
                             "(SELECT ChartOfAccountIDPurchase FROM tblProducts WHERE ProductID = @ProductID), " +
                             "(SELECT ChartOfAccountIDTaxPurchase FROM tblProducts WHERE ProductID = @ProductID), " +
                             "(SELECT ChartOfAccountIDInventory FROM tblProducts WHERE ProductID = @ProductID) " +
                             ");";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                MySqlParameter prmReturnID = new MySqlParameter("@DebitMemoID", MySqlDbType.Int64);
                prmReturnID.Value = Details.DebitMemoID;
                cmd.Parameters.Add(prmReturnID);

                MySqlParameter prmProductID = new MySqlParameter("@ProductID", MySqlDbType.Int64);
                prmProductID.Value = Details.ProductID;
                cmd.Parameters.Add(prmProductID);

                MySqlParameter prmProductCode = new MySqlParameter("@ProductCode", MySqlDbType.String);
                prmProductCode.Value = Details.ProductCode;
                cmd.Parameters.Add(prmProductCode);

                MySqlParameter prmBarCode = new MySqlParameter("@BarCode", MySqlDbType.String);
                prmBarCode.Value = Details.BarCode;
                cmd.Parameters.Add(prmBarCode);

                MySqlParameter prmDescription = new MySqlParameter("@Description", MySqlDbType.String);
                prmDescription.Value = Details.Description;
                cmd.Parameters.Add(prmDescription);

                MySqlParameter prmProductUnitID = new MySqlParameter("@ProductUnitID", MySqlDbType.Int16);
                prmProductUnitID.Value = Details.ProductUnitID;
                cmd.Parameters.Add(prmProductUnitID);

                MySqlParameter prmProductUnitCode = new MySqlParameter("@ProductUnitCode", MySqlDbType.String);
                prmProductUnitCode.Value = Details.ProductUnitCode;
                cmd.Parameters.Add(prmProductUnitCode);

                MySqlParameter prmQuantity = new MySqlParameter("@Quantity", MySqlDbType.Decimal);
                prmQuantity.Value = Details.Quantity;
                cmd.Parameters.Add(prmQuantity);

                MySqlParameter prmUnitCost = new MySqlParameter("@UnitCost", MySqlDbType.Decimal);
                prmUnitCost.Value = Details.UnitCost;
                cmd.Parameters.Add(prmUnitCost);

                MySqlParameter prmDiscount = new MySqlParameter("@Discount", MySqlDbType.Decimal);
                prmDiscount.Value = Details.Discount;
                cmd.Parameters.Add(prmDiscount);

                MySqlParameter prmDiscountApplied = new MySqlParameter("@DiscountApplied", MySqlDbType.Decimal);
                prmDiscountApplied.Value = Details.DiscountApplied;
                cmd.Parameters.Add(prmDiscountApplied);

                MySqlParameter prmDiscountType = new MySqlParameter("@DiscountType", MySqlDbType.Int16);
                prmDiscountType.Value = (int)Details.DiscountType;
                cmd.Parameters.Add(prmDiscountType);

                MySqlParameter prmAmount = new MySqlParameter("@Amount", MySqlDbType.Decimal);
                prmAmount.Value = Details.Amount;
                cmd.Parameters.Add(prmAmount);

                MySqlParameter prmVAT = new MySqlParameter("@VAT", MySqlDbType.Decimal);
                prmVAT.Value = Details.VAT;
                cmd.Parameters.Add(prmVAT);

                MySqlParameter prmVatableAmount = new MySqlParameter("@VatableAmount", MySqlDbType.Decimal);
                prmVatableAmount.Value = Details.VatableAmount;
                cmd.Parameters.Add(prmVatableAmount);

                MySqlParameter prmEVAT = new MySqlParameter("@EVAT", MySqlDbType.Decimal);
                prmEVAT.Value = Details.EVAT;
                cmd.Parameters.Add(prmEVAT);

                MySqlParameter prmEVatableAmount = new MySqlParameter("@EVatableAmount", MySqlDbType.Decimal);
                prmEVatableAmount.Value = Details.EVatableAmount;
                cmd.Parameters.Add(prmEVatableAmount);

                MySqlParameter prmLocalTax = new MySqlParameter("@LocalTax", MySqlDbType.Decimal);
                prmLocalTax.Value = Details.LocalTax;
                cmd.Parameters.Add(prmLocalTax);

                MySqlParameter prmisVATInclusive = new MySqlParameter("@isVATInclusive", MySqlDbType.Int16);
                prmisVATInclusive.Value = Convert.ToInt16(Details.isVATInclusive);
                cmd.Parameters.Add(prmisVATInclusive);

                MySqlParameter prmVariationMatrixID = new MySqlParameter("@VariationMatrixID", MySqlDbType.Int64);
                prmVariationMatrixID.Value = Details.VariationMatrixID;
                cmd.Parameters.Add(prmVariationMatrixID);

                MySqlParameter prmMatrixDescription = new MySqlParameter("@MatrixDescription", MySqlDbType.String);
                prmMatrixDescription.Value = Details.MatrixDescription;
                cmd.Parameters.Add(prmMatrixDescription);

                MySqlParameter prmProductGroup = new MySqlParameter("@ProductGroup", MySqlDbType.String);
                prmProductGroup.Value = Details.ProductGroup;
                cmd.Parameters.Add(prmProductGroup);

                MySqlParameter prmProductSubGroup = new MySqlParameter("@ProductSubGroup", MySqlDbType.String);
                prmProductSubGroup.Value = Details.ProductSubGroup;
                cmd.Parameters.Add(prmProductSubGroup);

                MySqlParameter prmPOReturnItemStatus = new MySqlParameter("@ItemStatus", MySqlDbType.Int16);
                prmPOReturnItemStatus.Value = Details.ItemStatus.ToString("d");
                cmd.Parameters.Add(prmPOReturnItemStatus);

                MySqlParameter prmIsVatable = new MySqlParameter("@IsVatable", MySqlDbType.Int16);
                prmIsVatable.Value = Convert.ToInt16(Details.IsVatable);
                cmd.Parameters.Add(prmIsVatable);

                MySqlParameter prmRemarks = new MySqlParameter("@Remarks", MySqlDbType.String);
                prmRemarks.Value = Details.Remarks;
                cmd.Parameters.Add(prmRemarks);

                base.ExecuteNonQuery(cmd);

                SQL = "SELECT LAST_INSERT_ID();";

                cmd.Parameters.Clear();
                cmd.CommandText = SQL;

                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);

                Int64 iID = 0;

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    iID = Int64.Parse(dr[0].ToString());
                }

                POReturns clsPOReturns = new POReturns(base.Connection, base.Transaction);
                clsPOReturns.SynchronizeAmount(Details.DebitMemoID);

                return(iID);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Ejemplo n.º 11
0
        public void Update(POReturnItemDetails Details)
        {
            try
            {
                string SQL = "UPDATE tblPODebitMemoItems SET " +
                             "DebitMemoID					=	@DebitMemoID, "+
                             "ProductID				=	@ProductID, "+
                             "ProductCode			=	@ProductCode, "+
                             "BarCode				=	@BarCode, "+
                             "Description			=	@Description, "+
                             "ProductUnitID			=	@ProductUnitID, "+
                             "ProductUnitCode		=	@ProductUnitCode, "+
                             "Quantity				=	@Quantity, "+
                             "UnitCost				=	@UnitCost, "+
                             "Discount				=	@Discount, "+
                             "DiscountApplied		=	@DiscountApplied, "+
                             "DiscountType			=	@DiscountType, "+
                             "Amount					=	@Amount, "+
                             "VAT					=	@VAT, "+
                             "VatableAmount			=	@VatableAmount, "+
                             "EVAT					=	@EVAT, "+
                             "EVatableAmount			=	@EVatableAmount, "+
                             "LocalTax				=	@LocalTax, "+
                             "isVATInclusive			=	@isVATInclusive, "+
                             "VariationMatrixID		=	@VariationMatrixID, "+
                             "MatrixDescription		=	@MatrixDescription, "+
                             "ProductGroup			=	@ProductGroup, "+
                             "ProductSubGroup		=	@ProductSubGroup, "+
                             "ItemStatus			    =	@ItemStatus, "+
                             "IsVatable				=	@IsVatable, "+
                             "Remarks				=	@Remarks, "+
                             "ChartOfAccountIDPurchase       = (SELECT ChartOfAccountIDPurchase FROM tblProducts WHERE ProductID = @ProductID), " +
                             "ChartOfAccountIDTaxPurchase    = (SELECT ChartOfAccountIDTaxPurchase FROM tblProducts WHERE ProductID = @ProductID), " +
                             "ChartOfAccountIDInventory      = (SELECT ChartOfAccountIDInventory FROM tblProducts WHERE ProductID = @ProductID) " +
                             "WHERE DebitMemoItemID = @DebitMemoItemID;";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                MySqlParameter prmReturnID = new MySqlParameter("@DebitMemoID", MySqlDbType.Int64);
                prmReturnID.Value = Details.DebitMemoID;
                cmd.Parameters.Add(prmReturnID);

                MySqlParameter prmProductID = new MySqlParameter("@ProductID", MySqlDbType.Int64);
                prmProductID.Value = Details.ProductID;
                cmd.Parameters.Add(prmProductID);

                MySqlParameter prmProductCode = new MySqlParameter("@ProductCode", MySqlDbType.String);
                prmProductCode.Value = Details.ProductCode;
                cmd.Parameters.Add(prmProductCode);

                MySqlParameter prmBarCode = new MySqlParameter("@BarCode", MySqlDbType.String);
                prmBarCode.Value = Details.BarCode;
                cmd.Parameters.Add(prmBarCode);

                MySqlParameter prmDescription = new MySqlParameter("@Description", MySqlDbType.String);
                prmDescription.Value = Details.Description;
                cmd.Parameters.Add(prmDescription);

                MySqlParameter prmProductUnitID = new MySqlParameter("@ProductUnitID", MySqlDbType.Int16);
                prmProductUnitID.Value = Details.ProductUnitID;
                cmd.Parameters.Add(prmProductUnitID);

                MySqlParameter prmProductUnitCode = new MySqlParameter("@ProductUnitCode", MySqlDbType.String);
                prmProductUnitCode.Value = Details.ProductUnitCode;
                cmd.Parameters.Add(prmProductUnitCode);

                MySqlParameter prmQuantity = new MySqlParameter("@Quantity", MySqlDbType.Decimal);
                prmQuantity.Value = Details.Quantity;
                cmd.Parameters.Add(prmQuantity);

                MySqlParameter prmUnitCost = new MySqlParameter("@UnitCost", MySqlDbType.Decimal);
                prmUnitCost.Value = Details.UnitCost;
                cmd.Parameters.Add(prmUnitCost);

                MySqlParameter prmDiscount = new MySqlParameter("@Discount", MySqlDbType.Decimal);
                prmDiscount.Value = Details.Discount;
                cmd.Parameters.Add(prmDiscount);

                MySqlParameter prmDiscountApplied = new MySqlParameter("@DiscountApplied", MySqlDbType.Decimal);
                prmDiscountApplied.Value = Details.DiscountApplied;
                cmd.Parameters.Add(prmDiscountApplied);

                MySqlParameter prmDiscountType = new MySqlParameter("@DiscountType", MySqlDbType.Int16);
                prmDiscountType.Value = (int)Details.DiscountType;
                cmd.Parameters.Add(prmDiscountType);

                MySqlParameter prmAmount = new MySqlParameter("@Amount", MySqlDbType.Decimal);
                prmAmount.Value = Details.Amount;
                cmd.Parameters.Add(prmAmount);

                MySqlParameter prmVAT = new MySqlParameter("@VAT", MySqlDbType.Decimal);
                prmVAT.Value = Details.VAT;
                cmd.Parameters.Add(prmVAT);

                MySqlParameter prmVatableAmount = new MySqlParameter("@VatableAmount", MySqlDbType.Decimal);
                prmVatableAmount.Value = Details.VatableAmount;
                cmd.Parameters.Add(prmVatableAmount);

                MySqlParameter prmEVAT = new MySqlParameter("@EVAT", MySqlDbType.Decimal);
                prmEVAT.Value = Details.EVAT;
                cmd.Parameters.Add(prmEVAT);

                MySqlParameter prmEVatableAmount = new MySqlParameter("@EVatableAmount", MySqlDbType.Decimal);
                prmEVatableAmount.Value = Details.EVatableAmount;
                cmd.Parameters.Add(prmEVatableAmount);

                MySqlParameter prmLocalTax = new MySqlParameter("@LocalTax", MySqlDbType.Decimal);
                prmLocalTax.Value = Details.LocalTax;
                cmd.Parameters.Add(prmLocalTax);

                MySqlParameter prmisVATInclusive = new MySqlParameter("@isVATInclusive", MySqlDbType.Int16);
                prmisVATInclusive.Value = Convert.ToInt16(Details.isVATInclusive);
                cmd.Parameters.Add(prmisVATInclusive);

                MySqlParameter prmVariationMatrixID = new MySqlParameter("@VariationMatrixID", MySqlDbType.Int64);
                prmVariationMatrixID.Value = Details.VariationMatrixID;
                cmd.Parameters.Add(prmVariationMatrixID);

                MySqlParameter prmMatrixDescription = new MySqlParameter("@MatrixDescription", MySqlDbType.String);
                prmMatrixDescription.Value = Details.MatrixDescription;
                cmd.Parameters.Add(prmMatrixDescription);

                MySqlParameter prmProductGroup = new MySqlParameter("@ProductGroup", MySqlDbType.String);
                prmProductGroup.Value = Details.ProductGroup;
                cmd.Parameters.Add(prmProductGroup);

                MySqlParameter prmProductSubGroup = new MySqlParameter("@ProductSubGroup", MySqlDbType.String);
                prmProductSubGroup.Value = Details.ProductSubGroup;
                cmd.Parameters.Add(prmProductSubGroup);

                MySqlParameter prmPOReturnItemStatus = new MySqlParameter("@ItemStatus", MySqlDbType.Int16);
                prmPOReturnItemStatus.Value = Details.ItemStatus.ToString("d");
                cmd.Parameters.Add(prmPOReturnItemStatus);

                MySqlParameter prmIsVatable = new MySqlParameter("@IsVatable", MySqlDbType.Int16);
                prmIsVatable.Value = Convert.ToInt16(Details.IsVatable);
                cmd.Parameters.Add(prmIsVatable);

                MySqlParameter prmRemarks = new MySqlParameter("@Remarks", MySqlDbType.String);
                prmRemarks.Value = Details.Remarks;
                cmd.Parameters.Add(prmRemarks);

                MySqlParameter prmPOReturnItemID = new MySqlParameter("@DebitMemoItemID", MySqlDbType.Int64);
                prmPOReturnItemID.Value = Details.DebitMemoItemID;
                cmd.Parameters.Add(prmPOReturnItemID);

                base.ExecuteNonQuery(cmd);

                POReturns clsPOReturns = new POReturns(base.Connection, base.Transaction);
                clsPOReturns.SynchronizeAmount(Details.DebitMemoID);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }