Example #1
0
        public void Insert(InvAdjustmentDetails Details)
        {
            try
            {
                string SQL = "CALL procInvAdjustmentInsert(@UID, @InvAdjustmentDate, @ProductID, @ProductCode, @Description, @VariationMatrixID, " +
                                                        "@MatrixDescription, @UnitID, @UnitCode, @QuantityBefore, @QuantityNow, " +
                                                        "@MinThresholdBefore, @MinThresholdNow, @MaxThresholdBefore, @MaxThresholdNow, @Remarks);";

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

                cmd.Parameters.AddWithValue("@UID", Details.UID);
                cmd.Parameters.AddWithValue("@InvAdjustmentDate", Details.InvAdjustmentDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@ProductID", Details.ProductID);
                cmd.Parameters.AddWithValue("@ProductCode", Details.ProductCode);
                cmd.Parameters.AddWithValue("@Description", Details.Description);
                cmd.Parameters.AddWithValue("@VariationMatrixID", Details.VariationMatrixID);
                cmd.Parameters.AddWithValue("@MatrixDescription", Details.MatrixDescription);
                cmd.Parameters.AddWithValue("@UnitID", Details.UnitID);
                cmd.Parameters.AddWithValue("@UnitCode", Details.UnitCode);
                cmd.Parameters.AddWithValue("@QuantityBefore", Details.QuantityBefore);
                cmd.Parameters.AddWithValue("@QuantityNow", Details.QuantityNow);
                cmd.Parameters.AddWithValue("@MinThresholdBefore", Details.MinThresholdBefore);
                cmd.Parameters.AddWithValue("@MinThresholdNow", Details.MinThresholdNow);
                cmd.Parameters.AddWithValue("@MaxThresholdBefore", Details.MaxThresholdBefore);
                cmd.Parameters.AddWithValue("@MaxThresholdNow", Details.MaxThresholdNow);
                cmd.Parameters.AddWithValue("@Remarks", Details.Remarks);

                base.ExecuteNonQuery(cmd);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Example #2
0
        public void Insert(InvAdjustmentDetails Details)
        {
            try
            {
                string SQL = "CALL procInvAdjustmentInsert(@UID, @InvAdjustmentDate, @ProductID, @ProductCode, @Description, @VariationMatrixID, " +
                             "@MatrixDescription, @UnitID, @UnitCode, @QuantityBefore, @QuantityNow, " +
                             "@MinThresholdBefore, @MinThresholdNow, @MaxThresholdBefore, @MaxThresholdNow, @Remarks);";

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

                cmd.Parameters.AddWithValue("@UID", Details.UID);
                cmd.Parameters.AddWithValue("@InvAdjustmentDate", Details.InvAdjustmentDate.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@ProductID", Details.ProductID);
                cmd.Parameters.AddWithValue("@ProductCode", Details.ProductCode);
                cmd.Parameters.AddWithValue("@Description", Details.Description);
                cmd.Parameters.AddWithValue("@VariationMatrixID", Details.VariationMatrixID);
                cmd.Parameters.AddWithValue("@MatrixDescription", Details.MatrixDescription);
                cmd.Parameters.AddWithValue("@UnitID", Details.UnitID);
                cmd.Parameters.AddWithValue("@UnitCode", Details.UnitCode);
                cmd.Parameters.AddWithValue("@QuantityBefore", Details.QuantityBefore);
                cmd.Parameters.AddWithValue("@QuantityNow", Details.QuantityNow);
                cmd.Parameters.AddWithValue("@MinThresholdBefore", Details.MinThresholdBefore);
                cmd.Parameters.AddWithValue("@MinThresholdNow", Details.MinThresholdNow);
                cmd.Parameters.AddWithValue("@MaxThresholdBefore", Details.MaxThresholdBefore);
                cmd.Parameters.AddWithValue("@MaxThresholdNow", Details.MaxThresholdNow);
                cmd.Parameters.AddWithValue("@Remarks", Details.Remarks);

                base.ExecuteNonQuery(cmd);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Example #3
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)
			{
                // Aug 1, 2011 : Lemu
                // Remove the entire code and replaced with the code below to cater InventoryAdjustment and ProductMovement 
                // See _Product/_variationsMatrix/_List.cs.Delete
                // 
                // ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix();
                // clsProductVariationsMatrix.Delete(stIDs.Substring(0,stIDs.Length-1));
                // clsProductVariationsMatrix.SynchronizeQuantity(Convert.ToInt64(lblProductID.Text));
                // clsProductVariationsMatrix.CommitAndDispose();

                Security.AccessUserDetails clsAccessUserDetails = (Security.AccessUserDetails)Session["AccessUserDetails"];
                ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix();
                clsProductVariationsMatrix.GetConnection();

                Products clsProducts = new Products(clsProductVariationsMatrix.Connection, clsProductVariationsMatrix.Transaction);

                long ProductID = Int64.Parse(lblProductID.Text);

                string[] strIDs = stIDs.Substring(0, stIDs.Length - 1).Split(',');
                foreach (string ID in strIDs)
                {
                    long MatrixID = long.Parse(ID);
                    ProductDetails clsDetails = clsProducts.Details(ProductID: ProductID, MatrixID: MatrixID);

                    InvAdjustmentDetails clsInvAdjustmentDetails = new InvAdjustmentDetails();
                    clsInvAdjustmentDetails.UID = clsAccessUserDetails.UID;
                    clsInvAdjustmentDetails.InvAdjustmentDate = DateTime.Now;
                    clsInvAdjustmentDetails.ProductID = clsDetails.ProductID;
                    clsInvAdjustmentDetails.ProductCode = clsDetails.ProductCode;
                    clsInvAdjustmentDetails.Description = clsDetails.ProductDesc;
                    clsInvAdjustmentDetails.VariationMatrixID = clsDetails.MatrixID;
                    clsInvAdjustmentDetails.MatrixDescription = clsDetails.MatrixDescription;
                    clsInvAdjustmentDetails.UnitID = clsDetails.BaseUnitID;
                    clsInvAdjustmentDetails.UnitCode = clsDetails.BaseUnitCode;
                    clsInvAdjustmentDetails.QuantityBefore = clsDetails.Quantity;
                    clsInvAdjustmentDetails.QuantityNow = 0;
                    clsInvAdjustmentDetails.MinThresholdBefore = clsDetails.MinThreshold;
                    clsInvAdjustmentDetails.MinThresholdNow = 0;
                    clsInvAdjustmentDetails.MaxThresholdBefore = clsDetails.MaxThreshold;
                    clsInvAdjustmentDetails.MaxThresholdNow = 0;
                    clsInvAdjustmentDetails.Remarks = "deleted item.";

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

                    clsProducts.SubtractQuantity(Constants.BRANCH_ID_MAIN, clsDetails.ProductID, clsDetails.MatrixID, clsDetails.Quantity, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_PRODUCT_VARIATION_DELETE) + " : " + clsDetails.MatrixDescription, clsInvAdjustmentDetails.InvAdjustmentDate, "SYS-VARDEL" + clsInvAdjustmentDetails.InvAdjustmentDate.ToString("yyyyMMddHHmmss"), clsAccessUserDetails.Name);

                    clsProductVariationsMatrix.Delete(long.Parse(ID));
                }
                clsProductVariationsMatrix.CommitAndDispose();
			}

			return boRetValue;
		}
Example #4
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 { }
        }
		private void SaveRecord()
		{
            Security.AccessUserDetails clsDetails = (Security.AccessUserDetails)Session["AccessUserDetails"];
            DateTime dteChangeDate = DateTime.Now;

            Products clsProduct = new Products();
            clsProduct.GetConnection();

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

            long lngProductID = long.Parse(cboProductCode.SelectedValue);

            if (lstVariationMatrix.Items.Count > 0)
            {
                ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(clsProduct.Connection, clsProduct.Transaction);
                foreach (DataListItem e in lstVariationMatrix.Items)
                {
                    HtmlInputCheckBox chkMatrixID = (HtmlInputCheckBox)e.FindControl("chkMatrixID");
                    Label lblVariationDesc = (Label)e.FindControl("lblVariationDesc");
                    Label lblUnitNameMatrix = (Label)e.FindControl("lblUnitCode");
                    TextBox txtQuantityBeforeMatrix = (TextBox)e.FindControl("txtQuantityBefore");
                    //TextBox txtDifferenceMatrix = (TextBox)e.FindControl("txtDifference");
                    TextBox txtQuantityNowMatrix = (TextBox)e.FindControl("txtQuantityNow");
                    TextBox txtMinThresholdMatrix = (TextBox)e.FindControl("txtMinThreshold");
                    TextBox txtMaxThresholdMatrix = (TextBox)e.FindControl("txtMaxThreshold");

                    decimal decQuantityBeforeMatrix = decimal.Parse(txtQuantityBeforeMatrix.Text);
                    //decimal decDifferenceMatrix = decimal.Parse(txtDifference.Text);
                    decimal decQuantityNowMatrix = decimal.Parse(txtQuantityNowMatrix.Text);
                    decimal decMinThresholdMatrixBefore = decimal.Parse(txtMinThresholdMatrix.ToolTip);
                    decimal decMinThresholdMatrixNow = decimal.Parse(txtMinThresholdMatrix.Text);
                    decimal decMaxThresholdMatrixBefore = decimal.Parse(txtMaxThresholdMatrix.ToolTip);
                    decimal decMaxThresholdMatrixNow = decimal.Parse(txtMaxThresholdMatrix.Text);

                    if (decQuantityBeforeMatrix != decQuantityNowMatrix || decMinThresholdMatrixBefore != decMinThresholdMatrixNow || decMaxThresholdMatrixBefore != decMaxThresholdMatrixNow)
                    {
                        clsInvAdjustmentDetails = new InvAdjustmentDetails();
                        clsInvAdjustmentDetails.UID = clsDetails.UID;
                        clsInvAdjustmentDetails.InvAdjustmentDate = dteChangeDate;
                        clsInvAdjustmentDetails.ProductID = long.Parse(cboProductCode.SelectedValue);
                        clsInvAdjustmentDetails.ProductCode = cboProductCode.SelectedItem.Text;
                        clsInvAdjustmentDetails.Description = cboProductCode.SelectedItem.Text;
                        clsInvAdjustmentDetails.VariationMatrixID = long.Parse(chkMatrixID.Value);
                        clsInvAdjustmentDetails.MatrixDescription = lblVariationDesc.Text;
                        clsInvAdjustmentDetails.UnitID = int.Parse(lblUnitNameMatrix.ToolTip);
                        clsInvAdjustmentDetails.UnitCode = lblUnitNameMatrix.Text;
                        clsInvAdjustmentDetails.QuantityBefore = decQuantityBeforeMatrix;
                        clsInvAdjustmentDetails.QuantityNow = decQuantityNowMatrix;
                        clsInvAdjustmentDetails.MinThresholdBefore = decMinThresholdMatrixBefore;
                        clsInvAdjustmentDetails.MinThresholdNow = decMinThresholdMatrixNow;
                        clsInvAdjustmentDetails.MaxThresholdBefore = decMaxThresholdMatrixBefore;
                        clsInvAdjustmentDetails.MaxThresholdNow = decMaxThresholdMatrixNow;
                        clsInvAdjustmentDetails.Remarks = txtRemarks.Text;
                        clsInvAdjustment.Insert(clsInvAdjustmentDetails);

                        if (decQuantityBeforeMatrix > decQuantityNowMatrix)
                        { clsProduct.UpdateInvDetails(int.Parse(cboBranch.SelectedItem.Value), lngProductID, long.Parse(chkMatrixID.Value), decQuantityNowMatrix, decMinThresholdMatrixNow, decMaxThresholdMatrixNow, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.DEDUCT_INVENTORY_ADJUSTMENT), dteChangeDate, "SYS-ADJ" + dteChangeDate.ToString("yyyyMMddHHmmss"), clsDetails.Name); }
                        else if (decQuantityBeforeMatrix < decQuantityNowMatrix)
                        { clsProduct.UpdateInvDetails(int.Parse(cboBranch.SelectedItem.Value), lngProductID, long.Parse(chkMatrixID.Value), decQuantityNowMatrix, decMinThresholdMatrixNow, decMaxThresholdMatrixNow, Products.getPRODUCT_INVENTORY_MOVEMENT_VALUE(PRODUCT_INVENTORY_MOVEMENT.ADD_INVENTORY_ADJUSTMENT), dteChangeDate, "SYS-ADJ" + dteChangeDate.ToString("yyyyMMddHHmmss"), clsDetails.Name); }

                    }
                }
            }
            clsProduct.CommitAndDispose();

		}
Example #6
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;
		}