Пример #1
0
 private void Delete_Click(object sender, RoutedEventArgs e)
 {
     if (dataGrid.SelectedIndex != -1)
     {
         int amount = (int)DataBase.GetTable(connectionString, $"select Quantity from Warehouse where ID_Warehouse = {tovarComboBox.SelectedValue}").Rows[0][0];
         DataBase.CDUBase(connectionString, $"insert into Statistic([Product_Name], [Amount], [Date_Add]) values ('{tovarComboBox.SelectedItem.ToString().Substring(1, tovarComboBox.SelectedItem.ToString().IndexOf(','))}', -{(dataGrid.SelectedItem as object[])[1]}, GETDATE())");
         DataBase.CDUBase(connectionString, $"update Warehouse set Quantity = {amount + (int)(dataGrid.SelectedItem as object[])[1]} where ID_Warehouse = {tovarComboBox.SelectedValue}");
         totalCost        -= (int)(dataGrid.SelectedItem as object[])[2];
         totalTextBox.Text = totalCost.ToString();
         checkTable.Rows.RemoveAt(dataGrid.SelectedIndex);
         Filling.FillDataGrid(checkTable, dataGrid);
     }
 }
Пример #2
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            #region Загрузка первого пивота
            DataBase.LoadComboBox(connectionString, "select ID_Warehouse, Name from Warehouse", tovarComboBox);

            checkTable.Columns.Add("Товар", Type.GetType("System.String"));
            checkTable.Columns.Add("Количество товара", Type.GetType("System.Int32"));
            checkTable.Columns.Add("Цена в сумме", Type.GetType("System.Int32"));

            Filling.FillDataGrid(checkTable, dataGrid);
            #endregion

            #region Загрузка второго пивота
            DataBase.LoadComboBox(connectionString, "select ID_Warehouse, Name from Warehouse", returnComboBox);
            #endregion
        }
Пример #3
0
        private void Insert_Click(object sender, RoutedEventArgs e)
        {
            if (tovarComboBox.SelectedIndex != -1)
            {
                string check = allCheck();

                if (check == "ОК")
                {
                    int amount = (int)DataBase.GetTable(connectionString, $"select Quantity from Warehouse where ID_Warehouse = {tovarComboBox.SelectedValue}").Rows[0][0];
                    int cost   = (int)DataBase.GetTable(connectionString, $"select Cost from Warehouse where ID_Warehouse = {tovarComboBox.SelectedValue}").Rows[0][0];
                    checkTable.Rows.Add(new Object[] { tovarComboBox.SelectedItem.ToString().Substring(1, tovarComboBox.SelectedItem.ToString().IndexOf(',')), Convert.ToInt32(amountTextBox.Text), Convert.ToInt32(amountTextBox.Text) * cost });
                    totalCost        += Convert.ToInt32(amountTextBox.Text) * cost;
                    totalTextBox.Text = totalCost.ToString();
                    DataBase.CDUBase(connectionString, $"update Warehouse set Quantity = {amount - Convert.ToInt32(amountTextBox.Text)} where ID_Warehouse = {tovarComboBox.SelectedValue}");
                    DataBase.CDUBase(connectionString, $"insert into Statistic([Product_Name], [Amount], [Date_Add]) values ('{tovarComboBox.SelectedItem.ToString().Substring(1, tovarComboBox.SelectedItem.ToString().IndexOf(','))}', {amountTextBox.Text}, GETDATE())");
                    Filling.FillDataGrid(checkTable, dataGrid);
                }
                else
                {
                    var message = new MessageDialog(check).ShowAsync();
                }
            }
        }