private void ButtonDelUser_Click(object sender, RoutedEventArgs e) { int id_del; string usrnm_del; int grpid_del; string lgn_del; string pass_del; //===========Selecting ID of current user in selected row in the DataGrid FuncUsers_Result row = (FuncUsers_Result)DataGridUsers.SelectedItems[0]; // !!! id_del = (int)row.Id; usrnm_del = row.Usr; lgn_del = row.Lgin; pass_del = row.Pass; string nameGroup = row.NameGrp.ToString(); //========================Searching the id of group, by name CarRentalCenterDBEntities context = new CarRentalCenterDBEntities(); var row2 = (from c in context.TableGroups where c.NameGrp == nameGroup select c).First(); //select from table (LINQ) grpid_del = row2.Id; // //context.TableUsers.Find(id_del); //TableUsers user_del = new TableUsers() { Id = id_del, GroupsID = grpid_del, Lgin = lgn_del, Pass = pass_del, Usr = usrnm_del }; context.TableUsers.Remove(context.TableUsers.Find(id_del)); context.SaveChanges(); RefreshWindow(); }
public Add_order(CarRentalCenterDBEntities context_input) { InitializeComponent(); context = context_input; this.ComboBoxStatus.ItemsSource = new DataSet1TableAdapters.TableStatusTableAdapter().GetData(); this.ComboBoxStatus.DisplayMemberPath = "Status"; }
//public EditPerson() //{ // InitializeComponent(); // context = new CarRentalCenterDBEntities(); //} public EditPerson(TablePersons row_input, CarRentalCenterDBEntities context_input) { InitializeComponent(); context = new CarRentalCenterDBEntities(); row = row_input; context = context_input; LoadData(); }
public Orders(string vinCar_inpt) { InitializeComponent(); vinOfselectedCar = vinCar_inpt; context = new CarRentalCenterDBEntities(); this.DataGridOrders.ItemsSource = (from c in context.FuncOrders1() where c.VIN == vinOfselectedCar select c).ToArray(); }
public EditORder(CarRentalCenterDBEntities context_inpt, FuncOrders1_Result selectedRow_inpt) { InitializeComponent(); this.context = context_inpt; this.selectedRow = selectedRow_inpt; this.context = context_inpt; this.LabelAmountCurr.Content = selectedRow.Amount.ToString(); this.LabelCarCurr.Content = selectedRow_inpt.Maker + selectedRow_inpt.Model; this.LabelDateCurr.Content = selectedRow_inpt.Date; this.LabelPersonCurr1.Content = selectedRow_inpt.FirstName + selectedRow_inpt.LastName; this.LabelStatusCurr.Content = selectedRow_inpt.Status; this.ComboBoxEditStatus.ItemsSource = (from c in context.TableStatus select c).ToArray(); this.ComboBoxEditStatus.DisplayMemberPath = "Status"; }
private void ButtonAdd_Click(object sender, RoutedEventArgs e) { string username = this.TextBoxUsername.Text.ToString(); string login = this.TextBoxLogin.Text.ToString(); string password = this.TextBoxPassword.Text.ToString(); string grup = this.ComboBoxGroup.Text.ToString(); //========================Searching id by the name of user group in the tabe TabeGroups CarRentalCenterDBEntities context = new CarRentalCenterDBEntities(); var row = (from c in context.TableGroups where c.NameGrp == grup select c).First(); // !!!! int idGroup = row.Id; // //==========================Adding new user context.TableUsers.Add(new TableUsers() { Usr = username, GroupsID = idGroup, Lgin = login, Pass = password }); context.SaveChanges(); this.Close(); }
private void ButtonAdd_Click(object sender, RoutedEventArgs e) { try { CarRentalCenterDBEntities context = new CarRentalCenterDBEntities(); context.TablePersons.Add( new TablePersons() { FirstName = this.TextBoxFName.Text, LastName = this.TextBoxLname.Text, DateOfBirth = this.DatePicked.SelectedDate, Address = this.TextBoxAddress.Text, Phone = this.TextBoxPhone.Text, E_mail = this.TextBoxEmail.Text }); context.SaveChanges(); this.Close(); } catch (Exception exp) { MessageBox.Show(exp.Message); } }
void RefreshWindow() { //this.DataGridUsers.ItemsSource = new CarRentalCenterDBEntities().FuncUsers(); context = new CarRentalCenterDBEntities(); this.DataGridUsers.ItemsSource = from c in context.FuncUsers() select c; }
void RefreshWindow() { context = new CarRentalCenterDBEntities(); this.DataGridPersons.ItemsSource = (from c in context.TablePersons select c).ToArray(); }
public Cars() { InitializeComponent(); context = new CarRentalCenterDBEntities(); RefreshWindow(); }
public Orders() { InitializeComponent(); context = new CarRentalCenterDBEntities(); this.DataGridOrders.ItemsSource = context.FuncOrders1(); }