/// <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);
			}	
		}
示例#2
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;
            }
		}
		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);
			}	
		}