示例#1
0
        /* Заполняем clb_Products данными */
        private void Fill_clb_Products(List <ProductsModel> _list)
        {
            ProductsModel tmpObject      = new ProductsModel {
            };
            List <string> tmpProductList = new List <string> {
            };

            clb_Products.Items.Clear();

            for (int i = 0; i < _list.Count; i++)
            {
                if (!tmpProductList.Contains(_list[i].Name + " [" + _list[i].ASIN + " - " + GetMarketPlaceNameById(_list[i].MarketPlaceId) + "]"))
                {
                    tmpProductList.Add(_list[i].Name + " [" + _list[i].ASIN + " - " + GetMarketPlaceNameById(_list[i].MarketPlaceId) + "]");
                }
            }

            for (int i = 0; i < tmpProductList.Count; i++)
            {
                clb_Products.Items.Add(tmpProductList[i]);
            }

            for (int i = 0; i < clb_Products.Items.Count; i++)
            {
                tmpObject = GetProduct(clb_Products.Items[i].ToString(), "just object");
                foreach (var checkedproduct in checkedProducts)
                {
                    if (checkedproduct.ASIN.Equals(tmpObject.ASIN) && checkedproduct.MarketPlaceId == tmpObject.MarketPlaceId)
                    {
                        clb_Products.SetItemChecked(i, true);
                    }
                }
            }
        }
示例#2
0
        /* Заносим данные в List<ProductsModel> */
        private void SetDataToList(object[] arr)
        {
            ProductsModel pModel = new ProductsModel();

            pList.Add(pModel);
            for (int i = 0; i < arr.Length; i++)
            {
                pList[pList.Count - 1].WriteData(i, arr[i]);
            }
        }
示例#3
0
        /* Заносим данные в List<ProductsModel> */
        private void SetProductsToList(IDataRecord record)
        {
            ProductsModel pModel = new ProductsModel();

            pList.Add(pModel);
            for (int i = 0; i < record.FieldCount; i++)
            {
                pList[pList.Count - 1].WriteData(i, record[i]);
            }
        }
示例#4
0
        /* Проверяем, есть ли у продукта хотябы одна семантика */
        private void checkForExistingSemantics()
        {
            List <string> tmp = new List <string> {
            };

            tmpPList = new List <ProductsModel> {
            };
            ProductsModel pmModel;

            for (int i = 0; i < pmUniqueList.Count; i++)
            {
                //string sqlSemanticsIds = "SELECT COUNT(SemanticsId) FROM semantics WHERE [ProductId] = " + pmList[i].ProductId;   SELECT * FROM getProductIdByASIN('B01AG56HYQ')
                string     sqlSemanticsIds = "SELECT COUNT(SemanticsId) FROM semantics WHERE [ProductId] = " + pmUniqueList[i].ProductId;
                SqlCommand command         = new SqlCommand(sqlSemanticsIds, connection);

                try
                {
                    connection.Open();

                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            IDataRecord dr  = (IDataRecord)reader;
                            int         cnt = int.Parse(dr[0].ToString());

                            if (cnt == 0)// && !tmp.Contains(pmUniqueList[i].ASIN))
                            {
                                pmModel = new ProductsModel();
                                tmpPList.Add(pmModel);

                                tmpPList[tmpPList.Count - 1] = pmUniqueList[i];
                                tmp.Add(pmUniqueList[i].ASIN);
                            }
                        }
                    }
                    else
                    {
                        Console.WriteLine("No rows found.");
                    }
                    reader.Close();
                    connection.Close();
                }
                catch (Exception e)
                {
                    MessageBox.Show("Упс! Возникла проблема с подключением к БД :( Приложение будет закрыто", "Ошибка");
                    Environment.Exit(0);
                }
            }
        }
示例#5
0
        /* Изменяем выбор товара в clb_Products */
        private void clb_Products_SelectedIndexChanged(object sender, EventArgs e)
        {
            ProductsModel tmpObject = new ProductsModel {
            };
            string val = "";

            if (clb_Products.CheckedItems.Count == 0)
            {
                checkedProducts.Clear();
            }
            else
            {
                for (int i = 0; i < clb_Products.CheckedItems.Count; i++)
                {
                    val       = clb_Products.CheckedItems[i].ToString();
                    tmpObject = GetProduct(val, "just object");
                    if (!checkedProducts.Contains(tmpObject))
                    {
                        checkedProducts.Add(tmpObject);
                    }
                }
            }
        }
示例#6
0
        /* Выделяем уникальные ASIN с разных SKU (работа с товарами, у которых ещё нет семантики) */
        private void getUniquesASIN()
        {
            List <string> tmp = new List <string> {
            };

            pList = new List <ProductsModel> {
            };

            if (pmUniqueList != null)
            {
                for (int i = 0; i < pmUniqueList.Count; i++)
                {
                    if (!tmp.Contains(pmUniqueList[i].ASIN))
                    {
                        ProductsModel pmModel = new ProductsModel();
                        pList.Add(pmModel);

                        pList[pList.Count - 1] = pmUniqueList[i];
                        tmp.Add(pmUniqueList[i].ASIN);
                    }
                }
            }
        }