示例#1
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);
            }
        }
示例#2
0
 private void LoadItems()
 {
     SOReturnItems clsSOReturnItems = new SOReturnItems();
     lstItem.DataSource = clsSOReturnItems.ListAsDataTable(Convert.ToInt64(lblCreditMemoID.Text)).DefaultView;
     lstItem.DataBind();
     clsSOReturnItems.CommitAndDispose();
 }
示例#3
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);
        }
示例#4
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;
        }
示例#5
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);
        }
示例#6
0
		public void Cancel(long CreditMemoID, DateTime CancelledDate, string Remarks, long CancelledByID)
		{
			try 
			{
				string SQL=	"UPDATE tblSOCreditMemo SET " + 
								"CancelledDate			=	@CancelledDate, " +
								"CancelledRemarks		=	@CancelledRemarks, " +
								"CancelledByID			=	@CancelledByID, " +
								"SOReturnStatus			=	@SOReturnStatus " +
							"WHERE CreditMemoID = @CreditMemoID;";
	 			
				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;
				
				MySqlParameter prmCancelledDate = new MySqlParameter("@CancelledDate",MySqlDbType.DateTime);
				prmCancelledDate.Value = CancelledDate.ToString("yyyy-MM-dd HH:mm:ss");
				cmd.Parameters.Add(prmCancelledDate);

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

				MySqlParameter prmCancelledByID = new MySqlParameter("@CancelledByID",MySqlDbType.Int64);						
				prmCancelledByID.Value = CancelledByID;
				cmd.Parameters.Add(prmCancelledByID);

				MySqlParameter prmSOReturnStatus = new MySqlParameter("@SOReturnStatus",MySqlDbType.Int16);
				prmSOReturnStatus.Value = SOReturnStatus.Cancelled.ToString("d");
				cmd.Parameters.Add(prmSOReturnStatus);

				MySqlParameter prmCreditMemoID = new MySqlParameter("@CreditMemoID",MySqlDbType.Int64);						
				prmCreditMemoID.Value = CreditMemoID;
				cmd.Parameters.Add(prmCreditMemoID);

				base.ExecuteNonQuery(cmd);

				/*******************************************
				 * Update the status of items
				 * ****************************************/
				SOReturnItems clsSOReturnItems = new SOReturnItems(base.Connection, base.Transaction);
				clsSOReturnItems.Cancel(CreditMemoID);

			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
示例#7
0
		private void AddItemToInventory(long CreditMemoID)
		{

			SOReturnDetails clsSOReturnDetails = Details(CreditMemoID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

			SOReturnItems clsSOReturnItems = new SOReturnItems(base.Connection, base.Transaction);
			ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
			Products clsProduct = new Products(base.Connection, base.Transaction);
			ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);

            Inventory clsInventory = new Inventory(base.Connection, base.Transaction);

            System.Data.DataTable dt = clsSOReturnItems.ListAsDataTable(CreditMemoID);

            foreach (System.Data.DataRow dr in dt.Rows)
			{
                long lngProductID = long.Parse(dr["ProductID"].ToString());
                int intProductUnitID = int.Parse(dr["ProductUnitID"].ToString());

                decimal decItemQuantity = decimal.Parse(dr["Quantity"].ToString());
                decimal decQuantity = clsProductUnit.GetBaseUnitValue(lngProductID, intProductUnitID, decItemQuantity);

                long lngVariationMatrixID = long.Parse(dr["VariationMatrixID"].ToString());
                string strMatrixDescription = "" + dr["MatrixDescription"].ToString();
                string strProductCode = "" + dr["ProductCode"].ToString();
                decimal decUnitCost = decimal.Parse(dr["UnitCost"].ToString());
                decimal decItemCost = decimal.Parse(dr["Amount"].ToString());
                decimal decVAT = decimal.Parse(dr["VAT"].ToString());

				/*******************************************
				 * Add from Inventory
				 * ****************************************/
				// clsProduct.AddQuantity(ProductID, Quantity);
				// if (VariationMatrixID != 0){ clsProductVariationsMatrix.AddQuantity(VariationMatrixID, Quantity); }
                // July 28, 2011: change the above codes to the following
                clsProduct.AddQuantity(clsSOReturnDetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_SALES_RETURN), DateTime.Now, clsSOReturnDetails.CNNo, clsSOReturnDetails.SellerName);

				/*******************************************
				 * Add to Inventory Analysis
				 * ****************************************/
				InventoryDetails clsInventoryDetails = new InventoryDetails();
				clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
				clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
				clsInventoryDetails.PostingDate = clsSOReturnDetails.PostingDate;
				clsInventoryDetails.ReferenceNo = clsSOReturnDetails.CNNo;
				clsInventoryDetails.ContactID = clsSOReturnDetails.CustomerID;
				clsInventoryDetails.ContactCode = clsSOReturnDetails.CustomerCode;
                clsInventoryDetails.ProductID = lngProductID;
				clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
				clsInventoryDetails.MatrixDescription = strMatrixDescription;
                clsInventoryDetails.SReturnQuantity = decQuantity;
				clsInventoryDetails.SReturnCost = decItemCost - decVAT;
				clsInventoryDetails.SReturnVAT = decItemCost;	//Purchase Return with VAT

				clsInventory.Insert(clsInventoryDetails);

			}
            //myReader.Close();

		}
示例#8
0
        private void UpdateAccounts(long CreditMemoID)
        {
            try
            {
                SOReturnDetails clsSOReturnDetails = Details(CreditMemoID);
                ChartOfAccounts clsChartOfAccount = new ChartOfAccounts(base.Connection, base.Transaction);

                // update ChartOfAccountIDARTracking as credit
                clsChartOfAccount.UpdateCredit(clsSOReturnDetails.ChartOfAccountIDARTracking, clsSOReturnDetails.SubTotal);

                // update Deposit & APContra
                clsChartOfAccount.UpdateDebit(clsSOReturnDetails.ChartOfAccountIDARContra, clsSOReturnDetails.Discount);

                // update Freight & APTracking
                clsChartOfAccount.UpdateDebit(clsSOReturnDetails.ChartOfAccountIDARTracking, clsSOReturnDetails.Freight);
                clsChartOfAccount.UpdateCredit(clsSOReturnDetails.ChartOfAccountIDARFreight, clsSOReturnDetails.Freight);

                // update Deposit & APTracking
                clsChartOfAccount.UpdateDebit(clsSOReturnDetails.ChartOfAccountIDARTracking, clsSOReturnDetails.Deposit);
                clsChartOfAccount.UpdateCredit(clsSOReturnDetails.ChartOfAccountIDARVDeposit, clsSOReturnDetails.Deposit);

                SOReturnItems clsSOReturnItems = new SOReturnItems(base.Connection, base.Transaction);
                System.Data.DataTable dt = clsSOReturnItems.ListAsDataTable(CreditMemoID);
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    int iChartOfAccountIDPurchase = Int16.Parse(dr["ChartOfAccountIDPurchase"].ToString());
                    int iChartOfAccountIDTaxPurchase = Int16.Parse(dr["ChartOfAccountIDTaxPurchase"].ToString());

                    decimal decVAT = decimal.Parse(dr["VAT"].ToString());
                    decimal decVATABLEAmount = decimal.Parse(dr["Amount"].ToString()) - decVAT;

                    // update purchase as debit
                    clsChartOfAccount.UpdateCredit(iChartOfAccountIDPurchase, decVATABLEAmount);
                    // update tax as debit
                    clsChartOfAccount.UpdateCredit(iChartOfAccountIDTaxPurchase, decVAT);

                }
                //myReader.Close();

            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
示例#9
0
		public void Post(long CreditMemoID, string CustomerDocNo, DateTime PostingDate)
		{
			try 
			{
				string SQL=	"UPDATE tblSOCreditMemo SET " + 
								"CustomerDocNo		=	@CustomerDocNo, " +
								"PostingDate		=	@PostingDate, " +
								"SOReturnStatus		=	@SOReturnStatus, " +
								"CreditMemoStatus	=	@CreditMemoStatus " +
							"WHERE CreditMemoID = @CreditMemoID;";
				  
				
	 			
				MySqlCommand cmd = new MySqlCommand();
				
				
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;
				
                cmd.Parameters.AddWithValue("@CustomerDocNo", CustomerDocNo);
                cmd.Parameters.AddWithValue("@PostingDate", PostingDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@SOReturnStatus", SOReturnStatus.Posted.ToString("d"));
                cmd.Parameters.AddWithValue("@CreditMemoStatus", CreditMemoStatus.Posted.ToString("d"));
                cmd.Parameters.AddWithValue("@CreditMemoID", CreditMemoID);

				base.ExecuteNonQuery(cmd);

				/*******************************************
				 * Update the status of items
				 * ****************************************/
				SOReturnItems clsSOReturnItems = new SOReturnItems(base.Connection, base.Transaction);
				clsSOReturnItems.Post(CreditMemoID);

				/*******************************************
				 * Update Customer Account
				 * ****************************************/
				AddItemToInventory(CreditMemoID);
			}

			catch (Exception ex)
			{
				
				
				{
					
					 
					
					
				}

				throw base.ThrowException(ex);
			}	
		}