Exemplo n.º 1
0
		private void LoadList()
		{	
			string SortField = "PackageID";
			if (Request.QueryString["sortfield"]!=null)
			{	SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID);	}

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

            ProductPackage clsProductPackage = new ProductPackage();
            System.Data.DataTable dt = clsProductPackage.ListAsDataTable(Convert.ToInt64(lblProductID.Text), SortField: SortField, SortOrder: SortOrder);
			clsProductPackage.CommitAndDispose();

            PageData.DataSource = dt.DefaultView;

			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;
		}
Exemplo n.º 2
0
        protected void cboProductCode_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            int intProductBaseUnitID = 0;
            decimal decCommision = 0;
            lblProductSubGroupID.Text = "0";

            if (cboProductCode.SelectedItem.Value != Constants.ZERO_STRING)
            {
                Products clsProduct = new Products();
                try
                {
                    ProductDetails clsDetails = clsProduct.Details(Convert.ToInt64(cboProductCode.SelectedValue));
                    intProductBaseUnitID = clsDetails.BaseUnitID; decCommision = clsDetails.PercentageCommision;

                    lblProductSubGroupID.Text = clsDetails.ProductSubGroupID.ToString();
                }
                catch { }
                
                txtProductCode.ToolTip = intProductBaseUnitID.ToString();
                lblProductID.ToolTip = decCommision.ToString();
                long ProductID = Convert.ToInt64(cboProductCode.SelectedValue);

                ProductPackage clsProductPackage = new ProductPackage(clsProduct.Connection, clsProduct.Transaction);
                lstProductPackages.DataSource = clsProductPackage.ListAsDataTable(Convert.ToInt64(cboProductCode.SelectedValue)).DefaultView;
                lstProductPackages.DataBind();

                ProductPurchasePriceHistory clsProductPurchasePriceHistory = new ProductPurchasePriceHistory(clsProduct.Connection, clsProduct.Transaction);
                System.Data.DataTable dtProductPurchasePriceHistory = clsProductPurchasePriceHistory.ListAsDataTable(Convert.ToInt64(cboProductCode.SelectedValue), DateTime.Now.AddMonths(-6), "PurchasePrice", SortOption.Ascending);
                clsProduct.CommitAndDispose();

                string strPurchasePriceHistory = string.Empty;
                foreach (System.Data.DataRow dr in dtProductPurchasePriceHistory.Rows)
                {
                    DateTime dtePurchaseDate = DateTime.Parse(dr["PurchaseDate"].ToString());
                    decimal decPurchasePrice = decimal.Parse(dr["PurchasePrice"].ToString());
                    string strSupplierName = "" + dr["PurchaserName"].ToString();
                    string strPurchaserName = "" + dr["SupplierName"].ToString();

                    strPurchasePriceHistory += dtePurchaseDate.ToString("ddMMMyyyy HH:mm") + ": " + strPurchaserName.PadRight(50) + " - " + decPurchasePrice.ToString("#,##0.#0").PadLeft(10) + " " + strSupplierName + "\r\n<br />" + Environment.NewLine;
                }
                lblPurchasePriceHistory.Text = "<br /><b>PURCHASE PRICE HISTORY: </b><br /><br />" + strPurchasePriceHistory;

                lblProductPackage.Visible = true;
                lnkProductPackageAdd.Visible = true;
                lstProductPackages.Visible = true;
                imgProductHistory.Visible = true;
                imgProductPriceHistory.Visible = true;
                imgInventoryAdjustment.Visible = true;
                imgEditNow.Visible = true;
                lnkPackage.Visible = true;
                imgVariationsMatrix.Visible = true;
                imgUnitsMatrix.Visible = true;

                string stParam = "?task=" + Common.Encrypt("list", Session.SessionID) + "&prodid=" + Common.Encrypt(cboProductCode.SelectedValue, Session.SessionID);
                lnkPackage.NavigateUrl = Constants.ROOT_DIRECTORY + "/MasterFiles/_Product/_Package/Default.aspx" + stParam;

                lnkProductPackageAdd.ToolTip = "Add new package for " + cboProductCode.SelectedItem.Text;
                lnkProductPackageAdd.NavigateUrl = "_Package/Default.aspx?task=" + Common.Encrypt("add", Session.SessionID) + "&prodid=" + Common.Encrypt(cboProductCode.SelectedValue, Session.SessionID) + "&productcode=" + Common.Encrypt(cboProductCode.SelectedItem.Text, Session.SessionID);
                txtProductCode.Text = cboProductCode.SelectedItem.Text;
                lblPurchasePriceHistory.Visible = true;
            }
            else if (cboProductCode.SelectedItem.Text == Constants.ZERO_STRING)
            {
                lblProductPackage.Visible = false;
                lnkProductPackageAdd.Visible = false;
                lstProductPackages.Visible = false;
                imgProductHistory.Visible = false;
                imgProductPriceHistory.Visible = false;
                imgInventoryAdjustment.Visible = false;
                imgEditNow.Visible = false;
                lnkPackage.Visible = false;
                imgVariationsMatrix.Visible = false;
                imgUnitsMatrix.Visible = false;
                lblPurchasePriceHistory.Visible = false;
                txtProductCode.ToolTip = intProductBaseUnitID.ToString();
                lblProductID.ToolTip = decCommision.ToString(); 
            }
           
        }
Exemplo n.º 3
0
        protected void cboProductUnit_SelectedIndexChanged(object sender, EventArgs e)
        {
            ProductPackage clsProductPackage = new ProductPackage();
            ProductPackageDetails clsDetails = clsProductPackage.DetailsByProductIDAndUnitID(long.Parse(cboProductCode.SelectedValue), long.Parse(cboProductUnit.SelectedValue));
            if (clsDetails.PackageID == 0)
            {
                ProductUnit clsProductUnit = new ProductUnit(clsProductPackage.Connection, clsProductPackage.Transaction);
                Products clsProduct = new Products(clsProductPackage.Connection, clsProductPackage.Transaction);
                ProductDetails clsProductDetails = clsProduct.Details(long.Parse(cboProductCode.SelectedItem.Value));
                decimal decBaseUnitValue = clsProductUnit.GetBaseUnitValue(long.Parse(cboProductCode.SelectedItem.Value), int.Parse(cboProductUnit.SelectedItem.Value), 1);

                clsDetails.Price = decBaseUnitValue * clsProductDetails.Price;
                clsDetails.PurchasePrice = decBaseUnitValue * clsProductDetails.PurchasePrice;
            }
            clsProductPackage.CommitAndDispose();


            txtPrice.Text = clsDetails.PurchasePrice.ToString("#####0.##0");
        }
Exemplo n.º 4
0
		private void LoadItemData()
		{	
			try
			{
				DataClass clsData = new DataClass(); 
                ProductPackage clsProductPackage = new ProductPackage();
                System.Data.DataTable dt = clsData.DataReaderToDataTable(clsProductPackage.List(mDetails.ProductID, "ProductDesc", SortOption.Ascending));
                clsProductPackage.CommitAndDispose();

                lstItems.Items.Clear(); int iImgCtr = 0;
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    if (mboIsPriceInq)
                        lstItems.Items.Add(dr["PackageID"].ToString(), "[" + dr["Price"].ToString() + "]" + Environment.NewLine + dr["Quantity"].ToString() + " " + dr["UnitCode"].ToString() + " - " + dr["ProductDesc"].ToString(), iImgCtr);
                    else
                        lstItems.Items.Add(dr["PackageID"].ToString(), dr["Quantity"].ToString() + " " + dr["UnitCode"].ToString() + " - " + dr["ProductDesc"].ToString(), iImgCtr);
                    if (iImgCtr == 7) iImgCtr = 0; else iImgCtr++;
                }
                try { lstItems.Items[0].Selected = true; }
                catch { }

			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message,"RetailPlus",MessageBoxButtons.OK,MessageBoxIcon.Error); 
			}
		}
Exemplo n.º 5
0
		private void SubtractItemToInventory(long SOID)
		{

			SODetails clsSODetails = Details(SOID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

            SOItem clsSOItem = new SOItem(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);
            ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
            MatrixPackage clsMatrixPackage = new MatrixPackage(base.Connection, base.Transaction);

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

            //MatrixPackagePriceHistoryDetails clsMatrixPackagePriceHistoryDetails;
            //ProductPackagePriceHistoryDetails clsProductPackagePriceHistoryDetails;

            System.Data.DataTable dt = clsSOItem.ListAsDataTable(SOID, "SOItemID", SortOption.Ascending);
            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 in the Sales Price History
                // * ****************************************/
                //if (lngVariationMatrixID != 0)
                //{
                //    // Update MatrixPackagePriceHistory first to get the history
                //    clsMatrixPackagePriceHistoryDetails = new MatrixPackagePriceHistoryDetails();
                //    clsMatrixPackagePriceHistoryDetails.UID = clsSODetails.SellerID;
                //    clsMatrixPackagePriceHistoryDetails.PackageID = clsMatrixPackage.GetPackageID(lngVariationMatrixID, intProductUnitID);
                //    clsMatrixPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                //    clsMatrixPackagePriceHistoryDetails.Price = decUnitCost;
                //    clsMatrixPackagePriceHistoryDetails.PurchasePrice = -1; //-1 = nochange
                //    clsMatrixPackagePriceHistoryDetails.VAT = -1; //-1 = nochange
                //    clsMatrixPackagePriceHistoryDetails.EVAT = -1; //-1 = nochange
                //    clsMatrixPackagePriceHistoryDetails.LocalTax = -1; //-1 = nochange
                //    clsMatrixPackagePriceHistoryDetails.Remarks = "Based on SO #: " + clsSODetails.SONo;
                //    MatrixPackagePriceHistory clsMatrixPackagePriceHistory = new MatrixPackagePriceHistory(base.Connection, base.Transaction);
                //    clsMatrixPackagePriceHistory.Insert(clsMatrixPackagePriceHistoryDetails);
                //}
                //else
                //{
                //    // Update ProductPackagePriceHistory first to get the history
                //    clsProductPackagePriceHistoryDetails = new ProductPackagePriceHistoryDetails();
                //    clsProductPackagePriceHistoryDetails.UID = clsSODetails.SellerID;
                //    clsProductPackagePriceHistoryDetails.PackageID = clsProductPackage.GetPackageID(lngProductID, intProductUnitID);
                //    clsProductPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                //    clsProductPackagePriceHistoryDetails.Price = decUnitCost;
                //    clsProductPackagePriceHistoryDetails.PurchasePrice = -1; //-1 = nochange
                //    clsProductPackagePriceHistoryDetails.VAT = -1; //-1 = nochange
                //    clsProductPackagePriceHistoryDetails.EVAT = -1; //-1 = nochange
                //    clsProductPackagePriceHistoryDetails.LocalTax = -1; //-1 = nochange
                //    clsProductPackagePriceHistoryDetails.Remarks = "Based on SO #: " + clsSODetails.SONo;
                //    ProductPackagePriceHistory clsProductPackagePriceHistory = new ProductPackagePriceHistory(base.Connection, base.Transaction);
                //    clsProductPackagePriceHistory.Insert(clsProductPackagePriceHistoryDetails);
                //}


				/*******************************************
				 * Subtract to Inventory
				 * ****************************************/
				// clsProduct.SubtractQuantity(lngProductID, decQuantity);
				// if (lngVariationMatrixID != 0) { clsProductVariationsMatrix.SubtractQuantity(lngVariationMatrixID, decQuantity); }
				// July 28, 2011: change the above codes to the following
				clsProduct.SubtractQuantity(clsSODetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_SOLD_WHOLESALE), DateTime.Now, clsSODetails.SONo, clsSODetails.SellerName);

				/*******************************************
				 * Update Selling Information
				 * ****************************************/
                int iBaseUnitID = clsProduct.get_BaseUnitID(lngProductID);
                if (iBaseUnitID != intProductUnitID)
                {
                    clsProduct.UpdateSellingPrice(lngProductID, lngVariationMatrixID, clsSODetails.CustomerID, intProductUnitID, (decItemQuantity * decUnitCost) / decQuantity, -1, -1, -1,- 1, -1); // Price should be the sugegsted selling price
                }
                clsProduct.UpdateSellingWSPrice(lngProductID, lngVariationMatrixID, clsSODetails.CustomerID, intProductUnitID, decUnitCost); // WS Price should be the unit cost


				/*******************************************
				 * Add to Inventory Analysis
				 * ****************************************/
				clsInventoryDetails = new InventoryDetails();
				clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
				clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
				clsInventoryDetails.PostingDate = clsSODetails.DeliveryDate;
				clsInventoryDetails.ReferenceNo = clsSODetails.SONo;
				clsInventoryDetails.ContactID = clsSODetails.CustomerID;
				clsInventoryDetails.ContactCode = clsSODetails.CustomerCode;
				clsInventoryDetails.ProductID = lngProductID;
				clsInventoryDetails.ProductCode = strProductCode;
				clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
				clsInventoryDetails.MatrixDescription = strMatrixDescription;
				clsInventoryDetails.SoldQuantity = decQuantity;
				clsInventoryDetails.SoldCost = decItemCost - decVAT;
				clsInventoryDetails.SoldVAT = decItemCost;	// Sales Cost with VAT

				clsInventory.Insert(clsInventoryDetails);
			}

		}
Exemplo n.º 6
0
        private void AddItemToInventory(long pvtDebitMemoID)
        {
            DebitMemoDetails clsDebitMemoDetails = Details(pvtDebitMemoID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
            ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

            DebitMemoItems clsDebitMemoItems = new DebitMemoItems(base.Connection, base.Transaction);
            ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);

            ProductDetails clsProductDetails = new ProductDetails();
            Products clsProduct = new Products(base.Connection, base.Transaction);
            ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);
            ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
            MatrixPackage clsMatrixPackage = new MatrixPackage(base.Connection, base.Transaction);

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

            ProductPackagePriceHistoryDetails clsProductPackagePriceHistoryDetails;
            ProductPackagePriceHistory clsProductPackagePriceHistory = new ProductPackagePriceHistory(base.Connection, base.Transaction);

            System.Data.DataTable dt = clsDebitMemoItems.ListAsDataTable(pvtDebitMemoID, SortField: "DebitMemoItemID", SortOrder: SortOption.Ascending);

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

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

                long lngVariationMatrixID = Convert.ToInt64(dr["VariationMatrixID"]);
                string strMatrixDescription = dr["MatrixDescription"].ToString();
                string strProductCode = dr["ProductCode"].ToString();
                string strProductUnitCode = dr["ProductUnitCode"].ToString();
                decimal decNewUnitCost = Convert.ToDecimal(dr["UnitCost"]);
                decimal decAmount = Convert.ToDecimal(dr["Amount"]);
                //decimal decSellingPrice = Convert.ToDecimal(dr["SellingPrice"]);
                decimal decVAT = Convert.ToDecimal(dr["VAT"]);
                //decimal decEVAT = Convert.ToDecimal(dr["EVAT"]);
                //decimal decLocalTax = Convert.ToDecimal(dr["LocalTax"]); 

                clsProductDetails = clsProduct.Details1(clsDebitMemoDetails.BranchID, lngProductID);
                /*******************************************
				 * Add in the Purchase Price History based on Debit Memo
				 * ****************************************/
                // Update ProductPackagePriceHistory first to get the history
                clsProductPackagePriceHistoryDetails = new ProductPackagePriceHistoryDetails();
                clsProductPackagePriceHistoryDetails.UID = clsDebitMemoDetails.PurchaserID;
                clsProductPackagePriceHistoryDetails.PackageID = clsProductPackage.GetPackageID(lngProductID, intProductUnitID);
                clsProductPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                clsProductPackagePriceHistoryDetails.PurchasePrice = decNewUnitCost * (decItemQuantity / decQuantity);
                clsProductPackagePriceHistoryDetails.Price = -1;
                clsProductPackagePriceHistoryDetails.VAT = -1;
                clsProductPackagePriceHistoryDetails.EVAT = -1;
                clsProductPackagePriceHistoryDetails.LocalTax = -1;
                clsProductPackagePriceHistoryDetails.Remarks = "Based on DebitMemo #: " + clsDebitMemoDetails.MemoNo;
                clsProductPackagePriceHistory.Insert(clsProductPackagePriceHistoryDetails);

                /*******************************************
                 * Subtract from Inventory : Remove this since this is a Debit Memo
                 * ****************************************/
                //clsProduct.SubtractQuantity(lngProductID, decQuantity);
                //if (lngVariationMatrixID != 0)
                //{
                //    clsProductVariationsMatrix.SubtractQuantity(lngVariationMatrixID, decQuantity);
                //}

                /*******************************************
				 * Update Purchasing Information
				 * ****************************************/
                int iBaseUnitID = clsProduct.get_BaseUnitID(lngProductID);
                if (iBaseUnitID != intProductUnitID)
                {
                    clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsDebitMemoDetails.SupplierID, iBaseUnitID, (decItemQuantity * decNewUnitCost) / decQuantity);
                }
                clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsDebitMemoDetails.SupplierID, intProductUnitID, decNewUnitCost);

                /*******************************************
                 * Add to Inventory Analysis
                 * ****************************************/
                InventoryDetails clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
                clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
                clsInventoryDetails.PostingDate = clsDebitMemoDetails.PostingDate;
                clsInventoryDetails.ReferenceNo = clsDebitMemoDetails.MemoNo;
                clsInventoryDetails.ContactID = clsDebitMemoDetails.SupplierID;
                clsInventoryDetails.ContactCode = clsDebitMemoDetails.SupplierCode;
                clsInventoryDetails.ProductID = lngProductID;
                clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
                clsInventoryDetails.PDebitQuantity = decQuantity;
                clsInventoryDetails.PDebitCost = decAmount - decVAT;
                clsInventoryDetails.PDebitVAT = decAmount;

                clsInventory.Insert(clsInventoryDetails);

            }
        }
Exemplo n.º 7
0
        public void UpdateSellingPrice(long ProductID, long MatrixID, long SupplierID, int BaseUnitID, decimal SellingPrice, decimal Price1, decimal Price2, decimal Price3, decimal Price4, decimal Price5)
		{
			try 
			{
				ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
                clsProductPackage.UpdateSelling(ProductID, MatrixID, BaseUnitID, 1, SellingPrice, Price1, Price2, Price3, Price4, Price5);
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Exemplo n.º 8
0
		private void AddItemToInventory(long POID)
		{

			PODetails clsPODetails = Details(POID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
			ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

			POItem clsPOItem = new POItem(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);
            ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);

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

            ProductPackagePriceHistoryDetails clsProductPackagePriceHistoryDetails;

			//MySqlDataReader myReader = clsPOItem.List(POID, "POItemID", SortOption.Ascending);
            System.Data.DataTable dt = clsPOItem.ListAsDataTable(POID, "POItemID", SortOption.Ascending);

			//while (myReader.Read())
            foreach (System.Data.DataRow dr in dt.Rows)
			{
                long lngProductID = Convert.ToInt64(dr["ProductID"]);
                int intProductUnitID = Convert.ToInt16(dr["ProductUnitID"]);

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

                long lngVariationMatrixID = Convert.ToInt64(dr["VariationMatrixID"]);
                string strMatrixDescription = dr["MatrixDescription"].ToString();
                string strProductCode = dr["ProductCode"].ToString();
                string strProductUnitCode = dr["ProductUnitCode"].ToString();
                decimal decUnitCost = Convert.ToDecimal(dr["UnitCost"]);
                decimal decItemCost = Convert.ToDecimal(dr["Amount"]);
                decimal decSellingPrice = Convert.ToDecimal(dr["SellingPrice"]);
                decimal decVAT = Convert.ToDecimal(dr["VAT"]);
                decimal decEVAT = Convert.ToDecimal(dr["EVAT"]);
                decimal decLocalTax = Convert.ToDecimal(dr["LocalTax"]); 

                /*******************************************
				 * Add in the Price History
				 * ****************************************/
                // Update ProductPackagePriceHistory first to get the history
                clsProductPackagePriceHistoryDetails = new ProductPackagePriceHistoryDetails();
                clsProductPackagePriceHistoryDetails.UID = clsPODetails.PurchaserID;
                clsProductPackagePriceHistoryDetails.PackageID = clsProductPackage.GetPackageID(lngProductID, intProductUnitID);
                clsProductPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                clsProductPackagePriceHistoryDetails.PurchasePrice = (decItemQuantity * decUnitCost) / decQuantity;
                clsProductPackagePriceHistoryDetails.Price = decSellingPrice;
                clsProductPackagePriceHistoryDetails.VAT = decVAT;
                clsProductPackagePriceHistoryDetails.EVAT = decEVAT;
                clsProductPackagePriceHistoryDetails.LocalTax = decLocalTax;
                clsProductPackagePriceHistoryDetails.Remarks = "Based on PO #: " + clsPODetails.PONo;
                ProductPackagePriceHistory clsProductPackagePriceHistory = new ProductPackagePriceHistory(base.Connection, base.Transaction);
                clsProductPackagePriceHistory.Insert(clsProductPackagePriceHistoryDetails);


				/*******************************************
				 * Add to Inventory
				 * ****************************************/
                //clsProduct.AddQuantity(lngProductID, decQuantity);
                //if (lngVariationMatrixID != 0) { clsProductVariationsMatrix.AddQuantity(lngVariationMatrixID, decQuantity); }
                // July 26, 2011: change the above codes to the following
                clsProduct.AddQuantity(clsPODetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_PURCHASE) + " @ " + decUnitCost.ToString("#,##0.#0") + "/" + strProductUnitCode, DateTime.Now, clsPODetails.PONo, clsPODetails.PurchaserName);

                /*******************************************
				 * Update Purchasing Information
                 * 
                 * 30May2013 Include variation in the package.
				 * ****************************************/
                int iBaseUnitID = clsProduct.get_BaseUnitID(lngProductID);
                if (iBaseUnitID != intProductUnitID)
                {
                    clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsPODetails.SupplierID, iBaseUnitID, (decItemQuantity * decUnitCost) / decQuantity);
                }
                clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsPODetails.SupplierID, intProductUnitID, decUnitCost);

				/*******************************************
				 * Add to Inventory Analysis
				 * ****************************************/
				clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.BranchID = clsPODetails.BranchID;
				clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
				clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
				clsInventoryDetails.PostingDate = clsPODetails.DeliveryDate;
				clsInventoryDetails.ReferenceNo = clsPODetails.PONo;
				clsInventoryDetails.ContactID = clsPODetails.SupplierID;
				clsInventoryDetails.ContactCode = clsPODetails.SupplierCode;
                clsInventoryDetails.ProductID = lngProductID;
                clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
				clsInventoryDetails.PurchaseQuantity = decQuantity;
                clsInventoryDetails.PurchaseCost = decItemCost - decVAT;
                clsInventoryDetails.PurchaseVAT = decItemCost;	// Purchase Cost with VAT

				clsInventory.Insert(clsInventoryDetails);

                /*******************************************
				 * Added Jan 1, 2010 4:20PM
                 * Update Selling Information when PO is posted
				 * ****************************************/
                clsProduct.UpdateSellingPrice(lngProductID, lngVariationMatrixID, clsPODetails.SupplierID, intProductUnitID, Convert.ToDecimal(dr["SellingPrice"]), -1, -1, -1, -1, -1);

                /*******************************************
				 * Added Mar 8, 2010 4:20PM
                 * Update the purchase price history to check who has the lowest price.
				 * ****************************************/
                ProductPurchasePriceHistoryDetails clsProductPurchasePriceHistoryDetails = new ProductPurchasePriceHistoryDetails();
                clsProductPurchasePriceHistoryDetails.ProductID = lngProductID;
                clsProductPurchasePriceHistoryDetails.MatrixID = lngVariationMatrixID;
                clsProductPurchasePriceHistoryDetails.SupplierID = clsPODetails.SupplierID;
                clsProductPurchasePriceHistoryDetails.PurchasePrice = decUnitCost;
                clsProductPurchasePriceHistoryDetails.PurchaseDate = clsPODetails.PODate;
                clsProductPurchasePriceHistoryDetails.Remarks = clsPODetails.PONo;
                clsProductPurchasePriceHistoryDetails.PurchaserName = clsPODetails.PurchaserName;
                ProductPurchasePriceHistory clsProductPurchasePriceHistory = new ProductPurchasePriceHistory(base.Connection, base.Transaction);
                clsProductPurchasePriceHistory.AddToList(clsProductPurchasePriceHistoryDetails);
			}
			//myReader.Close();

		}
Exemplo n.º 9
0
		public void Update(ProductDetails Details)
		{
			try 
			{
                if (IsExist(Details.ProductID, Details.BarCode, Details.BarCode2, Details.BarCode3))
                {
                    throw new Exception("This product already exist, please check the barcode.");
                }

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

				string SQL =	"UPDATE tblProducts SET " +
									"ProductCode		= @ProductCode, " + 
									"ProductDesc		= @ProductDesc, " +  
									"ProductSubGroupID	= @ProductSubGroupID, " + 
									"BaseUnitID			= @BaseUnitID, " +
									"PercentageCommision        =   @PercentageCommision, " +
									"IncludeInSubtotalDiscount	=	@IncludeInSubtotalDiscount, " +
									"MinThreshold		= @MinThreshold, " +
									"MaxThreshold		= @MaxThreshold, " +
									"SupplierID			= @SupplierID, " +
									"IsItemSold			= @IsItemSold, " +
									"WillPrintProductComposition    =   @WillPrintProductComposition, " +
                                    "RID                = @RID, " +
                                    "SequenceNo         = @SequenceNo " +
								"WHERE ProductID	    = @ProductID;";
				  
                cmd.Parameters.AddWithValue("ProductCode", Details.ProductCode);
                cmd.Parameters.AddWithValue("ProductDesc", Details.ProductDesc);
                cmd.Parameters.AddWithValue("ProductSubGroupID", Details.ProductSubGroupID);
                cmd.Parameters.AddWithValue("BaseUnitID", Details.BaseUnitID);
                cmd.Parameters.AddWithValue("PercentageCommision", Details.PercentageCommision);
                cmd.Parameters.AddWithValue("IncludeInSubtotalDiscount", Details.IncludeInSubtotalDiscount);
                cmd.Parameters.AddWithValue("MinThreshold", Details.MinThreshold);
                cmd.Parameters.AddWithValue("MaxThreshold", Details.MaxThreshold);
                cmd.Parameters.AddWithValue("SupplierID", Details.SupplierID);
                cmd.Parameters.AddWithValue("IsItemSold", Details.IsItemSold);
                cmd.Parameters.AddWithValue("WillPrintProductComposition", Details.WillPrintProductComposition);
                cmd.Parameters.AddWithValue("RID", Details.RID);
                cmd.Parameters.AddWithValue("SequenceNo", Details.SequenceNo);
                cmd.Parameters.AddWithValue("ProductID", Details.ProductID);

                cmd.CommandText = SQL;
				base.ExecuteNonQuery(cmd);

                if (Details.Quantity > 0)
                {
                    SQL = "UPDATE tblProducts SET Active = 1 WHERE ProductID = @ProductID AND Active = 0;";

                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("ProductID", Details.ProductID);

                    cmd.CommandText = SQL;
                    base.ExecuteNonQuery(cmd);
                }
				ProductPackageDetails clsDetails = new ProductPackageDetails();
				clsDetails.ProductID = Details.ProductID;
				clsDetails.Quantity = 1;
				clsDetails.Price = Details.Price;
                clsDetails.Price1 = Details.Price1;
                clsDetails.Price2 = Details.Price2;
                clsDetails.Price3 = Details.Price3;
                clsDetails.Price4 = Details.Price4;
                clsDetails.Price5 = Details.Price5;
				clsDetails.WSPrice = Details.WSPrice;
                clsDetails.PurchasePrice = Details.PurchasePrice;
				clsDetails.VAT = Details.VAT;
				clsDetails.EVAT = Details.EVAT;
				clsDetails.LocalTax = Details.LocalTax;
				clsDetails.UnitID = Details.BaseUnitID;
				clsDetails.UnitCode = Details.BaseUnitCode;
				clsDetails.UnitName = Details.BaseUnitName;
				clsDetails.BarCode1 = Details.BarCode;
				clsDetails.BarCode2 = Details.BarCode2;
				clsDetails.BarCode3 = Details.BarCode3;

				ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
				clsProductPackage.UpdateByProductIDUnitIDAndQuantity(clsDetails, Details.UpdatedBy, Details.UpdatedOn, "Edit product module.");
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Exemplo n.º 10
0
		public void UpdatePurchasing(long ProductID, long MatrxID, long SupplierID, int BaseUnitID, decimal UnitCost)
		{
			try 
			{
				string SQL =	"UPDATE tblProducts SET " +
									"SupplierID		= @SupplierID " +
								"WHERE ProductID	= @ProductID " +
									"AND BaseUnitID	= @BaseUnitID;";
				  
				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;
				
				cmd.Parameters.AddWithValue("@SupplierID", SupplierID);
				cmd.Parameters.AddWithValue("@ProductID", ProductID);
				cmd.Parameters.AddWithValue("@BaseUnitID", BaseUnitID);

				base.ExecuteNonQuery(cmd);

				ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
                clsProductPackage.UpdatePurchasing(ProductID, MatrxID, BaseUnitID, 1, UnitCost);

			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Exemplo n.º 11
0
		public Int64 Insert(ProductDetails Details)
		{
			try  
			{
                if (IsExist(Details.ProductID, Details.BarCode, Details.BarCode2, Details.BarCode3))
                {
                    throw new EntryPointNotFoundException("This product already exist, please check the barcode.");
                }

				string SQL =	"INSERT INTO tblProducts (" +
									"ProductCode, " + 
									"ProductDesc, " +  
									"ProductSubGroupID, " + 
									"BaseUnitID, " + 
									"DateCreated, " +
									"PercentageCommision, " +
									"IncludeInSubtotalDiscount, " +
									"MinThreshold, " +
									"MaxThreshold, " +
									"SupplierID, " +
									"IsItemSold, " +
									"WillPrintProductComposition"+
								") VALUES (" +
									"@ProductCode, " + 
									"@ProductDesc, " +   
									"@ProductSubGroupID, " + 
									"@BaseUnitID, " + 
									"@DateCreated," + 
									"@PercentageCommision, " +
									"@IncludeInSubtotalDiscount, " +
									"@MinThreshold, " +
									"@MaxThreshold, " +
									"@SupplierID, " +
									"@IsItemSold, " +
									"@WillPrintProductComposition);"; 

				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;
				
				MySqlParameter prmProductCode = new MySqlParameter("@ProductCode",MySqlDbType.String);			
				prmProductCode.Value = Details.ProductCode;
				cmd.Parameters.Add(prmProductCode);

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

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

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

				MySqlParameter prmDateCreated = new MySqlParameter("@DateCreated",MySqlDbType.DateTime);			
				prmDateCreated.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
				cmd.Parameters.Add(prmDateCreated);

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

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

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

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

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

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

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

				base.ExecuteNonQuery(cmd);

				SQL = "SELECT LAST_INSERT_ID();";
				
				cmd.Parameters.Clear(); 
				cmd.CommandText = SQL;

                System.Data.DataTable dt = new System.Data.DataTable("LAST_INSERT_ID");
                base.MySqlDataAdapterFill(cmd, dt);
                

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

				ProductPackageDetails clsProductPackageDetails = new ProductPackageDetails();
				clsProductPackageDetails.ProductID = iID;
				clsProductPackageDetails.BarCode1 = Details.BarCode;
				clsProductPackageDetails.BarCode2 = Details.BarCode2;
				clsProductPackageDetails.BarCode3 = Details.BarCode3;
				clsProductPackageDetails.UnitID = Details.BaseUnitID;
				clsProductPackageDetails.Price = Details.Price;
                clsProductPackageDetails.Price1 = Details.Price1;
                clsProductPackageDetails.Price2 = Details.Price2;
                clsProductPackageDetails.Price3 = Details.Price3;
                clsProductPackageDetails.Price4 = Details.Price4;
                clsProductPackageDetails.Price5 = Details.Price5;
				clsProductPackageDetails.WSPrice = Details.WSPrice;
                clsProductPackageDetails.PurchasePrice = Details.PurchasePrice;
                clsProductPackageDetails.Quantity = 1;
				clsProductPackageDetails.VAT = Details.VAT;
				clsProductPackageDetails.EVAT = Details.EVAT;
				clsProductPackageDetails.LocalTax = Details.LocalTax;

				ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
				clsProductPackage.Insert(clsProductPackageDetails);

				// Oct 28, 2011 : Lemu
				// Added to cater branch inventory
                //BranchInventory clsBranchInventory = new BranchInventory(base.Connection, base.Transaction);
                //clsBranchInventory.CreateToAllBranches(iID);

				//base.ExecuteNonQuery(cmd);
				
				return iID;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Exemplo n.º 12
0
		// Dec 10, 2011 : Obsolete, change to ChangeTax
		//public void ChangeVAT(decimal OldVAT, decimal NewVAT)
		//{
		//    try 
		//    {
		//        string SQL =	"UPDATE tblProducts SET " +
		//                            "VAT		= @NewVAT " +
		//                        "WHERE VAT		= @OldVAT;";
				  
		//        
				
		//        MySqlCommand cmd = new MySqlCommand();
		//        
		//        
		//        cmd.CommandType = System.Data.CommandType.Text;
		//        cmd.CommandText = SQL;
				
		//        MySqlParameter prmNewVAT = new MySqlParameter("@NewVAT",MySqlDbType.Decimal);			
		//        prmNewVAT.Value = NewVAT;
		//        cmd.Parameters.Add(prmNewVAT);

		//        MySqlParameter prmOldVAT = new MySqlParameter("@OldVAT",MySqlDbType.Decimal);			
		//        prmOldVAT.Value = OldVAT;
		//        cmd.Parameters.Add(prmOldVAT);

		//        base.ExecuteNonQuery(cmd);

		//        MatrixPackage clsMatrixPackage = new MatrixPackage(base.Connection, base.Transaction);
		//        clsMatrixPackage.ChangeVAT(OldVAT, NewVAT);

		//        ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);
		//        clsProductVariationsMatrix.ChangeVAT(OldVAT, NewVAT);

		//        ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
		//        clsProductPackage.ChangeVAT(OldVAT, NewVAT);
		//    }

		//    catch (Exception ex)
		//    {
		//        
		//        
		//        {
		//            
		//            
		//            
		//            
		//        }

		//        throw base.ThrowException(ex);
		//    }	
		//}

		//// Dec 10, 2011 : Obsolete, change to ChangeTax
		//public void ChangeEVAT(decimal OldEVAT, decimal NewEVAT)
		//{
		//    try 
		//    {
		//        string SQL =	"UPDATE tblProducts SET " +
		//            "EVAT		= @NewEVAT " +
		//            "WHERE EVAT		= @OldEVAT;";
				  
		//        
				
		//        MySqlCommand cmd = new MySqlCommand();
		//        
		//        
		//        cmd.CommandType = System.Data.CommandType.Text;
		//        cmd.CommandText = SQL;
				
		//        MySqlParameter prmNewEVAT = new MySqlParameter("@NewEVAT",MySqlDbType.Decimal);			
		//        prmNewEVAT.Value = NewEVAT;
		//        cmd.Parameters.Add(prmNewEVAT);

		//        MySqlParameter prmOldEVAT = new MySqlParameter("@OldEVAT",MySqlDbType.Decimal);			
		//        prmOldEVAT.Value = OldEVAT;
		//        cmd.Parameters.Add(prmOldEVAT);

		//        base.ExecuteNonQuery(cmd);

		//        MatrixPackage clsMatrixPackage = new MatrixPackage(base.Connection, base.Transaction);
		//        clsMatrixPackage.ChangeEVAT(OldEVAT, NewEVAT);

		//        ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);
		//        clsProductVariationsMatrix.ChangeEVAT(OldEVAT, NewEVAT);

		//        ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
		//        clsProductPackage.ChangeEVAT(OldEVAT, NewEVAT);
		//    }

		//    catch (Exception ex)
		//    {
		//        
		//        
		//        {
		//            
		//            
		//            
		//            
		//        }

		//        throw base.ThrowException(ex);
		//    }	
		//}

		//// Dec 10, 2011 : Obsolete, change to ChangeTax
		//public void ChangeLocalTax(decimal OldLocalTax, decimal NewLocalTax)
		//{
		//    try 
		//    {
		//        string SQL =	"UPDATE tblProducts SET " +
		//            "LocalTax		= @NewLocalTax " +
		//            "WHERE LocalTax		= @OldLocalTax;";
				  
		//        
				
		//        MySqlCommand cmd = new MySqlCommand();
		//        
		//        
		//        cmd.CommandType = System.Data.CommandType.Text;
		//        cmd.CommandText = SQL;
				
		//        MySqlParameter prmNewLocalTax = new MySqlParameter("@NewLocalTax",MySqlDbType.Decimal);			
		//        prmNewLocalTax.Value = NewLocalTax;
		//        cmd.Parameters.Add(prmNewLocalTax);

		//        MySqlParameter prmOldLocalTax = new MySqlParameter("@OldLocalTax",MySqlDbType.Decimal);			
		//        prmOldLocalTax.Value = OldLocalTax;
		//        cmd.Parameters.Add(prmOldLocalTax);

		//        base.ExecuteNonQuery(cmd);

		//        MatrixPackage clsMatrixPackage = new MatrixPackage(base.Connection, base.Transaction);
		//        clsMatrixPackage.ChangeLocalTax(OldLocalTax, NewLocalTax);

		//        ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);
		//        clsProductVariationsMatrix.ChangeLocalTax(OldLocalTax, NewLocalTax);

		//        ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
		//        clsProductPackage.ChangeLocalTax(OldLocalTax, NewLocalTax);
		//    }
		//    catch (Exception ex)
		//    {
		//        
		//        
		//        {
		//            
		//            
		//            
		//            
		//        }

		//        throw base.ThrowException(ex);
		//    }	
		//}

		/// <summary>
		/// Update Products VAT, EVAT and LocalTax
		/// This will also update ProductPackage, ProductVariationsMatrix and MatrixPackage
		/// </summary>
		/// <param name="ProductGroupID"></param>
		/// <param name="ProductSubGroupID"></param>
		/// <param name="ProductID"></param>
		/// <param name="NewVAT"></param>
		/// <param name="NewEVAT"></param>
		/// <param name="NewLocalTax"></param>
		public void ChangeTax(long ProductGroupID, long ProductSubGroupID, long ProductID, decimal NewVAT, decimal NewEVAT, decimal NewLocalTax, string CreatedBy)
		{
			try
			{
				ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
                clsProductPackage.ChangeTax(ProductGroupID, ProductSubGroupID, ProductID, NewVAT, NewEVAT, NewLocalTax, CreatedBy);
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}
		}
Exemplo n.º 13
0
		private bool Delete()
		{
			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)
			{
				ProductPackage clsProductPackage = new ProductPackage();
				clsProductPackage.Delete(stIDs.Substring(0,stIDs.Length-1));
				clsProductPackage.CommitAndDispose();

				Security.AuditTrailDetails clsAuditDetails = new Security.AuditTrailDetails();

				clsAuditDetails.ActivityDate = DateTime.Now;
				clsAuditDetails.User = Convert.ToString(Session["Name"]);
				clsAuditDetails.IPAddress = Request.UserHostAddress;
				clsAuditDetails.Activity = "Product Package";
				clsAuditDetails.Remarks = "Delete Product Package(s). ProductID:'" + lblProductID.Text + "' IDs:'" + stIDs + "'";

				Security.AuditTrail clsAuditTrail = new Security.AuditTrail();
				clsAuditTrail.Insert(clsAuditDetails);
				clsAuditTrail.CommitAndDispose();
			}

			return boRetValue;
		}
Exemplo n.º 14
0
		private void LoadRecord()
		{
			ProductPackage clsProductPackage = new ProductPackage();
			ProductPackageDetails clsDetails = clsProductPackage.Details(Convert.ToInt64(lblPackageID.Text));

            Products clsProduct = new Products(clsProductPackage.Connection, clsProductPackage.Transaction);
            ProductDetails clsProductDetails = clsProduct.Details(Convert.ToInt64(lblProductID.Text));

            ProductBaseVariationsMatrixDetails clsProductBaseVariationsMatrixDetails = new ProductBaseVariationsMatrix(clsProductPackage.Connection, clsProductPackage.Transaction).BaseDetails(clsDetails.MatrixID, clsDetails.ProductID);
            clsProductPackage.CommitAndDispose();

            lblProductSubGroupID.Text = clsProductDetails.ProductSubGroupID.ToString();

            lblMatrixID.Text = clsDetails.MatrixID.ToString();
            lblMatrixDescription.Text = clsDetails.MatrixID == 0 ? "" : "Base Matrix: " + clsProductBaseVariationsMatrixDetails.Description;

			cboUnit.SelectedIndex = cboUnit.Items.IndexOf(cboUnit.Items.FindByValue(clsDetails.UnitID.ToString()));
			txtProductPrice.Text = clsDetails.Price.ToString("#,##0.#0");
            txtPrice1.Text = clsDetails.Price1.ToString("#,##0.#0");
            txtPrice2.Text = clsDetails.Price2.ToString("#,##0.#0");
            txtPrice3.Text = clsDetails.Price3.ToString("#,##0.#0");
            txtPrice4.Text = clsDetails.Price4.ToString("#,##0.#0");
            txtPrice5.Text = clsDetails.Price5.ToString("#,##0.#0");
            txtWSPrice.Text = clsDetails.WSPrice.ToString("#,##0.#0");
			txtPurchasePrice.Text = clsDetails.PurchasePrice.ToString("#,##0.#0");

            decimal decMargin = clsDetails.Price - clsDetails.PurchasePrice;
            try { decMargin = decMargin / clsDetails.PurchasePrice; }
            catch { decMargin = 1; }
            decMargin = decMargin * 100;
            txtMargin.Text = decMargin.ToString("#,##0.##0");

            decMargin = clsDetails.WSPrice - clsDetails.PurchasePrice;
            try { decMargin = decMargin / clsDetails.PurchasePrice; }
            catch { decMargin = 1; }
            decMargin = decMargin * 100;
            txtWSPriceMarkUp.Text = decMargin.ToString("#,##0.##0");

			txtVAT.Text = clsDetails.VAT.ToString("#,##0.#0");
			txtEVAT.Text = clsDetails.EVAT.ToString("#,##0.#0");
			txtLocalTax.Text = clsDetails.LocalTax.ToString("#,##0.#0");
			txtQuantity.Text = clsDetails.Quantity.ToString("#,##0.#0");
            txtBarCode1.Text = clsDetails.BarCode1;
            txtBarCode2.Text = clsDetails.BarCode2;
            txtBarCode3.Text = clsDetails.BarCode3;
            if (clsDetails.Quantity == 1 && clsProductDetails.BaseUnitID == clsDetails.UnitID)
            {
                txtQuantity.Enabled = false; cboUnit.Enabled = false;
            }
		}
Exemplo n.º 15
0
        public void UpdateSellingWSPrice(long ProductID, long MatrixID, long SupplierID, int BaseUnitID, decimal WholesalePrice)
		{
			try
			{
				ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
                clsProductPackage.UpdateSellingWSPrice(ProductID, MatrixID, BaseUnitID, 1, WholesalePrice);
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}
		}
Exemplo n.º 16
0
		private bool SaveRecord()
		{
            long lngUID = long.Parse(Session["UID"].ToString());
            DateTime dteChangeDate = DateTime.Now;

			ProductPackage clsProductPackage = new ProductPackage();
			ProductPackageDetails clsDetails = new ProductPackageDetails();
			
			clsDetails.PackageID = Convert.ToInt64(lblPackageID.Text);
            clsDetails.MatrixID = Convert.ToInt64(lblMatrixID.Text);
            clsDetails.ProductID = Convert.ToInt64(lblProductID.Text);
			clsDetails.UnitID = Convert.ToInt32(cboUnit.SelectedItem.Value);
			clsDetails.Price = Convert.ToDecimal(txtProductPrice.Text);
            clsDetails.Price1 = Convert.ToDecimal(txtPrice1.Text);
            clsDetails.Price2 = Convert.ToDecimal(txtPrice2.Text);
            clsDetails.Price3 = Convert.ToDecimal(txtPrice3.Text);
            clsDetails.Price4 = Convert.ToDecimal(txtPrice4.Text);
            clsDetails.Price5 = Convert.ToDecimal(txtPrice5.Text);
            clsDetails.WSPrice = Convert.ToDecimal(txtWSPrice.Text);
			clsDetails.PurchasePrice = Convert.ToDecimal(txtPurchasePrice.Text);
			clsDetails.Quantity = Convert.ToDecimal(txtQuantity.Text);
			clsDetails.VAT = Convert.ToDecimal(txtVAT.Text);
			clsDetails.EVAT = Convert.ToDecimal(txtEVAT.Text);
			clsDetails.LocalTax = Convert.ToDecimal(txtLocalTax.Text);
            clsDetails.BarCode1 = txtBarCode1.Text;
            clsDetails.BarCode2 = txtBarCode2.Text;
            clsDetails.BarCode3 = txtBarCode3.Text;

			clsProductPackage.Update(clsDetails, lngUID, dteChangeDate, "Product Package Update.");
			clsProductPackage.CommitAndDispose();

			return true;
		}
Exemplo n.º 17
0
        private void AddItemToInventory(long TransferInID)
        {
            try
            {
                TransferInDetails clsTransferInDetails = Details(TransferInID);
                ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
                ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

                TransferInItem clsTransferInItem = new TransferInItem(base.Connection, base.Transaction);
                ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
                Products clsProduct = new Products(base.Connection, base.Transaction);
                ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);

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

                ProductPackagePriceHistoryDetails clsProductPackagePriceHistoryDetails;

                System.Data.DataTable dt = clsTransferInItem.ListAsDataTable(TransferInID, "TransferInItemID", SortOption.Ascending);
            
                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 = new ProductUnit().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 decSellingPrice = Convert.ToDecimal(dr["SellingPrice"]);
                    decimal decVAT = Convert.ToDecimal(dr["VAT"]); // myReader.GetDecimal("VAT");
                    decimal decEVAT = Convert.ToDecimal(dr["EVAT"]);
                    decimal decLocalTax = Convert.ToDecimal(dr["LocalTax"]); 

                    /*******************************************
				     * Add in the Price History
				     * ****************************************/
                    // Update ProductPackagePriceHistory first to get the history
                    clsProductPackagePriceHistoryDetails = new ProductPackagePriceHistoryDetails();
                    clsProductPackagePriceHistoryDetails.UID = clsTransferInDetails.TransferrerID;
                    clsProductPackagePriceHistoryDetails.PackageID = new ProductPackage().GetPackageID(lngProductID, intProductUnitID);
                    clsProductPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                    clsProductPackagePriceHistoryDetails.PurchasePrice = (decItemQuantity * decUnitCost) / decQuantity;
                    clsProductPackagePriceHistoryDetails.Price = decSellingPrice;
                    clsProductPackagePriceHistoryDetails.VAT = decVAT;
                    clsProductPackagePriceHistoryDetails.EVAT = decEVAT;
                    clsProductPackagePriceHistoryDetails.LocalTax = decLocalTax;
                    clsProductPackagePriceHistoryDetails.Remarks = "Based on TransferIn #: " + clsTransferInDetails.TransferInNo;
                    ProductPackagePriceHistory clsProductPackagePriceHistory = new ProductPackagePriceHistory(base.Connection, base.Transaction);
                    clsProductPackagePriceHistory.Insert(clsProductPackagePriceHistoryDetails);

                    /*******************************************
                     * Add to Inventory
                     * ****************************************/
                    //clsProduct.AddQuantity(lngProductID, decQuantity);
                    //if (lngVariationMatrixID != 0)
                    //{
                    //    clsProductVariationsMatrix.AddQuantity(lngVariationMatrixID, decQuantity);
                    //}
                    // July 26, 2011: change the above codes to the following
                    clsProduct.AddQuantity(clsTransferInDetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_TRANSFER_IN), DateTime.Now, clsTransferInDetails.TransferInNo, clsTransferInDetails.TransferrerName);

                    /*******************************************
                     * Update Purchasing Information
                     * ****************************************/
                    int iBaseUnitID = clsProduct.get_BaseUnitID(lngProductID);
                    if (iBaseUnitID != intProductUnitID)
                    {
                        clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsTransferInDetails.SupplierID, iBaseUnitID, (decItemQuantity * decUnitCost) / decQuantity);
                    }
                    clsProduct.UpdatePurchasing(lngProductID, lngVariationMatrixID, clsTransferInDetails.SupplierID, intProductUnitID, decUnitCost);

                    /*******************************************
                     * Add to Inventory Analysis
                     * ****************************************/
                    clsInventoryDetails = new InventoryDetails();
                    clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
                    clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
                    clsInventoryDetails.PostingDate = clsTransferInDetails.DeliveryDate;
                    clsInventoryDetails.ReferenceNo = clsTransferInDetails.TransferInNo;
                    clsInventoryDetails.ContactID = clsTransferInDetails.SupplierID;
                    clsInventoryDetails.ContactCode = clsTransferInDetails.SupplierCode;
                    clsInventoryDetails.ProductID = lngProductID;
                    clsInventoryDetails.ProductCode = strProductCode;
                    clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                    clsInventoryDetails.MatrixDescription = strMatrixDescription;
                    clsInventoryDetails.TransferInQuantity = decQuantity;
                    clsInventoryDetails.TransferInCost = decItemCost - decVAT;
                    clsInventoryDetails.TransferInVAT = decItemCost;	// TransferIn Cost with VAT

                    clsInventory.Insert(clsInventoryDetails);

                    /*******************************************
				     * Added April 28, 2010 4:20PM
                     * Update Selling Information when TransferIn is posted
				     * ****************************************/
                    clsProduct.UpdateSellingPrice(lngProductID, lngVariationMatrixID, clsTransferInDetails.SupplierID, intProductUnitID, decimal.Parse(dr["SellingPrice"].ToString()), -1, -1, -1, -1, -1);
                    //if (lngVariationMatrixID != 0)
                    //{
                    //    clsProductVariationsMatrix.UpdateSellingWithSameQuantityAndUnit(lngVariationMatrixID, clsPODetails.SupplierID, intProductUnitID, decimal.Parse(myReader["SellingPrice");
                    //}

                    /*******************************************
				     * Added April 28, 2010 4:20PM
                     * Update the purchase price history to check who has the lowest price.
				     * ****************************************/
                    ProductPurchasePriceHistoryDetails clsProductPurchasePriceHistoryDetails = new ProductPurchasePriceHistoryDetails();
                    clsProductPurchasePriceHistoryDetails.ProductID = lngProductID;
                    clsProductPurchasePriceHistoryDetails.MatrixID = lngVariationMatrixID;
                    clsProductPurchasePriceHistoryDetails.SupplierID = clsTransferInDetails.SupplierID;
                    clsProductPurchasePriceHistoryDetails.PurchasePrice = decUnitCost;
                    clsProductPurchasePriceHistoryDetails.PurchaseDate = clsTransferInDetails.TransferInDate;
                    clsProductPurchasePriceHistoryDetails.Remarks = clsTransferInDetails.TransferInNo;
                    ProductPurchasePriceHistory clsProductPurchasePriceHistory = new ProductPurchasePriceHistory(base.Connection, base.Transaction);
                    clsProductPurchasePriceHistory.AddToList(clsProductPurchasePriceHistoryDetails);
                }
            }
            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }

        }
Exemplo n.º 18
0
		private bool SaveRecord()
		{
			ProductPackageDetails clsDetails = new ProductPackageDetails();
			
			clsDetails.ProductID = Convert.ToInt64(lblProductID.Text);
			clsDetails.UnitID = Convert.ToInt32(cboUnit.SelectedItem.Value);
            clsDetails.Price = Convert.ToDecimal(txtProductPrice.Text);
            clsDetails.Price1 = Convert.ToDecimal(txtPrice1.Text);
            clsDetails.Price2 = Convert.ToDecimal(txtPrice2.Text);
            clsDetails.Price3 = Convert.ToDecimal(txtPrice3.Text);
            clsDetails.Price4 = Convert.ToDecimal(txtPrice4.Text);
            clsDetails.Price5 = Convert.ToDecimal(txtPrice5.Text);
            clsDetails.WSPrice = Convert.ToDecimal(txtWSPrice.Text);
            clsDetails.PurchasePrice = Convert.ToDecimal(txtPurchasePrice.Text);
			clsDetails.Quantity = Convert.ToDecimal(txtQuantity.Text);
			clsDetails.VAT = Convert.ToDecimal(txtVAT.Text);
			clsDetails.EVAT = Convert.ToDecimal(txtEVAT.Text);
			clsDetails.LocalTax = Convert.ToDecimal(txtLocalTax.Text);
            clsDetails.BarCode1 = txtBarCode1.Text;
            clsDetails.BarCode2 = txtBarCode2.Text;
            clsDetails.BarCode3 = txtBarCode3.Text;

			ProductPackage clsProductPackage = new ProductPackage();
			clsProductPackage.Insert(clsDetails);
			clsProductPackage.CommitAndDispose();

			return true;
		}
Exemplo n.º 19
0
		public bool UpdateBaseVariation(ProductBaseVariationsMatrixDetails Details)
		{
			try 
			{
                ProductBaseVariationsMatrix clsProductBaseVariationsMatrix = new ProductBaseVariationsMatrix(base.Connection, base.Transaction);
                clsProductBaseVariationsMatrix.Update(Details);

                ProductPackageDetails clsDetails = new ProductPackageDetails();
                clsDetails.ProductID = Details.ProductID;
				clsDetails.MatrixID = Details.MatrixID;
				clsDetails.UnitID = Details.UnitID;
				clsDetails.Price = Details.Price;

                // 02Mar2015 : Added Price1...Price5
                clsDetails.Price1 = Details.Price1;
                clsDetails.Price2 = Details.Price2;
                clsDetails.Price3 = Details.Price3;
                clsDetails.Price4 = Details.Price4;
                clsDetails.Price5 = Details.Price5;

                clsDetails.WSPrice = Details.WSPrice;
				clsDetails.PurchasePrice = Details.PurchasePrice;
				clsDetails.Quantity = 1;
				clsDetails.VAT = Details.VAT;
				clsDetails.EVAT = Details.EVAT;
				clsDetails.LocalTax = Details.LocalTax;

                // 27May2014: Added barcode details
                clsDetails.BarCode1 = Details.BarCode1;
                clsDetails.BarCode2 = Details.BarCode2;
                clsDetails.BarCode3 = Details.BarCode3;

                ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
                clsProductPackage.Update(clsDetails, 0, DateTime.Now, "Update base variation");

				return true;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Exemplo n.º 20
0
        protected void cboProductUnit_SelectedIndexChanged(object sender, EventArgs e)
        {
            ProductPackage clsProductPackage = new ProductPackage();
            ProductPackageDetails clsDetails = clsProductPackage.DetailsByProductIDAndUnitID(long.Parse(cboProductCode.SelectedValue), long.Parse(cboProductUnit.SelectedValue));
            if (clsDetails.PackageID == 0)
            {
                ProductUnit clsProductUnit = new ProductUnit(clsProductPackage.Connection, clsProductPackage.Transaction);
                Products clsProduct = new Products(clsProductPackage.Connection, clsProductPackage.Transaction);
                ProductDetails clsProductDetails = clsProduct.Details(long.Parse(cboProductCode.SelectedItem.Value));
                decimal decBaseUnitValue = clsProductUnit.GetBaseUnitValue(long.Parse(cboProductCode.SelectedItem.Value), int.Parse(cboProductUnit.SelectedItem.Value), 1);

                clsDetails.Price = decBaseUnitValue * clsProductDetails.Price;
                clsDetails.PurchasePrice = decBaseUnitValue * clsProductDetails.PurchasePrice;
            }
            clsProductPackage.CommitAndDispose();


            txtPrice.Text = clsDetails.PurchasePrice.ToString("#####0.##0");
            txtSellingPrice.Text = clsDetails.Price.ToString("#####0.##0");
            txtOldSellingPrice.Text = clsDetails.Price.ToString("#####0.##0");
            decimal decMargin = clsDetails.Price - clsDetails.PurchasePrice;
            try { decMargin = decMargin / clsDetails.PurchasePrice; }
            catch { decMargin = 1; }
            decMargin = decMargin * 100;
            txtMargin.Text = decMargin.ToString("#,##0.##0");
            txtVAT.Text = clsDetails.VAT.ToString("#,##0.##0");
            txtEVAT.Text = clsDetails.EVAT.ToString("#,##0.##0");
            txtLocalTax.Text = clsDetails.LocalTax.ToString("#,##0.##0");

            ComputeItemAmount();
            lstItemFixCssClass();
        }
Exemplo n.º 21
0
        /// <summary>
        /// Aug 1, 2011 : Lemu
        /// Include clsProduct.AddQuantity
        /// </summary>
        /// <param name="Details"></param>
        /// <returns></returns>
		public Int64 InsertBaseVariation(ProductBaseVariationsMatrixDetails Details)
		{
			try 
			{
                ProductBaseVariationsMatrix clsProductBaseVariationsMatrix = new ProductBaseVariationsMatrix(base.Connection, base.Transaction);
                clsProductBaseVariationsMatrix.Insert(Details);

                string SQL = "SELECT LAST_INSERT_ID();";
				  
				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				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 = Int64.Parse(dt.Rows[0][0].ToString());

                // 23May2013 Add n the product package
                ProductPackageDetails clsProductPackageDetails = new ProductPackageDetails();
                clsProductPackageDetails.ProductID = Details.ProductID;
                clsProductPackageDetails.MatrixID = iID;
                clsProductPackageDetails.BarCode1 = Details.BarCode1;
                clsProductPackageDetails.BarCode2 = Details.BarCode2;
                clsProductPackageDetails.BarCode3 = Details.BarCode3;
                clsProductPackageDetails.UnitID = Details.UnitID;
                clsProductPackageDetails.Price = Details.Price;
                clsProductPackageDetails.WSPrice = Details.WSPrice;
                clsProductPackageDetails.PurchasePrice = Details.PurchasePrice;
                clsProductPackageDetails.Quantity = 1;
                clsProductPackageDetails.VAT = Details.VAT;
                clsProductPackageDetails.EVAT = Details.EVAT;
                clsProductPackageDetails.LocalTax = Details.LocalTax;

                ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
                clsProductPackage.Insert(clsProductPackageDetails);

                /************************
                 * 23May2013 Remove handling of inventory here
                 * Inventory should be added in the addquantity / subtractquantity
                 * 
				MatrixPackageDetails clsMatrixPackageDetails = new MatrixPackageDetails();
				clsMatrixPackageDetails.MatrixID = iID;
				clsMatrixPackageDetails.UnitID = Details.UnitID;
				clsMatrixPackageDetails.Price = Details.Price;
                clsMatrixPackageDetails.WSPrice = Details.WSPrice;
				clsMatrixPackageDetails.PurchasePrice = Details.PurchasePrice;
				clsMatrixPackageDetails.Quantity = 1;
				clsMatrixPackageDetails.VAT = Details.VAT;
				clsMatrixPackageDetails.EVAT = Details.EVAT;
				clsMatrixPackageDetails.LocalTax = Details.LocalTax;

				MatrixPackage clsMatrixPackage = new MatrixPackage(base.Connection, base.Transaction);
				clsMatrixPackage.Insert(clsMatrixPackageDetails);

                
                // Oct 28, 2011 : Lemu
                // Added to cater branch inventory
                SQL = "CALL procProductBranchInventoryInsert(@lngProductID);";

                cmd.Parameters.Clear();
                cmd.CommandText = SQL;
                cmd.Parameters.AddWithValue("@lngProductID", Details.ProductID);
                base.ExecuteNonQuery(cmd);

                // Oct 28, 2011 : change to procSyncProductVariationFromQuantityPerItem(lngProductID, intBranchID);
                // ProductUnit clsProductUnit = new ProductUnit(base.Connection, base.Transaction);
                // decimal Quantity = clsProductUnit.GetBaseUnitValue(Details.ProductID, Details.UnitID, Details.Quantity);
				// Product clsProduct = new Product(base.Connection, base.Transaction);
                // clsProduct.AddQuantity(Constants.BRANCH_ID_MAIN, Details.ProductID, iID, Details.Quantity, Product.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_PRODUCT_VARIATION_CREATION), DateTime.Now, "SYS-ADDVAR" + DateTime.Now.ToString("yyyyMMddHHmmss"), Details.CreatedBy);
                SQL = "CALL procSyncProductVariationFromQuantityPerItemAllBranch(@lngProductID);";

                cmd.Parameters.Clear();
                cmd.CommandText = SQL;
                cmd.Parameters.AddWithValue("@lngProductID", Details.ProductID);
                base.ExecuteNonQuery(cmd);          

                // Added August 2, 2009 to monitor if product still has/have variations
                Products clsProduct = new Products(base.Connection, base.Transaction);
                clsProduct.UpdateVariationCount(Details.ProductID);
                *************************/

                return iID;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Exemplo n.º 22
0
		private Int32 SaveRecord()
		{
			ProductUnitsMatrix clsUnitMatrix = new ProductUnitsMatrix();
			ProductUnitsMatrixDetails clsDetails = new ProductUnitsMatrixDetails();

			clsDetails.ProductID = Convert.ToInt64(lblProductID.Text);
			clsDetails.BaseUnitID = Convert.ToInt32(lblBaseUnitID.Text);
			clsDetails.BaseUnitValue = Convert.ToDecimal(txtBaseUnitValue.Text);
			clsDetails.BottomUnitID = Convert.ToInt32(cboBottomUnit.SelectedItem.Value);
			clsDetails.BottomUnitValue = Convert.ToDecimal(txtBottomUnitValue.Text);
			int id = clsUnitMatrix.Insert(clsDetails);

            ProductPackageDetails clsProductPackageDetails = new ProductPackageDetails();
            ProductPackage clsProductPackage = new ProductPackage(clsUnitMatrix.Connection, clsUnitMatrix.Transaction);
            clsProductPackageDetails = clsProductPackage.DetailsByProductIDAndUnitID(Convert.ToInt64(lblProductID.Text), Convert.ToInt32(cboBottomUnit.SelectedItem.Value));
            if (clsProductPackageDetails.PackageID == 0)
            {
                Products clsProduct = new Products(clsUnitMatrix.Connection, clsUnitMatrix.Transaction);
                ProductDetails clsProductDetails = clsProduct.Details(Convert.ToInt64(lblProductID.Text));

                Terminal clsTerminal = new Terminal(clsUnitMatrix.Connection, clsUnitMatrix.Transaction);
                TerminalDetails clsTerminalDetails = clsTerminal.Details(Int32.Parse(Session["BranchID"].ToString()), Session["TerminalNo"].ToString());

                clsProductPackageDetails.ProductID = Convert.ToInt64(lblProductID.Text);
                clsProductPackageDetails.UnitID = Convert.ToInt32(cboBottomUnit.SelectedItem.Value);
                clsProductPackageDetails.Price = clsProductDetails.Price * Convert.ToDecimal(txtBaseUnitValue.Text);
                clsProductPackageDetails.WSPrice = clsProductDetails.WSPrice * Convert.ToDecimal(txtBaseUnitValue.Text);
                clsProductPackageDetails.PurchasePrice = clsProductDetails.PurchasePrice * Convert.ToDecimal(txtBaseUnitValue.Text);
                clsProductPackageDetails.Quantity = 1;
                clsProductPackageDetails.VAT = clsTerminalDetails.VAT;
                clsProductPackageDetails.EVAT = clsTerminalDetails.EVAT;
                clsProductPackageDetails.LocalTax = clsTerminalDetails.LocalTax;
                if (!string.IsNullOrEmpty(clsProductDetails.BarCode1)) clsProductPackageDetails.BarCode1 = clsProductDetails.BarCode1 + clsProductPackageDetails.UnitID.ToString() + clsProductPackageDetails.Quantity.ToString();
                if (!string.IsNullOrEmpty(clsProductDetails.BarCode2)) clsProductPackageDetails.BarCode2 = clsProductDetails.BarCode2 + clsProductPackageDetails.UnitID.ToString() + clsProductPackageDetails.Quantity.ToString();
                if (!string.IsNullOrEmpty(clsProductDetails.BarCode3)) clsProductPackageDetails.BarCode3 = clsProductDetails.BarCode3 + clsProductPackageDetails.UnitID.ToString() + clsProductPackageDetails.Quantity.ToString();
                clsProductPackage.Insert(clsProductPackageDetails);
            }
			clsUnitMatrix.CommitAndDispose();

			return id;
		}
Exemplo n.º 23
0
        protected void lstProductPackages_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
        {
            TextBox txtSellingPrice = (TextBox)e.Item.FindControl("txtSellingPrice");
            TextBox txtBarCode1 = (TextBox)e.Item.FindControl("txtBarCode1");
            TextBox txtBarCode2 = (TextBox)e.Item.FindControl("txtBarCode2");
            TextBox txtBarCode3 = (TextBox)e.Item.FindControl("txtBarCode3");

            switch (e.CommandName)
            {
                case "cmdDelProductPackage":
                    Label lblProductPackageID = (Label)e.Item.FindControl("lblProductPackageID");

                    ProductPackage clsProductPackage = new ProductPackage();
                    clsProductPackage.Delete(lblProductPackageID.Text);
                    clsProductPackage.CommitAndDispose();

                    cboProductCode_SelectedIndexChanged(null, null);
                    break;
                case "cmdPrintShelvesBarCode1":
                    AceSoft.ThermalBarCodePrinter clsThermalBarCodePrinter1 = new ThermalBarCodePrinter();
                    clsThermalBarCodePrinter1.PrintShelvesTag(cboProductCode.SelectedItem.Text, txtBarCode1.Text, Convert.ToDecimal(txtSellingPrice.Text).ToString("#,##0.#0"));
                    break;
                case "cmdPrintShelvesBarCode2":
                    AceSoft.ThermalBarCodePrinter clsThermalBarCodePrinter2 = new ThermalBarCodePrinter();
                    clsThermalBarCodePrinter2.PrintShelvesTag(cboProductCode.SelectedItem.Text, txtBarCode2.Text, Convert.ToDecimal(txtSellingPrice.Text).ToString("#,##0.#0"));
                    break;
                case "cmdPrintShelvesBarCode3":
                    AceSoft.ThermalBarCodePrinter clsThermalBarCodePrinter3 = new ThermalBarCodePrinter();
                    clsThermalBarCodePrinter3.PrintShelvesTag(cboProductCode.SelectedItem.Text, txtBarCode3.Text, Convert.ToDecimal(txtSellingPrice.Text).ToString("#,##0.#0"));
                    break;
                case "cmdPrintTagPriceBarCode1":
                    AceSoft.ThermalBarCodePrinter clsThermalBarCodeTagPrice1 = new ThermalBarCodePrinter();
                    clsThermalBarCodeTagPrice1.PrintTagPrice(cboProductCode.SelectedItem.Text, txtBarCode1.Text, Convert.ToDecimal(txtSellingPrice.Text).ToString("#,##0.#0"));
                    break;
                case "cmdPrintTagPriceBarCode2":
                    AceSoft.ThermalBarCodePrinter clsThermalBarCodeTagPrice2 = new ThermalBarCodePrinter();
                    clsThermalBarCodeTagPrice2.PrintTagPrice(cboProductCode.SelectedItem.Text, txtBarCode2.Text, Convert.ToDecimal(txtSellingPrice.Text).ToString("#,##0.#0"));
                    break;
                case "cmdPrintTagPriceBarCode3":
                    AceSoft.ThermalBarCodePrinter clsThermalBarCodeTagPrice3 = new ThermalBarCodePrinter();
                    clsThermalBarCodeTagPrice3.PrintTagPrice(cboProductCode.SelectedItem.Text, txtBarCode3.Text, Convert.ToDecimal(txtSellingPrice.Text).ToString("#,##0.#0"));
                    break;

                // 02Mar2015 : Added to automatically generate Barcode
                case "imgCreateBarCode1_Click":
                    txtBarCode1.Text = CreateBarCode();
                    break;
                case "imgCreateBarCode2_Click":
                    txtBarCode2.Text = CreateBarCode();
                    break;
                case "imgCreateBarCode3_Click":
                    txtBarCode3.Text = CreateBarCode();
                    break;
            }
        }
Exemplo n.º 24
0
		private void LoadItemData()
		{	
			ProductPackage clsProductPackage = new ProductPackage(); 

			try
			{
				DataClass clsData = new DataClass(); 
				System.Data.DataTable dt = clsData.DataReaderToDataTable(clsProductPackage.List(mDetails.ProductID,"ProductDesc",SortOption.Ascending));
				clsProductPackage.CommitAndDispose();
				
				//dt.TableName = "tblProductPackage";
                this.dgStyle.MappingName = dt.TableName;
				dgItems.DataSource = dt;
				dgItems.Select(0);
				dgItems.CurrentRowIndex=0;
			}
			catch (Exception ex)
			{
				clsProductPackage.CommitAndDispose();
				MessageBox.Show(ex.Message,"RetailPlus",MessageBoxButtons.OK,MessageBoxIcon.Error); 
			}
		}
Exemplo n.º 25
0
		private void SaveRecord()
		{
            long lngUID = long.Parse(Session["UID"].ToString());
            DateTime dteChangeDate = DateTime.Now;

            ProductPackage clsProductPackage = new ProductPackage();
            clsProductPackage.GetConnection();

            bool boIsFirstRecord = true;
            ProductPackageDetails clsProductPackageDetails;
            foreach (DataListItem e in lstProductPackages.Items)
            {
                if (boIsFirstRecord == true)
                {
                    TextBox txtCommision = (TextBox)e.FindControl("txtCommision");
                    Products clsProduct = new Products(clsProductPackage.Connection, clsProductPackage.Transaction);
                    clsProduct.UpdateCommision(long.Parse(cboProductCode.SelectedValue), Convert.ToDecimal(txtCommision.Text));

                    boIsFirstRecord = false;
                }

                HtmlInputCheckBox chkProductPackageID = (HtmlInputCheckBox)e.FindControl("chkProductPackageID");
                TextBox txtBarCode1 = (TextBox)e.FindControl("txtBarCode1");
                TextBox txtBarCode2 = (TextBox)e.FindControl("txtBarCode2");
                TextBox txtBarCode3 = (TextBox)e.FindControl("txtBarCode3");
                Label lblUnitName = (Label)e.FindControl("lblUnitName");
                TextBox txtQuantity = (TextBox)e.FindControl("txtQuantity");
                TextBox txtPurchasePrice = (TextBox)e.FindControl("txtPurchasePrice");
                TextBox txtSellingPrice = (TextBox)e.FindControl("txtSellingPrice");
                TextBox txtPrice1 = (TextBox)e.FindControl("txtPrice1");
                TextBox txtPrice2 = (TextBox)e.FindControl("txtPrice2");
                TextBox txtPrice3 = (TextBox)e.FindControl("txtPrice3");
                TextBox txtPrice4 = (TextBox)e.FindControl("txtPrice4");
                TextBox txtPrice5 = (TextBox)e.FindControl("txtPrice5");
                TextBox txtWSPrice = (TextBox)e.FindControl("txtWSPrice");
                Label lblVAT = (Label)e.FindControl("lblVAT");
                Label lblEVAT = (Label)e.FindControl("lblEVAT");
                Label lblLocalTax = (Label)e.FindControl("lblLocalTax");
                
                clsProductPackageDetails = new ProductPackageDetails();
                clsProductPackageDetails.PackageID = Convert.ToInt64(chkProductPackageID.Value);
                clsProductPackageDetails.ProductID = Convert.ToInt64(cboProductCode.SelectedValue);
                clsProductPackageDetails.UnitID = Convert.ToInt32(lblUnitName.ToolTip);
                clsProductPackageDetails.Price = Convert.ToDecimal(txtSellingPrice.Text);
                clsProductPackageDetails.Price1 = Convert.ToDecimal(txtPrice1.Text);
                clsProductPackageDetails.Price2 = Convert.ToDecimal(txtPrice2.Text);
                clsProductPackageDetails.Price3 = Convert.ToDecimal(txtPrice3.Text);
                clsProductPackageDetails.Price4 = Convert.ToDecimal(txtPrice4.Text);
                clsProductPackageDetails.Price5 = Convert.ToDecimal(txtPrice5.Text);
                clsProductPackageDetails.WSPrice = Convert.ToDecimal(txtWSPrice.Text);
                clsProductPackageDetails.PurchasePrice = Convert.ToDecimal(txtPurchasePrice.Text);
                clsProductPackageDetails.Quantity = Convert.ToDecimal(txtQuantity.Text);
                clsProductPackageDetails.VAT = Convert.ToDecimal(lblVAT.Text);
                clsProductPackageDetails.EVAT = Convert.ToDecimal(lblEVAT.Text);
                clsProductPackageDetails.LocalTax = Convert.ToDecimal(lblLocalTax.Text);
                clsProductPackageDetails.BarCode1 = txtBarCode1.Text;
                clsProductPackageDetails.BarCode2 = txtBarCode2.Text;
                clsProductPackageDetails.BarCode3 = txtBarCode3.Text;

                clsProductPackage.Update(clsProductPackageDetails, lngUID, dteChangeDate, "Change price adjustment.");

            }

            clsProductPackage.CommitAndDispose();
		}
Exemplo n.º 26
0
        private void SelectItem()
        {
            ListView.SelectedListViewItemCollection items = this.lstItems.SelectedItems;

            foreach (ListViewItem item in items)
            { mDetails.ProductPackageID = Convert.ToInt64(item.SubItems[0].Name); break; }

            ProductPackage clsProductPackage = new ProductPackage();
            ProductPackageDetails clsDetails = clsProductPackage.Details(mDetails.ProductPackageID);
            clsProductPackage.CommitAndDispose();
            if (mDetails.ProductPackageID != 0)
            {
                mDetails.ProductUnitID = clsDetails.UnitID;
                mDetails.ProductUnitCode = clsDetails.UnitCode;
                mDetails.Price = clsDetails.Price;
                mDetails.PackageQuantity = clsDetails.Quantity;
                mDetails.VAT = clsDetails.VAT;
                mDetails.LocalTax = clsDetails.LocalTax;
                mDetails.Amount = (mDetails.Quantity * mDetails.Price) - (mDetails.Quantity * mDetails.Discount);
                mDetails.PurchasePrice = clsDetails.PurchasePrice;
                mDetails.Amount = mDetails.Quantity * mDetails.PurchasePrice;
            }

            dialog = DialogResult.OK;
            this.Hide();
        }
Exemplo n.º 27
0
        private void SubtractItemFromInventory(long TransferOutID)
        {

            TransferOutDetails clsTransferOutDetails = Details(TransferOutID);
            ERPConfig clsERPConfig = new ERPConfig(base.Connection, base.Transaction);
            ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details();

            TransferOutItem clsTransferOutItem = new TransferOutItem(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);
            ProductPackage clsProductPackage = new ProductPackage(base.Connection, base.Transaction);
            MatrixPackage clsMatrixPackage = new MatrixPackage(base.Connection, base.Transaction);

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

            //MatrixPackagePriceHistoryDetails clsMatrixPackagePriceHistoryDetails;
            //ProductPackagePriceHistoryDetails clsProductPackagePriceHistoryDetails;

            System.Data.DataTable dt = clsTransferOutItem.ListAsDataTable(TransferOutID, "TransferOutItemID", SortOption.Ascending);

            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 in the Purchase Price History
                // * ****************************************/
                //if (lngVariationMatrixID != 0)
                //{
                //    // Update MatrixPackagePriceHistory first to get the history
                //    clsMatrixPackagePriceHistoryDetails = new MatrixPackagePriceHistoryDetails();
                //    clsMatrixPackagePriceHistoryDetails.UID = clsTransferOutDetails.TransferrerID;
                //    clsMatrixPackagePriceHistoryDetails.PackageID = clsMatrixPackage.GetPackageID(lngVariationMatrixID, intProductUnitID);
                //    clsMatrixPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                //    clsMatrixPackagePriceHistoryDetails.PurchasePrice = (decItemQuantity * decUnitCost) / decQuantity;
                //    clsMatrixPackagePriceHistoryDetails.Price = -1;
                //    clsMatrixPackagePriceHistoryDetails.VAT = -1;
                //    clsMatrixPackagePriceHistoryDetails.EVAT = -1;
                //    clsMatrixPackagePriceHistoryDetails.LocalTax = -1;
                //    clsMatrixPackagePriceHistoryDetails.Remarks = "Based on TransferOut #: " + clsTransferOutDetails.TransferOutNo;
                //    MatrixPackagePriceHistory clsMatrixPackagePriceHistory = new MatrixPackagePriceHistory(base.Connection, base.Transaction);
                //    clsMatrixPackagePriceHistory.Insert(clsMatrixPackagePriceHistoryDetails);
                //}
                //else
                //{
                //    // Update ProductPackagePriceHistory first to get the history
                //    clsProductPackagePriceHistoryDetails = new ProductPackagePriceHistoryDetails();
                //    clsProductPackagePriceHistoryDetails.UID = clsTransferOutDetails.TransferrerID;
                //    clsProductPackagePriceHistoryDetails.PackageID = clsProductPackage.GetPackageID(lngProductID, intProductUnitID);
                //    clsProductPackagePriceHistoryDetails.ChangeDate = DateTime.Now;
                //    clsProductPackagePriceHistoryDetails.PurchasePrice = (decItemQuantity * decUnitCost) / decQuantity;
                //    clsProductPackagePriceHistoryDetails.Price = -1;
                //    clsProductPackagePriceHistoryDetails.VAT = -1;
                //    clsProductPackagePriceHistoryDetails.EVAT = -1;
                //    clsProductPackagePriceHistoryDetails.LocalTax = -1;
                //    clsProductPackagePriceHistoryDetails.Remarks = "Based on TransferOut #: " + clsTransferOutDetails.TransferOutNo;
                //    ProductPackagePriceHistory clsProductPackagePriceHistory = new ProductPackagePriceHistory(base.Connection, base.Transaction);
                //    clsProductPackagePriceHistory.Insert(clsProductPackagePriceHistoryDetails);
                //}

                /*******************************************
                 * Add to Inventory
                 * ****************************************/
                //clsProduct.AddQuantity(lngProductID, decQuantity);
                //if (lngVariationMatrixID != 0)
                //{
                //    clsProductVariationsMatrix.AddQuantity(lngVariationMatrixID, decQuantity);
                //}
                // July 26, 2011: change the above codes to the following
                clsProduct.SubtractQuantity(clsTransferOutDetails.BranchID, lngProductID, lngVariationMatrixID, decQuantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_TRANSFER_OUT), DateTime.Now, clsTransferOutDetails.TransferOutNo, clsTransferOutDetails.TransferrerName);

                ///*******************************************
                // * Update Purchasing Information
                // * ****************************************/
                //clsProduct.UpdatePurchasing(lngProductID, clsTransferOutDetails.SupplierID, intProductUnitID, (decItemQuantity * decUnitCost) / decQuantity);
                //if (lngVariationMatrixID != 0)
                //{
                //    clsProductVariationsMatrix.UpdatePurchasing(lngVariationMatrixID, clsTransferOutDetails.SupplierID, intProductUnitID, (decItemQuantity * decUnitCost) / decQuantity);
                //}

                /*******************************************
                 * Add to Inventory Analysis
                 * ****************************************/
                clsInventoryDetails = new InventoryDetails();
                clsInventoryDetails.PostingDateFrom = clsERPConfigDetails.PostingDateFrom;
                clsInventoryDetails.PostingDateTo = clsERPConfigDetails.PostingDateTo;
                clsInventoryDetails.PostingDate = clsTransferOutDetails.DeliveryDate;
                clsInventoryDetails.ReferenceNo = clsTransferOutDetails.TransferOutNo;
                clsInventoryDetails.ContactID = clsTransferOutDetails.SupplierID;
                clsInventoryDetails.ContactCode = clsTransferOutDetails.SupplierCode;
                clsInventoryDetails.ProductID = lngProductID;
                clsInventoryDetails.ProductCode = strProductCode;
                clsInventoryDetails.VariationMatrixID = lngVariationMatrixID;
                clsInventoryDetails.MatrixDescription = strMatrixDescription;
                clsInventoryDetails.TransferOutQuantity = decQuantity;
                clsInventoryDetails.TransferOutCost = decItemCost - decVAT;
                clsInventoryDetails.TransferOutVAT = decItemCost;	// TransferOut Cost with VAT

                clsInventory.Insert(clsInventoryDetails);

                /*******************************************
				 * Added April 28, 2010 4:20PM
                 * Update Selling Information when TransferOut is posted
				 * ****************************************/
                //clsProduct.UpdateSellingIncludingAllMatrixWithSameQuantityAndUnit(lngProductID, clsTransferOutDetails.SupplierID, intProductUnitID, decimal.Parse(myReader["SellingPrice");
                //if (lngVariationMatrixID != 0)
                //{
                //    clsProductVariationsMatrix.UpdateSellingWithSameQuantityAndUnit(lngVariationMatrixID, clsPODetails.SupplierID, intProductUnitID, decimal.Parse(myReader["SellingPrice");
                //}

                /*******************************************
				 * Added April 28, 2010 4:20PM
                 * Update the purchase price history to check who has the lowest price.
				 * ****************************************/
                //ProductPurchasePriceHistoryDetails clsProductPurchasePriceHistoryDetails = new ProductPurchasePriceHistoryDetails();
                //clsProductPurchasePriceHistoryDetails.ProductID = lngProductID;
                //clsProductPurchasePriceHistoryDetails.MatrixID = lngVariationMatrixID;
                //clsProductPurchasePriceHistoryDetails.SupplierID = clsTransferOutDetails.SupplierID;
                //clsProductPurchasePriceHistoryDetails.PurchasePrice = decUnitCost;
                //clsProductPurchasePriceHistoryDetails.PurchaseDate = clsTransferOutDetails.TransferOutDate;
                //clsProductPurchasePriceHistoryDetails.Remarks = clsTransferOutDetails.TransferOutNo;
                //ProductPurchasePriceHistory clsProductPurchasePriceHistory = new ProductPurchasePriceHistory(base.Connection, base.Transaction);
                //clsProductPurchasePriceHistory.AddToList(clsProductPurchasePriceHistoryDetails);
            }

        }