private void btnAddToList_Click(object sender, EventArgs e) { string newMarka = cmbMarka.SelectedItem.ToString(); ComboItem newModel = cmbModel.SelectedItem as ComboItem; ComboItem newYear = cmbYear.SelectedItem as ComboItem; ComboItem newEngPow = cmbEnginerPow.SelectedItem as ComboItem; ComboItem newFuel = cmbFuel.SelectedItem as ComboItem; ComboItem newStatus = cmbStatus.SelectedItem as ComboItem; Car newCar = new Car { ModelID = newModel.Value, YearID = newYear.Value, EPowID = newEngPow.Value, FuelID = newFuel.Value, StatusID = newStatus.Value, }; db.Cars.Add(newCar); db.SaveChanges(); updateInformation(); }
private void btnSubmitUser_Click(object sender, EventArgs e) { string FirstName = txtFirstName.Text.Trim().ToLower(); string Surname = txtSurName.Text.Trim().ToLower(); string Email = txtNewEmail.Text.Trim().ToLower(); string NewPassword = txtNewPassword.Text; if (String.IsNullOrEmpty(FirstName) || String.IsNullOrEmpty(Surname) || String.IsNullOrEmpty(Email) || String.IsNullOrEmpty(NewPassword)) { MessageBox.Show("Please, Fill all inputs"); } else { UserPanel newUser = new UserPanel { FirstName = FirstName, LastName = Surname, E_mail = Email, Password = Exception.Exception.HashPassword(NewPassword), ForgetingPassword = NewPassword, }; newUserName = db.UserPanels.Where(w => w.FirstName == newUser.FirstName).FirstOrDefault(); if (newUserName == null) { MessageBox.Show("You have registered", "Welcome"); db.UserPanels.Add(newUser); db.SaveChanges(); } else { MessageBox.Show("This UserName existes"); } } }