private void buttonAddBasket_Click(object sender, EventArgs e) { if (comboBoxChooseType.Text.Length == 0 || comboBoxChooseProd.Text.Length == 0 || comboBoxSizeBuy.Text.Length == 0) { MessageBox.Show("Ничего не выбранно!", "Ошибка.", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { com = "SELECT Product.[ProductName] " + "FROM Product " + "join ProductType on Product.[Id_ProductType] = ProductType.[Id_ProductTypeKA] " + "join TableProdImg on ProductType.[Id_ProductTypeKA] = TableProdImg.[Id_Type] " + $"WHERE TableProdImg.[Id_Type] = {comboBoxChooseType.SelectedIndex + 1} AND TableProdImg.[ProductName] = '{comboBoxChooseProd.Text}' " + $"AND Product.[ProductName] = '{comboBoxChooseProd.Text}' " + $"AND Product.[Size] = '{comboBoxSizeBuy.Text}'"; MyConnection.listBoxOrder(listBoxProds, com); com = "SELECT Product.[PriceOfUnit] " + "FROM Product " + "join ProductType on Product.[Id_ProductType] = ProductType.[Id_ProductTypeKA] " + "join TableProdImg on ProductType.[Id_ProductTypeKA] = TableProdImg.[Id_Type] " + $"WHERE TableProdImg.[Id_Type] = {comboBoxChooseType.SelectedIndex + 1} AND TableProdImg.[ProductName] = '{comboBoxChooseProd.Text}' " + $"AND Product.[ProductName] = '{comboBoxChooseProd.Text}' " + $"AND Product.[Size] = '{comboBoxSizeBuy.Text}'"; MyConnection.textBoxLoading(textBoxAmount, com); com = "SELECT Warehouse.[Id_Position] FROM Product " + "join Warehouse on Product.[Id_ProductKA] = Warehouse.[Id_Product] " + "join ProductType on Product.[Id_ProductType] = ProductType.[Id_ProductTypeKA] " + "join TableProdImg on ProductType.[Id_ProductTypeKA] = TableProdImg.[Id_Type] " + $"WHERE TableProdImg.[Id_Type] = {comboBoxChooseType.SelectedIndex + 1} AND TableProdImg.[ProductName] = '{comboBoxChooseProd.Text}' " + $"AND Product.[ProductName] = '{comboBoxChooseProd.Text}' " + $"AND Product.[Size] = '{comboBoxSizeBuy.Text}' " + $"AND Warehouse.[Id_Affiliate] = {affiliateId}"; using (SqlConnection sqlConnection = new MyConnection().GetConnection()) { sqlConnection.Open(); SqlCommand sqlCommand = new SqlCommand(com, sqlConnection); tempInt = Convert.ToInt32(sqlCommand.ExecuteScalar()); sqlConnection.Close(); } positionProd.Add(tempInt.ToString() + ", "); sizeList.Add(comboBoxSizeBuy.Text + ", "); amount += Double.Parse(textBoxAmount.Text); textBoxAmount.Text = amount.ToString(); i++; } }