Ejemplo n.º 1
0
 private void buttonAddGood_Click(object sender, EventArgs e)
 {
     if (income == null)
     {
         income = new IncomesModel();
         if (textBoxAmount.Text != "" && textBoxName.Text != "" && textBoxPrice.Text != "")
         {
             income.Name        = textBoxName.Text;
             income.Price       = Convert.ToInt32(textBoxPrice.Text);
             income.Amount      = Convert.ToInt32(textBoxAmount.Text);
             income.DateIncomes = dateTimePicker1.Value.ToString("dd-MM-yyyy HH:mm");
             int id = IncomesModel.Insert(income);
             if (id >= 0)
             {
                 Close();
             }
             else
             {
                 MessageBox.Show("ошибка");
             }
         }
         else
         {
             MessageBox.Show("Заполните поля");
         }
     }
 }
Ejemplo n.º 2
0
 private void buttonInsert_Click(object sender, EventArgs e)
 {
     if (incomes == null)
     {
         incomes = new IncomesModel();
         if (textBoxName.Text != "" && textBoxPrice.Text != "" && textBoxAmount.Text != "")
         {
             incomes.Name        = textBoxName.Text;
             incomes.Price       = int.Parse(textBoxPrice.Text);
             incomes.Amount      = int.Parse(textBoxAmount.Text);
             incomes.DateIncomes = dateTimePickerAddGoods.Value.ToString("dd-MM-yyyy HH:mm");
             int lastId = IncomesModel.Insert(incomes);
             if (lastId > 0)
             {
                 MessageBox.Show("Успешно добавлен");
                 Close();
             }
             else
             {
                 MessageBox.Show("Ошибка при добавлений");
             }
         }
         else
         {
             MessageBox.Show("Заполните поля");
         }
     }
     else
     {
         MessageBox.Show("Ошибка");
     }
 }
Ejemplo n.º 3
0
 private void buttonDeleteByDateIncomes_Click(object sender, EventArgs e)
 {
     if (incomes.Count != 0)
     {
         incomes = IncomesModel.SelectAll();
         string query  = "DELETE FROM Incomes WHERE DateIncomes BETWEEN @before AND @after";
         var    before = new DateTime(dateTimePickerBefore.Value.Year, dateTimePickerBefore.Value.Month, dateTimePickerBefore.Value.Day, 0, 0, 0);
         var    after  = new DateTime(dateTimePickerAfter.Value.Year, dateTimePickerAfter.Value.Month, dateTimePickerAfter.Value.Day, 23, 59, 0);
         try
         {
             connection.Open();
             command = new SQLiteCommand(query, connection);
             command.Parameters.AddWithValue("before", before.ToString("dd-MM-yyyy HH:mm"));
             command.Parameters.AddWithValue("after", after.ToString("dd-MM-yyyy HH:mm"));
             command.ExecuteNonQuery();
         }
         catch (Exception ex) { MessageBox.Show(ex.Message); }
         finally { connection.Close(); }
         ShowIncomes();
     }
     else
     {
         MessageBox.Show("Таблица пустая");
     }
 }
Ejemplo n.º 4
0
 public static int Insert(IncomesModel incomes)
 {
     return(DBManager.InsertIncomes(incomes));
 }
Ejemplo n.º 5
0
 private void ShowIncomes()
 {
     incomes = IncomesModel.SelectAll();
     dataGridViewIncomes.DataSource = incomes;
 }