Example #1
0
        protected void imgProductQuickAdd_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(txtProductCode.Text))
                {
                    ProductDetails clsDetails = new ProductDetails();

                    clsDetails.ProductCode = txtProductCode.Text;
                    clsDetails.BarCode = txtProductCode.Text;
                    clsDetails.ProductDesc = txtProductCode.Text;
                    clsDetails.ProductGroupID = ProductGroup.DEFAULT_GROUP_ID;
                    clsDetails.ProductSubGroupID = ProductSubGroup.DEFAULT_SUB_GROUP_ID;
                    clsDetails.BaseUnitID = Data.Unit.DEFAULT_UNIT_ID;
                    clsDetails.Price = 0;
                    clsDetails.PurchasePrice = 0;
                    clsDetails.IncludeInSubtotalDiscount = true;
                    clsDetails.VAT = Constants.DEFAULTS_VAT;
                    clsDetails.EVAT = 0;
                    clsDetails.LocalTax = 0;
                    clsDetails.Quantity = 0;
                    clsDetails.MinThreshold = 0;
                    clsDetails.MaxThreshold = 0;
                    clsDetails.SupplierID = Contacts.DEFAULT_SUPPLIER_ID;
                    clsDetails.IsItemSold = true;
                    clsDetails.WillPrintProductComposition = false;

                    Products clsProduct = new Products();
                    long id = clsProduct.Insert(clsDetails);
                    clsDetails.ProductID = id;

                    long lngUID = long.Parse(Session["UID"].ToString());
                    InvAdjustmentDetails clsInvAdjustmentDetails = new InvAdjustmentDetails();
                    clsInvAdjustmentDetails.UID = lngUID;
                    clsInvAdjustmentDetails.InvAdjustmentDate = DateTime.Now;
                    clsInvAdjustmentDetails.ProductID = id;
                    clsInvAdjustmentDetails.ProductCode = clsDetails.ProductCode;
                    clsInvAdjustmentDetails.Description = clsDetails.ProductDesc;
                    clsInvAdjustmentDetails.VariationMatrixID = 0;
                    clsInvAdjustmentDetails.MatrixDescription = null;
                    clsInvAdjustmentDetails.UnitID = clsDetails.BaseUnitID;
                    clsInvAdjustmentDetails.UnitCode = cboProductUnit.SelectedItem.Text;
                    clsInvAdjustmentDetails.QuantityBefore = 0;
                    clsInvAdjustmentDetails.QuantityNow = clsDetails.Quantity;
                    clsInvAdjustmentDetails.MinThresholdBefore = 0;
                    clsInvAdjustmentDetails.MinThresholdNow = clsDetails.MinThreshold;
                    clsInvAdjustmentDetails.MaxThresholdBefore = 0;
                    clsInvAdjustmentDetails.MaxThresholdNow = clsDetails.MaxThreshold;
                    clsInvAdjustmentDetails.Remarks = "newly added. beginning balance.";

                    InvAdjustment clsInvAdjustment = new InvAdjustment(clsProduct.Connection, clsProduct.Transaction);
                    clsInvAdjustment.Insert(clsInvAdjustmentDetails);

                    clsProduct.InheritSubGroupVariations(clsDetails.ProductSubGroupID, clsDetails.ProductID);

                    clsProduct.CommitAndDispose();

                    cmdProductCode_Click(null, null);
                }
            }
            catch { }
        }
Example #2
0
		private Int64 SaveRecord()
		{
			ProductDetails clsDetails = new ProductDetails();

			clsDetails.ProductCode  = txtProductCode.Text;
			clsDetails.BarCode  = txtBarcode.Text;
            clsDetails.BarCode2 = txtBarcode2.Text;
            clsDetails.BarCode3 = txtBarcode3.Text;
			clsDetails.ProductDesc = txtProductDesc.Text;
			clsDetails.ProductGroupID = Convert.ToInt64(cboProductGroup.SelectedItem.Value); 
			clsDetails.ProductSubGroupID  = Convert.ToInt64(cboProductSubGroup.SelectedItem.Value);
			clsDetails.BaseUnitID = Convert.ToInt32(cboProductUnit.SelectedItem.Value); 
			clsDetails.Price = Convert.ToDecimal(txtProductPrice.Text);
            clsDetails.WSPrice = Convert.ToDecimal(txtWSPrice.Text); 
			clsDetails.PurchasePrice = Convert.ToDecimal(txtPurchasePrice.Text);
            clsDetails.PercentageCommision = Convert.ToDecimal(txtPercentageCommision.Text);
            clsDetails.IncludeInSubtotalDiscount = chkIncludeInSubtotalDiscount.Checked; 
			clsDetails.VAT = Convert.ToDecimal(txtVAT.Text); 
			clsDetails.EVAT = Convert.ToDecimal(txtEVAT.Text); 
			clsDetails.LocalTax = Convert.ToDecimal(txtLocalTax.Text); 
			clsDetails.Quantity = Convert.ToDecimal(txtQuantity.Text);
			clsDetails.MinThreshold = Convert.ToDecimal(txtMinThreshold.Text);
			clsDetails.MaxThreshold = Convert.ToDecimal(txtMaxThreshold.Text);
			clsDetails.SupplierID = Convert.ToInt64(cboSupplier.SelectedItem.Value);
            clsDetails.IsItemSold = Convert.ToBoolean(chkIsItemSold.Checked);
            clsDetails.WillPrintProductComposition = Convert.ToBoolean(chkWillPrintProductComposition.Checked);
            
			Products clsProduct = new Products();
			Int64 id = clsProduct.Insert(clsDetails);
			clsDetails.ProductID = id;

            long lngUID = long.Parse(Session["UID"].ToString());
            InvAdjustmentDetails clsInvAdjustmentDetails = new InvAdjustmentDetails();
            clsInvAdjustmentDetails.UID = lngUID;
            clsInvAdjustmentDetails.InvAdjustmentDate = DateTime.Now;
            clsInvAdjustmentDetails.ProductID = id;
            clsInvAdjustmentDetails.ProductCode = clsDetails.ProductCode;
            clsInvAdjustmentDetails.Description = clsDetails.ProductDesc;
            clsInvAdjustmentDetails.VariationMatrixID = 0;
            clsInvAdjustmentDetails.MatrixDescription = null;
            clsInvAdjustmentDetails.UnitID = clsDetails.BaseUnitID;
            clsInvAdjustmentDetails.UnitCode = cboProductUnit.SelectedItem.Text;
            clsInvAdjustmentDetails.QuantityBefore = 0;
            clsInvAdjustmentDetails.QuantityNow = clsDetails.Quantity;
            clsInvAdjustmentDetails.MinThresholdBefore = 0;
            clsInvAdjustmentDetails.MinThresholdNow = clsDetails.MinThreshold;
            clsInvAdjustmentDetails.MaxThresholdBefore = 0;
            clsInvAdjustmentDetails.MaxThresholdNow = clsDetails.MaxThreshold;
            clsInvAdjustmentDetails.Remarks = "newly added. beginning balance.";

            InvAdjustment clsInvAdjustment = new InvAdjustment(clsProduct.Connection, clsProduct.Transaction);
            clsInvAdjustment.Insert(clsInvAdjustmentDetails);

			if (chkVariations.Checked == true)
			{
				clsProduct.InheritSubGroupVariations(clsDetails.ProductSubGroupID, clsDetails.ProductID);
			}

			if (chkVariationsMatrix.Checked == true)
			{
				if (chkVariations.Checked == false)
				{
					clsProduct.InheritSubGroupVariations(clsDetails.ProductSubGroupID, clsDetails.ProductID);
				}
				clsProduct.InheritSubGroupVariationsMatrix(clsDetails.ProductSubGroupID, clsDetails.ProductID, clsDetails);
			}
			if (chkUnitMatrix.Checked == true)
			{
				clsProduct.InheritSubGroupUnitMatrix(clsDetails.ProductSubGroupID, clsDetails.ProductID);
			}

            // Aug 26, 2011 : Lemu
            // Update Required Inventory Days (RID)
            clsDetails.RID = Convert.ToInt64(txtRID.Text);
            clsProduct.UpdateRID(clsDetails.ProductID, clsDetails.RID);

			clsProduct.CommitAndDispose();

			return 0;
		}