private void buttonAccept_Click(object sender, EventArgs e)
 {
     int user_id = UserSingleton.Instance.userId;
     var login = textBoxLogin.Text;
     var pass = textBoxPassword.Text;
     var newPass1 = textBoxNewPassword1.Text;
     var newPass2 = textBoxNewPassword2.Text;
     if (newPass1 == newPass2)
     {
         var dbModel = new DatabaseModel();
         var result = dbModel.user_data.Find(user_id);
         if (result != null)
         {
             if (login == result.login && pass == result.password)
             {
                 result.password = newPass1;
                 dbModel.SaveChanges();
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Nieprawidłowy login i/lub hasło.\nOsoba zalogowana może zmienić hasło tylko sobie.");
             }
         }
         else
         {
             MessageBox.Show("Sprawdź połaczenie z internetem.");
         }
     }
     else
     {
         MessageBox.Show("Nowe hasło w obu polach musi być jednakowe.");
     }
 }
Example #2
0
 private void buttonCancel_Click(object sender, EventArgs e)
 {
     if(row != null){
         var dbModel = new DatabaseModel();
         var reservation = dbModel.reservation.Find((int)row.Cells["idDataGridViewTextBoxColumn"].Value);
         dbModel.reservation.Remove(reservation);
         dbModel.SaveChanges();
         this.buttonFilter_Click(new object(), new EventArgs());
     }
 }
Example #3
0
 private void buttonHire_Click(object sender, EventArgs e)
 {
     if (row != null) {
         var id = row.Cells["idDataGridViewTextBoxColumn"].Value.ToString();
         var dbModel = new DatabaseModel();
         var user = dbModel.user_data.Find(Int32.Parse(id));
         user.is_active = 1;
         dbModel.SaveChanges();
         this.buttonFilter_Click(new object(), new EventArgs());
     }
 }
 private void buttonAccept_Click(object sender, EventArgs e)
 {
     var dbModel = new DatabaseModel();
     var result = dbModel.client.Find(clientId);
     if (result != null)
     {
         result.first_name = this.textBoxName.Text;
         result.last_name = this.textBoxSurname.Text;
         result.address = this.textBoxAddress.Text;
         result.phone = this.textBoxTelephoneNum.Text;
         result.email = this.textBoxEmail.Text;
         dbModel.SaveChanges();
         this.Close();
     }
 }
 private void buttonAccept_Click(object sender, EventArgs e)
 {
     if (this.client != null && this.car != null) {
         var dbModel = new DatabaseModel();
         var newReservation = new reservation();
         newReservation.date_reservation = this.dateTimePickerPurchaseDate.Value;
         newReservation.date_reservation_expired = this.dateTimePickerPurchaseDate.Value.AddDays(14);
         newReservation.id_user = UserSingleton.Instance.userId;
         newReservation.id_client = (int)this.client.Cells["idDataGridViewTextBoxColumn"].Value;
         newReservation.id_car = (int)this.car.Cells["idDataGridViewTextBoxColumn"].Value;
         dbModel.reservation.Add(newReservation);
         dbModel.SaveChanges();
     } else {
         MessageBox.Show("Musisz najpierw wybrać klienta oraz samochód.");
     }
 }
 private void buttonAccept_Click(object sender, EventArgs e)
 {
     var dbModel = new DatabaseModel();
     foreach (var service in this.selectedServices) {
         var order = new client_order();
         var serv = dbModel.dict_service.SqlQuery("SELECT * FROM dict_service WHERE name like '" + service.ToString() + "';").ToList();
         order.date_order = this.dateTimePickerPurchaseDate.Value;
         order.date_done = this.dateTimePickerPurchaseDate.Value;
         order.id_client = (int)this.client.Cells["idDataGridViewTextBoxColumn"].Value;
         order.id_service = (int)serv[0].id;
         order.id_user = UserSingleton.Instance.userId;
         order.cost = Decimal.Parse(serv[0].cost);
         order.comment = this.textBoxComment.Text;
         order.id_car_shop = dbModel.user_data.Find(UserSingleton.Instance.userId).id_car_shop;
         order.is_done = 1;
         dbModel.client_order.Add(order);
         dbModel.SaveChanges();
     }
     this.Close();
 }
Example #7
0
 private void buttonRealize_Click(object sender, EventArgs e)
 {
     if(row != null){
         var dbModel = new DatabaseModel();
         var reservation = dbModel.reservation.Find((int)row.Cells["idDataGridViewTextBoxColumn"].Value);
         var carSell = new car_sell();
         carSell.id_car = reservation.id_car;
         carSell.id_client = reservation.id_client;
         carSell.id_user = UserSingleton.Instance.userId;
         carSell.sell_date = DateTime.Now;
         carSell.cost = Decimal.Parse(dbModel.car.Find(carSell.id_car).cost);
         dbModel.car_sell.Add(carSell);
         dbModel.reservation.Remove(reservation);
         dbModel.SaveChanges();
         this.buttonFilter_Click(new object(), new EventArgs());
     }
 }