Пример #1
0
        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();
        }
Пример #2
0
 public Add_order(CarRentalCenterDBEntities context_input)
 {
     InitializeComponent();
     context = context_input;
     this.ComboBoxStatus.ItemsSource       = new DataSet1TableAdapters.TableStatusTableAdapter().GetData();
     this.ComboBoxStatus.DisplayMemberPath = "Status";
 }
Пример #3
0
        //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();
        }
Пример #4
0
 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();
 }
Пример #5
0
        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";
        }
Пример #6
0
        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();
        }
Пример #7
0
        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);
            }
        }
Пример #8
0
 void RefreshWindow()
 {
     //this.DataGridUsers.ItemsSource = new CarRentalCenterDBEntities().FuncUsers();
     context = new CarRentalCenterDBEntities();
     this.DataGridUsers.ItemsSource = from c in context.FuncUsers() select c;
 }
Пример #9
0
 void RefreshWindow()
 {
     context = new CarRentalCenterDBEntities();
     this.DataGridPersons.ItemsSource = (from c in context.TablePersons select c).ToArray();
 }
Пример #10
0
 public Cars()
 {
     InitializeComponent();
     context = new CarRentalCenterDBEntities();
     RefreshWindow();
 }
Пример #11
0
 public Orders()
 {
     InitializeComponent();
     context = new CarRentalCenterDBEntities();
     this.DataGridOrders.ItemsSource = context.FuncOrders1();
 }