private void ShowPriceTime()
 {
     price = PriceTimeModel.SelectAll();
     comboBoxPriceTime.DisplayMember = "Name";
     comboBoxPriceTime.ValueMember   = "Id";
     comboBoxPriceTime.DataSource    = price;
 }
Exemple #2
0
 private void buttonDeletePriceTime_Click(object sender, EventArgs e)
 {
     if (priceTime.Count != 0)
     {
         var          index  = dataGridViewPriceTime.CurrentRow.Index;
         int          Id     = priceTime[index].Id;
         DialogResult result = MessageBox.Show("Удалить?", "Удаление", MessageBoxButtons.YesNo);
         if (result == DialogResult.Yes)
         {
             bool isDelete = PriceTimeModel.Delete(Id);
             if (isDelete)
             {
                 ShowPriceTime();
             }
             else
             {
                 MessageBox.Show("Ошибка при удаления");
             }
         }
     }
     else
     {
         MessageBox.Show("Таблица пустая");
     }
 }
 private void buttonSave_Click(object sender, EventArgs e)
 {
     if (price == null)
     {
         price = new PriceTimeModel();
         if (textBoxTypeTime.Text != "" && textBoxPriceTime.Text != "")
         {
             price.Name  = textBoxTypeTime.Text;
             price.Price = int.Parse(textBoxPriceTime.Text);
             int lastId = PriceTimeModel.Insert(price);
             if (lastId > 0)
             {
                 Close();
             }
             else
             {
                 MessageBox.Show("Ошибка при добавления");
             }
         }
         else
         {
             MessageBox.Show("Заполните поля");
         }
     }
     else
     {
         price.Name  = textBoxTypeTime.Text;
         price.Price = int.Parse(textBoxPriceTime.Text);
         bool isUpdate = PriceTimeModel.Update(price);
         if (isUpdate)
         {
             Close();
         }
         else
         {
             MessageBox.Show("Ошибка");
         }
     }
 }
 public static bool Update(PriceTimeModel priceTime)
 {
     return(DBManager.UpdatePriceTime(priceTime));
 }
 public static int Insert(PriceTimeModel price)
 {
     return(DBManager.InsertPriceTime(price));
 }
Exemple #6
0
 private void ShowPriceTime()
 {
     priceTime = PriceTimeModel.SelectAll();
     dataGridViewPriceTime.DataSource = priceTime;
 }