Ejemplo n.º 1
0
        protected void imgVariationQuickAdd_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            try 
            {
                if (!string.IsNullOrEmpty(txtVariation.Text))
                {
                    DateTime dteExpiration = Constants.C_DATE_MIN_VALUE;
                    string LotNo = "";

                    if (Session[Constants.SYS_CONFIG_BACKEND_VARIATION_TYPE].ToString() == Constants.SYS_CONFIG_BACKEND_VARIATION_TYPE_EXPIRATION_LOTNO)
                    {
                        string javaScript = "";
                        string[] variation = txtVariation.Text.Split(';');
                        
                        if (!DateTime.TryParse(variation[0], out dteExpiration))
                        {
                            javaScript = "window.alert('Please enter a valid expiration date in YYYY-MM-DD format. Variation format must be: EXPIRATION;LOTNO');";
                            System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.updPrint, this.updPrint.GetType(), "openwindow", javaScript, true);
                            return;
                        }
                        if (variation.Length == 1)
                        {
                            javaScript = "window.alert('Please enter a valid LOTNO, it must not be blank. If there is no LOTNO please enter NA.');";
                            System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.updPrint, this.updPrint.GetType(), "openwindow", javaScript, true);
                            return;
                        }
                        
                        LotNo = variation[1];
                        if (string.IsNullOrEmpty(LotNo))
                        {
                            javaScript = "window.alert('Please enter a valid LOTNO, it must not be blank. If there is no LOTNO please enter NA.');";
                            System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.updPrint, this.updPrint.GetType(), "openwindow", javaScript, true);
                            return;
                        }
                        
                    }
                    long lngProdductID = long.Parse(cboProductCode.SelectedItem.Value);

                    Security.AccessUserDetails clsAccessUserDetails = (Security.AccessUserDetails)Session["AccessUserDetails"];
                    ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix();
                    long lngMatrixID = clsProductVariationsMatrix.InsertBaseVariationEasy(long.Parse(cboProductCode.SelectedItem.Value), txtVariation.Text, clsAccessUserDetails.Name);

                    if (Session[Constants.SYS_CONFIG_BACKEND_VARIATION_TYPE].ToString() == Constants.SYS_CONFIG_BACKEND_VARIATION_TYPE_EXPIRATION_LOTNO)
                    {
                        ProductVariationsMatrixDetails clsDetails;
                        clsDetails = new ProductVariationsMatrixDetails();
                        clsDetails.MatrixID = lngMatrixID;
                        clsDetails.ProductID = lngProdductID;

                        // save the expiration
                        clsDetails.VariationID = long.Parse(CONSTANT_VARIATIONS.EXPIRATION.ToString("d"));
                        clsDetails.Description = dteExpiration.ToString("yyyy-MM-dd");
                        clsProductVariationsMatrix.SaveVariation(clsDetails);

                        // save the lotno
                        clsDetails.VariationID = long.Parse(CONSTANT_VARIATIONS.LOTNO.ToString("d"));
                        clsDetails.Description = LotNo;
                        clsProductVariationsMatrix.SaveVariation(clsDetails);
                    }
                    clsProductVariationsMatrix.CommitAndDispose();

                    cmdVariationSearch_Click(null, null);
                }
            }
            catch{}
        }
Ejemplo n.º 2
0
		private void Upload()
		{
			if( ( txtPath.PostedFile != null ) && ( txtPath.PostedFile.ContentLength > 0 ) )
			{
				string fn = System.IO.Path.GetFileName(txtPath.PostedFile.FileName);
				string SaveLocation = "/RetailPlus/temp/uploaded_" + fn;

				txtPath.PostedFile.SaveAs(SaveLocation);
				XmlTextReader reader = new XmlTextReader(SaveLocation);
				reader.WhitespaceHandling = WhitespaceHandling.None;

				Stock clsStock = new Stock();
				clsStock.GetConnection();

				string strStockTransactionNo = null;
				long StockID = 0;
				long ContactID = 0;
				int UnitID = 0;
				long ProductGroupID = 0;
				long ProductSubGroupID = 0;
				long ProductID = 0;
				long ProductBaseMatrixID = 0;

				VariationDetails clsVariationDetails;
				int VariationID = 0;

				StockItemDetails clsStockItemDetails = new StockItemDetails();

				while (reader.Read()) 
				{
					switch (reader.NodeType) 
					{
						case XmlNodeType.Element:
							if (reader.Name == "Stock") 
							{
								strStockTransactionNo = reader.GetAttribute("TransactionNo");

								StockID = clsStock.Details(reader.GetAttribute("TransactionNo")).StockID;
								if (StockID > 0)
								{
									clsStock.CommitAndDispose();
									Label1.Text = "<b>This file has already been added to inventory.<br />";
									Label1.Text += "Please refer to transaction No: " + strStockTransactionNo + ".</b>";
									reader.Close();
									return;
								}
								Contacts clsContact = new Contacts(clsStock.Connection, clsStock.Transaction);
								ContactID = clsContact.Details(reader.GetAttribute("ContactCode")).ContactID;
								if (ContactID == 0)
								{
									ContactDetails clsContactDetails = new ContactDetails();
									clsContactDetails.ContactCode = reader.GetAttribute("ContactCode");
									clsContactDetails.ContactName = reader.GetAttribute("ContactName");
									clsContactDetails.ContactGroupID = Convert.ToInt32(reader.GetAttribute("ContactGroupID"));
                                    clsContactDetails.ModeOfTerms = (ModeOfTerms)Enum.Parse(typeof(ModeOfTerms), reader.GetAttribute("ModeOfTerms"));
									clsContactDetails.Terms = Convert.ToInt32(reader.GetAttribute("Terms"));
									clsContactDetails.Address = reader.GetAttribute("Address");
									clsContactDetails.BusinessName = reader.GetAttribute("BusinessName");
									clsContactDetails.TelephoneNo = reader.GetAttribute("TelephoneNo");
									clsContactDetails.Remarks = reader.GetAttribute("Remarks");
									clsContactDetails.Debit = Convert.ToDecimal(reader.GetAttribute("Debit"));
									clsContactDetails.Credit = Convert.ToDecimal(reader.GetAttribute("Credit"));
									clsContactDetails.IsCreditAllowed = Convert.ToBoolean(reader.GetAttribute("IsCreditAllowed"));
									clsContactDetails.CreditLimit = Convert.ToDecimal(reader.GetAttribute("CreditLimit"));
									ContactID = clsContact.Insert(clsContactDetails);
								}

                                StockDetails clsStockDetails = new StockDetails();
								clsStockDetails.TransactionNo = reader.GetAttribute("TransactionNo");
								clsStockDetails.StockTypeID = Convert.ToInt16(Constants.STOCK_TYPE_TRANSFER_FROM_BRANCH_ID);
								clsStockDetails.StockDate = DateTime.Now;
								clsStockDetails.SupplierID = ContactID;
								clsStockDetails.Remarks = reader.GetAttribute("StockRemarks") + Environment.NewLine + "Original Stock Date: " + reader.GetAttribute("StockDate");
								
								StockItemDetails[] itemDetails = new StockItemDetails[0];
								clsStockDetails.StockItems = itemDetails;

								StockID = clsStock.Insert(clsStockDetails);
							}
							else if (reader.Name == "Item") 
							{
								Data.Unit clsUnit = new Data.Unit(clsStock.Connection, clsStock.Transaction);
								UnitID = clsUnit.Details(reader.GetAttribute("ProductUnitCode")).UnitID;
								if (UnitID == 0) 
								{
									UnitDetails clsUnitDetails = new UnitDetails();
									clsUnitDetails.UnitCode = reader.GetAttribute("ProductUnitCode");
									clsUnitDetails.UnitName = reader.GetAttribute("ProductUnitName");
									UnitID = clsUnit.Insert(clsUnitDetails);
								}

								ProductGroup clsProductGroup = new ProductGroup(clsStock.Connection, clsStock.Transaction);
								ProductGroupID = clsProductGroup.Details(reader.GetAttribute("ProductGroupCode")).ProductGroupID;
								if (ProductGroupID == 0) 
								{
									Label1.Text += "inserting product group....";
									ProductGroupDetails clsProductGroupDetails = new ProductGroupDetails();
									clsProductGroupDetails.ProductGroupCode = reader.GetAttribute("ProductGroupCode");
									clsProductGroupDetails.ProductGroupName = reader.GetAttribute("ProductGroupName");
                                    clsProductGroupDetails.UnitDetails = new UnitDetails
                                    {
                                        UnitID = UnitID
                                    };
									clsProductGroupDetails.Price = Convert.ToDecimal(reader.GetAttribute("Price"));
									clsProductGroupDetails.PurchasePrice = Convert.ToDecimal(reader.GetAttribute("PurchasePrice"));
									clsProductGroupDetails.IncludeInSubtotalDiscount = Convert.ToBoolean(reader.GetAttribute("IncludeInSubtotalDiscount"));
									clsProductGroupDetails.VAT = Convert.ToDecimal(reader.GetAttribute("VAT"));
									clsProductGroupDetails.EVAT = Convert.ToDecimal(reader.GetAttribute("EVAT"));
									clsProductGroupDetails.LocalTax = Convert.ToDecimal(reader.GetAttribute("LocalTax"));
									ProductGroupID = clsProductGroup.Insert(clsProductGroupDetails);
								}
								
								ProductSubGroup clsProductSubGroup = new ProductSubGroup(clsStock.Connection, clsStock.Transaction);
								ProductSubGroupID = clsProductSubGroup.Details(reader.GetAttribute("ProductSubGroupCode")).ProductSubGroupID;
								if (ProductSubGroupID == 0) 
								{
									Label1.Text += "inserting product sub-group....";
									ProductSubGroupDetails clsProductSubGroupDetails = new ProductSubGroupDetails();
									clsProductSubGroupDetails.ProductGroupID = ProductGroupID;
									clsProductSubGroupDetails.ProductSubGroupCode = reader.GetAttribute("ProductSubGroupCode");
									clsProductSubGroupDetails.ProductSubGroupName = reader.GetAttribute("ProductSubGroupName");
									clsProductSubGroupDetails.BaseUnitID = UnitID;
									clsProductSubGroupDetails.Price = Convert.ToDecimal(reader.GetAttribute("Price"));
									clsProductSubGroupDetails.PurchasePrice = Convert.ToDecimal(reader.GetAttribute("PurchasePrice"));
									clsProductSubGroupDetails.IncludeInSubtotalDiscount = Convert.ToBoolean(reader.GetAttribute("IncludeInSubtotalDiscount"));
									clsProductSubGroupDetails.VAT = Convert.ToDecimal(reader.GetAttribute("VAT"));
									clsProductSubGroupDetails.EVAT = Convert.ToDecimal(reader.GetAttribute("EVAT"));
									clsProductSubGroupDetails.LocalTax = Convert.ToDecimal(reader.GetAttribute("LocalTax"));
									ProductSubGroupID = clsProductSubGroup.Insert(clsProductSubGroupDetails);
								}

								Products clsProduct = new Products(clsStock.Connection, clsStock.Transaction);
                                ProductID = clsProduct.Details(reader.GetAttribute("BarCode")).ProductID;
								if (ProductID == 0) 
								{
									Label1.Text += "inserting product....";
									ProductDetails clsProductDetails = new ProductDetails();
									clsProductDetails.ProductCode  = reader.GetAttribute("ProductCode");
									clsProductDetails.BarCode  = reader.GetAttribute("BarCode");
									clsProductDetails.ProductDesc = reader.GetAttribute("ProductDesc");
									clsProductDetails.ProductGroupID = ProductGroupID; 
									clsProductDetails.ProductSubGroupID  = ProductSubGroupID;
									clsProductDetails.ProductDesc  = reader.GetAttribute("ProductDesc");
									clsProductDetails.BaseUnitID = UnitID;
									clsProductDetails.Price = Convert.ToDecimal(reader.GetAttribute("Price")); 
									clsProductDetails.PurchasePrice = Convert.ToDecimal(reader.GetAttribute("PurchasePrice")); 
									clsProductDetails.IncludeInSubtotalDiscount = Convert.ToBoolean(reader.GetAttribute("IncludeInSubtotalDiscount")); 
									clsProductDetails.VAT = Convert.ToDecimal(reader.GetAttribute("VAT")); 
									clsProductDetails.EVAT = Convert.ToDecimal(reader.GetAttribute("EVAT")); 
									clsProductDetails.LocalTax = Convert.ToDecimal(reader.GetAttribute("LocalTax")); 
									clsProductDetails.Quantity = 0;
									clsProductDetails.MinThreshold = Convert.ToDecimal(reader.GetAttribute("MinThreshold"));
									clsProductDetails.MaxThreshold = Convert.ToDecimal(reader.GetAttribute("MaxThreshold"));
									clsProductDetails.SupplierID = Contacts.DEFAULT_SUPPLIER_ID;
									ProductID = clsProduct.Insert(clsProductDetails);
								}

                                //ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(clsStock.Connection, clsStock.Transaction);
                                //ProductBaseMatrixID = clsProductVariationsMatrix.BaseDetails(0, 0, ProductID, reader["ItemBaseVariationDescription"].ToString()).MatrixID;
                                //if (ProductBaseMatrixID == 0)
                                //{
                                //    ProductBaseMatrixDetails clsBaseDetails = new ProductBaseMatrixDetails();
                                //    clsBaseDetails.ProductID = ProductID;
                                //    clsBaseDetails.Description = reader.GetAttribute("ItemBaseVariationDescription");
                                //    clsBaseDetails.UnitID = UnitID;
                                //    clsBaseDetails.Price = Convert.ToDecimal(reader.GetAttribute("Price"));
                                //    clsBaseDetails.PurchasePrice = Convert.ToDecimal(reader.GetAttribute("PurchasePrice"));
                                //    clsBaseDetails.IncludeInSubtotalDiscount = Convert.ToBoolean(reader.GetAttribute("IncludeInSubtotalDiscount"));
                                //    clsBaseDetails.Quantity = 0;
                                //    clsBaseDetails.VAT = Convert.ToDecimal(reader.GetAttribute("VAT"));
                                //    clsBaseDetails.EVAT = Convert.ToDecimal(reader.GetAttribute("EVAT"));
                                //    clsBaseDetails.LocalTax = Convert.ToDecimal(reader.GetAttribute("LocalTax"));
                                //    clsBaseDetails.MinThreshold = Convert.ToDecimal(reader.GetAttribute("MinThreshold"));
                                //    clsBaseDetails.MaxThreshold = Convert.ToDecimal(reader.GetAttribute("MaxThreshold"));
                                //    ProductBaseMatrixID = clsProductVariationsMatrix.InsertBaseVariation(clsBaseDetails);
                                //    clsBaseDetails.MatrixID = ProductBaseMatrixID;
                                //}

								clsStockItemDetails = new StockItemDetails();
								clsStockItemDetails.StockID = StockID;
								clsStockItemDetails.ProductID = ProductID;
								clsStockItemDetails.VariationMatrixID = ProductBaseMatrixID;
								clsStockItemDetails.ProductUnitID = UnitID;
								clsStockItemDetails.StockTypeID = Convert.ToInt16(Constants.STOCK_TYPE_TRANSFER_FROM_BRANCH_ID);
								clsStockItemDetails.StockDate = DateTime.Now;
								clsStockItemDetails.Quantity = Convert.ToDecimal(reader.GetAttribute("ItemQuantity"));
								clsStockItemDetails.Remarks = reader.GetAttribute("ItemRemarks");

                                Security.AccessUserDetails clsAccessUserDetails = (Security.AccessUserDetails)Session["AccessUserDetails"];
                                clsStock.AddItem(Constants.BRANCH_ID_MAIN, strStockTransactionNo, clsAccessUserDetails.Name, clsStockItemDetails, StockDirections.Increment);
							}
							else if (reader.Name == "Variation" && reader.GetAttribute("VariationCode") != null)
							{
								Variation clsVariation = new Variation(clsStock.Connection, clsStock.Transaction);
								VariationID = clsVariation.Details(reader.GetAttribute("VariationCode")).VariationID;
								if (VariationID == 0 ) 
								{	
									clsVariationDetails = new VariationDetails();
									clsVariationDetails.VariationCode = reader.GetAttribute("VariationCode");
									clsVariationDetails.VariationType = reader.GetAttribute("VariationType");
									VariationID = clsVariation.Insert(clsVariationDetails);
								}

								ProductVariationDetails clsProductVariationDetails = new ProductVariationDetails();
								clsProductVariationDetails.ProductID = ProductID;
								clsProductVariationDetails.VariationID = VariationID;

								ProductVariations clsProductVariation = new ProductVariations(clsStock.Connection, clsStock.Transaction);
								if (clsProductVariation.isExist(clsProductVariationDetails) == false)
								{
									long ProductVariationID = clsProductVariation.Insert(clsProductVariationDetails);
								}

							}
							else if (reader.Name == "VariationMatrix" && reader.GetAttribute("VariationCode") != null)
							{
								Variation clsVariation = new Variation(clsStock.Connection, clsStock.Transaction);
								VariationID = clsVariation.Details(reader.GetAttribute("VariationCode")).VariationID;
								if (VariationID == 0) 
								{
									clsVariationDetails = new VariationDetails();
									clsVariationDetails.VariationCode = reader.GetAttribute("VariationCode");
									clsVariationDetails.VariationType = reader.GetAttribute("VariationType");
									VariationID = clsVariation.Insert(clsVariationDetails);
								}

								ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(clsStock.Connection, clsStock.Transaction);
								if (clsProductVariationsMatrix.isExist(ProductBaseMatrixID, VariationID) == false)
								{
									ProductVariationsMatrixDetails clsProductVariationsMatrixDetails = new ProductVariationsMatrixDetails();
                                    clsProductVariationsMatrixDetails.ProductID = ProductID;
                                    clsProductVariationsMatrixDetails.MatrixID = ProductBaseMatrixID;
									clsProductVariationsMatrixDetails.VariationID = VariationID;
									clsProductVariationsMatrixDetails.Description = reader.GetAttribute("Description");
									clsProductVariationsMatrix.SaveVariation(clsProductVariationsMatrixDetails);
								}
							}
							else
							{
								Label1.Text = "<b>Reader Name:<b>" + reader.Name + "<br />";
							}
							break;
						case XmlNodeType.Text:
							Label1.Text = "<b>" + reader.LocalName + ":<b>" + reader.Value + "<br />";
							break;
					}       
				}
				reader.Close();
				
				clsStock.CommitAndDispose();
				Label1.Text = "<b>Transaction No.: " + strStockTransactionNo + " has been successfully transferred.<br />";
			}
			else
			{
				Response.Write("Please select a file to upload.");
			}

		}
Ejemplo n.º 3
0
		private bool InsertVariation(ProductVariationsMatrixDetails Details)
		{
			try 
			{
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
				
				string SQL = "INSERT INTO tblProductVariationsMatrix (ProductID, MatrixID, VariationID, Description) VALUES (@ProductID, @MatrixID, @VariationID, @Description);";

                cmd.Parameters.AddWithValue("@ProductID", Details.ProductID);
                cmd.Parameters.AddWithValue("@MatrixID", Details.MatrixID);
                cmd.Parameters.AddWithValue("@VariationID", Details.VariationID);
                cmd.Parameters.AddWithValue("@Description", Details.Description);

                cmd.CommandText = SQL;
				base.ExecuteNonQuery(cmd);
				
				return true;
			}
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Ejemplo n.º 4
0
		private bool SaveRecord()
		{
            foreach (DataListItem item in lstItem.Items)
            {
                HyperLink lnkVariationType = (HyperLink)item.FindControl("lnkVariationType");

                if (lnkVariationType.Text.ToUpper() == CONSTANT_VARIATIONS.EXPIRATION.ToString("G"))
                {
                    TextBox txtDescription = (TextBox)item.FindControl("txtDescription");
                    try
                    {
                        DateTime Expiry = DateTime.Parse(txtDescription.Text);
                    }
                    catch
                    {
                        string javaScript = "window.alert('Please enter a valid expiration date in YYYY-MM-DD format.');";
                        System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.updSave, this.updSave.GetType(), "openwindow", javaScript, true);

                        return false;
                    }
                }
            }

            string stringVariationDesc = null;
            foreach (DataListItem item in lstItem.Items)
            {
                HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList");
                TextBox txtDescription = (TextBox)item.FindControl("txtDescription");
                stringVariationDesc += txtDescription.Text + "; ";
            }

            Security.AccessUserDetails clsAccessUserDetails = (Security.AccessUserDetails)Session["AccessUserDetails"];

			ProductBaseVariationsMatrixDetails clsBaseDetails = new ProductBaseVariationsMatrixDetails();
			ProductVariationsMatrixDetails clsDetails;
			ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix();

            ProductDetails clsProductDetails = new Products(clsProductVariationsMatrix.Connection, clsProductVariationsMatrix.Transaction).Details(Int64.Parse(lblProductID.Text));

			clsBaseDetails.ProductID = Convert.ToInt64(lblProductID.Text);
            clsBaseDetails.BarCode1 = txtBarcode.Text;
            clsBaseDetails.BarCode2 = txtBarcode2.Text;
            clsBaseDetails.BarCode3 = txtBarcode3.Text;
            clsBaseDetails.Description = stringVariationDesc;
			clsBaseDetails.UnitID = Convert.ToInt32(cboUnit.SelectedItem.Value);
            clsBaseDetails.Price = Convert.ToDecimal(txtProductPrice.Text);
            clsBaseDetails.Price1 = Convert.ToDecimal(txtPrice1.Text);
            clsBaseDetails.Price2 = Convert.ToDecimal(txtPrice2.Text);
            clsBaseDetails.Price3 = Convert.ToDecimal(txtPrice3.Text);
            clsBaseDetails.Price4 = Convert.ToDecimal(txtPrice4.Text);
            clsBaseDetails.Price5 = Convert.ToDecimal(txtPrice5.Text);
            clsBaseDetails.WSPrice = Convert.ToDecimal(txtWSPrice.Text);
            clsBaseDetails.WSPrice = Convert.ToDecimal(txtWSPrice.Text); 
            clsBaseDetails.PurchasePrice = Convert.ToDecimal(txtPurchasePrice.Text);
			clsBaseDetails.IncludeInSubtotalDiscount = chkIncludeInSubtotalDiscount.Checked;
			clsBaseDetails.Quantity = Convert.ToDecimal(txtQuantity.Text);
			clsBaseDetails.VAT = Convert.ToDecimal(txtVAT.Text);
			clsBaseDetails.EVAT = Convert.ToDecimal(txtEVAT.Text);
			clsBaseDetails.LocalTax = Convert.ToDecimal(txtLocalTax.Text);
			clsBaseDetails.MinThreshold = Convert.ToDecimal(txtMinThreshold.Text);
			clsBaseDetails.MaxThreshold = Convert.ToDecimal(txtMaxThreshold.Text);
            clsBaseDetails.SupplierID = clsProductDetails.SupplierID;
            clsBaseDetails.CreatedBy = clsAccessUserDetails.Name;
			clsBaseDetails.MatrixID = clsProductVariationsMatrix.InsertBaseVariation(clsBaseDetails);

			foreach (DataListItem item in lstItem.Items)
			{
				HtmlInputCheckBox chkList = (HtmlInputCheckBox) item.FindControl("chkList");
				TextBox txtDescription = (TextBox) item.FindControl("txtDescription");

				clsDetails = new ProductVariationsMatrixDetails();
				clsDetails.MatrixID = clsBaseDetails.MatrixID;
				clsDetails.ProductID = Convert.ToInt64(lblProductID.Text);
				clsDetails.VariationID = Convert.ToInt32(chkList.Value);
				clsDetails.Description = txtDescription.Text;
				
				clsProductVariationsMatrix.SaveVariation(clsDetails);
			}
			clsProductVariationsMatrix.CommitAndDispose();

			return true;
		}
Ejemplo n.º 5
0
 public void SaveVariation(ProductVariationsMatrixDetails Details)
 {
     if (IsVariationExists(Details.MatrixID, Details.VariationID))
     {
         Update(Details);
     }
     else
     {
         InsertVariation(Details);
     }
 }
Ejemplo n.º 6
0
		public ProductVariationsMatrixDetails Details(long MatrixID, long VariationID)
		{
			try
			{
				string SQL=	"SELECT MatrixID, VariationID, Description FROM tblProductVariationsMatrix " +
					        "WHERE MatrixID = @MatrixID AND VariationID = @VariationID;";
	 			
				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;

                cmd.Parameters.AddWithValue("@MatrixID", MatrixID);
                cmd.Parameters.AddWithValue("@VariationID", VariationID);

                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);

                ProductVariationsMatrixDetails Details = new ProductVariationsMatrixDetails();
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    Details.MatrixID = MatrixID;
                    Details.VariationID = VariationID;
                    Details.Description = dr["Description"].ToString();
                }

				return Details;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Ejemplo n.º 7
0
        public Int32 Save(ProductVariationsMatrixDetails Details)
        {
            try
            {
                string SQL = "CALL procSaveProductVariationsMatrix(@ProductVariationsMatrixID, @MatrixID, @VariationID, @Description, @CreatedOn, @LastModified);";

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

                cmd.Parameters.AddWithValue("ProductVariationsMatrixID", Details.ProductVariationsMatrixID);
                cmd.Parameters.AddWithValue("MatrixID", Details.MatrixID);
                cmd.Parameters.AddWithValue("VariationID", Details.VariationID);
                cmd.Parameters.AddWithValue("Description", Details.Description);
                cmd.Parameters.AddWithValue("CreatedOn", Details.CreatedOn == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : Details.CreatedOn);
                cmd.Parameters.AddWithValue("LastModified", Details.LastModified == DateTime.MinValue ? Constants.C_DATE_MIN_VALUE : Details.LastModified);

                return base.ExecuteNonQuery(cmd);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Ejemplo n.º 8
0
        private void Update(ProductVariationsMatrixDetails Details)
		{
			try 
			{
				string SQL=	"UPDATE tblProductVariationsMatrix SET " + 
					"Description = @Description " +  
					"WHERE MatrixID = @MatrixID " + 
					"AND VariationID = @VariationID;";
	 			
				MySqlCommand cmd = new MySqlCommand();
				
				
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;
				
				MySqlParameter prmDescription = new MySqlParameter("@Description",MySqlDbType.String);			
				prmDescription.Value = Details.Description;
				cmd.Parameters.Add(prmDescription);

				MySqlParameter prmMatrixID = new MySqlParameter("@MatrixID",MySqlDbType.Int32);			
				prmMatrixID.Value = Details.MatrixID;
				cmd.Parameters.Add(prmMatrixID);

				MySqlParameter prmVariationID = new MySqlParameter("@VariationID",MySqlDbType.Int32);			
				prmVariationID.Value = Details.VariationID;
				cmd.Parameters.Add(prmVariationID);

				base.ExecuteNonQuery(cmd);
			}

			catch (Exception ex)
			{
				
				
				{
					
					
					
					
				}
				throw base.ThrowException(ex);
			}	
		}
Ejemplo n.º 9
0
		public void InheritSubGroupVariationsMatrix(Int64 ProductSubGroupID, Int64 ProductID, ProductDetails prodDetails)
		{
			try 
			{	
				

				ProductBaseVariationsMatrixDetails clsBaseDetails;

				ProductSubGroupVariationsMatrix clsProductSubGroupVariationsMatrix = new ProductSubGroupVariationsMatrix(base.Connection, base.Transaction);

				ProductVariationsMatrix clsProductVariationsMatrix = new ProductVariationsMatrix(base.Connection, base.Transaction);
				ProductVariationsMatrixDetails  clsProductVariationsMatrixDetails = new ProductVariationsMatrixDetails();

				MySqlDataReader clsProductSubGroupVariationsMatrixList;
				MySqlDataReader clsProductSubGroupBaseVariationsMatrixList = clsProductSubGroupVariationsMatrix.BaseList(ProductSubGroupID,"MatrixID",SortOption.Ascending);

				Int64 SubGroupBaseMatrixID = 0;

				while (clsProductSubGroupBaseVariationsMatrixList.Read())
				{
					clsBaseDetails = new ProductBaseVariationsMatrixDetails();
					clsBaseDetails.ProductID = ProductID;
					clsBaseDetails.Description = "" + clsProductSubGroupBaseVariationsMatrixList["Description"].ToString();
					clsBaseDetails.UnitID = Convert.ToInt32(clsProductSubGroupBaseVariationsMatrixList["UnitID"]);
					clsBaseDetails.Price = Convert.ToDecimal(clsProductSubGroupBaseVariationsMatrixList["Price"]);
					clsBaseDetails.WSPrice = Convert.ToDecimal(clsProductSubGroupBaseVariationsMatrixList["WSPrice"]);
					clsBaseDetails.PurchasePrice = Convert.ToDecimal(clsProductSubGroupBaseVariationsMatrixList["PurchasePrice"]);
					clsBaseDetails.IncludeInSubtotalDiscount = Convert.ToBoolean(clsProductSubGroupBaseVariationsMatrixList["IncludeInSubtotalDiscount"]);
					clsBaseDetails.VAT = Convert.ToDecimal(clsProductSubGroupBaseVariationsMatrixList["VAT"]);
					clsBaseDetails.EVAT = Convert.ToDecimal(clsProductSubGroupBaseVariationsMatrixList["EVAT"]);
					clsBaseDetails.LocalTax = Convert.ToDecimal(clsProductSubGroupBaseVariationsMatrixList["LocalTax"]);
					clsBaseDetails.Quantity = 0;
					clsBaseDetails.MinThreshold = prodDetails.MinThreshold;
					clsBaseDetails.MaxThreshold = prodDetails.MaxThreshold;

					clsBaseDetails.MatrixID = clsProductVariationsMatrix.InsertBaseVariation(clsBaseDetails);

					SubGroupBaseMatrixID = clsProductSubGroupBaseVariationsMatrixList.GetInt64(0);
					clsProductSubGroupVariationsMatrix = new ProductSubGroupVariationsMatrix(base.Connection, base.Transaction);
					clsProductSubGroupVariationsMatrixList =  clsProductSubGroupVariationsMatrix.List(SubGroupBaseMatrixID);

					while (clsProductSubGroupVariationsMatrixList.Read())
					{
						clsProductVariationsMatrixDetails = new ProductVariationsMatrixDetails();
						clsProductVariationsMatrixDetails.MatrixID = clsBaseDetails.MatrixID;
						clsProductVariationsMatrixDetails.ProductID = ProductID;
						clsProductVariationsMatrixDetails.VariationID = Convert.ToInt64(clsProductSubGroupVariationsMatrixList["VariationID"]);
						clsProductVariationsMatrixDetails.Description = "" + clsProductSubGroupVariationsMatrixList["Description"].ToString();
						clsProductVariationsMatrix.SaveVariation(clsProductVariationsMatrixDetails);
					}
					clsProductSubGroupVariationsMatrixList.Close(); 

				}
				clsProductSubGroupBaseVariationsMatrixList.Close();

			}
				
			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}