Ejemplo n.º 1
0
        /// <summary>
        /// returns a List of all information about the products (limit:200)
        /// </summary>
        private async Task<List<Product>> GetFullProductsAsync()
        {
            
            MySqlDataReader reader = this.Query("SELECT * FROM gk_pricing ORDER BY product ASC LIMIT 0,200");

            List<Product> list = new List<Product>();

            while (await reader.ReadAsync())
            {
                Product product = new Product();

                try
                {
                    product.comment = reader.GetString("comment");
                }
                catch { }

                product.ID = reader.GetInt32("ID");
                product.price = reader.GetDouble("price");
                product.product = reader.GetString("product");

                list.Add(product);
            }

            reader.Close();
            this.Close();
            return list;
        }
        /// <summary>
        /// Basing on the submitted Form, check which elements are dirty (changes)
        /// </summary>
        public List<Product> CheckDirtyElements()
        {
            // Get number of Elements
            int amount = int.Parse((string)Request.Form["ctl00$MainContent$entryCount"]);

            List<Product> list = new List<Product>();

            // Check one by one...
            for (int i=0;i<amount;i++)
            {
                if ((string)Request.Form["ctl00$MainContent$repProd$ctl"+i.ToString("D2")+"$textName"] != (string)Request.Form["ctl00$MainContent$repProd$ctl" + i.ToString("D2") + "$textNameOld"]
                    || (string)Request.Form["ctl00$MainContent$repProd$ctl" + i.ToString("D2") + "$textComment"] != (string)Request.Form["ctl00$MainContent$repProd$ctl" + i.ToString("D2") + "$textCommentOld"]
                    || (string)Request.Form["ctl00$MainContent$repProd$ctl" + i.ToString("D2") + "$textPrice"] != (string)Request.Form["ctl00$MainContent$repProd$ctl" + i.ToString("D2") + "$textPriceOld"])
                {
                    //Response.Write("Test");
                    // Found a dirty item, Create a User for this and store data
                    int id = (int.Parse((string)Request.Form["ctl00$MainContent$repProd$ctl" + i.ToString("D2") + "$textID"]));
                    Product product = new Product();
                    product.comment = (string)Request.Form["ctl00$MainContent$repProd$ctl" + i.ToString("D2") + "$textComment"];
                    try
                    {
                        
                        string debtString = (string)Request.Form["ctl00$MainContent$repProd$ctl" + i.ToString("D2") + "$textPrice"];
                        //debtString = debtString.Replace(",", ".");
                        //product.price = Double.Parse(debtString, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.CultureInfo.InvariantCulture);
                        product.price = Global.String2Double(debtString);
                        
                        //Response.Write(product.price);
                        /*System.Globalization.CultureInfo EnglishCulture = new System.Globalization.CultureInfo("en-EN");
                        product.price = Double.Parse(debtString, System.Globalization.NumberStyles.Float, EnglishCulture);*/
                    }
                    catch
                    {
                        // not valid double value
                        StateMessage = "Please provide valid values for price! (Aborting)";
                        return new List<Product>();
                    }
                    product.ID = id;
                    
                    product.product = (string)Request.Form["ctl00$MainContent$repProd$ctl" + i.ToString("D2") + "$textName"];
                    if (product.comment == null) product.comment = String.Empty;

                    list.Add(product);
                }

                // Todo: Deletions
            }

            return list;
        }