Esempio n. 1
0
 private void buttonUpdateExpenses_Click(object sender, EventArgs e)
 {
     expense = ExpensesModel.SelectAll();
     if (expense.Count != 0)
     {
         var index = dataGridViewExpenses.CurrentRow.Index;
         UpdatePriceExpenses updatePrice = new UpdatePriceExpenses();
         updatePrice.eModel = expense[index];
         updatePrice.ShowDialog();
         ShowExpenses();
         Show();
     }
     else
     {
         MessageBox.Show("Таблица пустая");
     }
 }
Esempio n. 2
0
 private void buttonUpdate_Click(object sender, EventArgs e)
 {
     if (eModel != null)
     {
         eModel.Price = Convert.ToInt32(textBoxPrice.Text);
         eModel.Date  = textBoxDate.Text;
         eModel.Name  = textBoxName.Text;
         bool isUpdate = ExpensesModel.Update(eModel);
         if (isUpdate)
         {
             Close();
         }
         else
         {
             MessageBox.Show("Ошибка");
         }
     }
 }
Esempio n. 3
0
 private void buttonAddExpenses_Click(object sender, EventArgs e)
 {
     if (textBoxExpenses.Text != "" && textBoxPrice.Text != "")
     {
         expenses       = new ExpensesModel();
         expenses.Name  = textBoxExpenses.Text;
         expenses.Price = int.Parse(textBoxPrice.Text);
         var hour  = DateTime.Now.Hour;
         var day   = DateTime.Now.Day;
         var month = DateTime.Now.Month;
         var year  = DateTime.Now.Year;
         if (hour >= 0 && hour <= 6)
         {
             var date = new DateTime(year, month, day - 1, hour, dateTimePicker1.Value.Minute, dateTimePicker1.Value.Second);
             dateTimePicker1.Value = date;
         }
         else if (hour >= 9 && hour <= 23)
         {
             var date = new DateTime(year, month, day, hour, dateTimePicker1.Value.Minute, dateTimePicker1.Value.Second);
             dateTimePicker1.Value = date;
         }
         else
         {
             MessageBox.Show("Рабочий день закончился");
         }
         expenses.Date = dateTimePicker1.Value.ToString("dd-MM-yyyy HH:mm");
         int lastId = ExpensesModel.Insert(expenses);
         if (lastId > 0)
         {
             ShowExpenses();
             ClearTextBox();
         }
         else
         {
             MessageBox.Show("Ошибка при добавление");
         }
     }
     else
     {
         MessageBox.Show("Заполните поля");
     }
 }
Esempio n. 4
0
 private void ShowExpenses()
 {
     expense = ExpensesModel.SelectAll();
     dataGridViewExpenses.DataSource = expense;
 }
Esempio n. 5
0
 public static bool Update(ExpensesModel expenses)
 {
     return(DBManager.UpdateExpenses(expenses));
 }
Esempio n. 6
0
 public static int Insert(ExpensesModel expenses)
 {
     return(DBManager.InsertExpenses(expenses));
 }