private void comboBoxChooseProd_SelectedIndexChanged(object sender, EventArgs e) { prodName = comboBoxChooseProd.Text; com = "SELECT DISTINCT [Size] 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 " + $"Warehouse.[Id_Affiliate] = {affiliateId}"; comboBoxSizeBuy.SelectedIndex = -1; comboBoxSizeBuy.Items.Clear(); textBoxPriceProd.Clear(); richTextBox.Clear(); MyConnection.comboBoxLoading(comboBoxSizeBuy, com, "Size"); com = "SELECT TOP 1 [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}'"; MyConnection.textBoxLoading(textBoxPriceProd, com); com = "SELECT TOP 1 [Descriprion] 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}'"; MyConnection.richTextBoxLoading(richTextBox, com); }
private void refresh() { com = "SELECT CONCAT(Buyer.[Surname], ' ', Buyer.[Name]) AS 'Ф.И.' FROM Buyer WHERE Buyer.[Id_Buyer] != 1"; MyConnection.comboBoxLoading(comboBoxOrdersUserChoose, com, "Ф.И."); MyConnection.comboBoxLoading(comboBoxDeliveryChoose, com, "Ф.И."); com = "SELECT COUNT(*) FROM Purchase"; MyConnection.textBoxLoading(textBoxOrders, com); com = "SELECT * FROM PurchaseView"; MyConnection.loadingDataGridView(dataGridViewOrdersProducts, com, "PurchaseView"); com = "SELECT [Номер доставки], [Ф.И.], [Адрес доставки], [Дата доставки], [Статус доставки] FROM DeliveryToBuyerView"; MyConnection.loadingDataGridView(dataGridViewOrdersDelivery, com, "DeliveryToBuyerView"); }
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++; } }