Пример #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
        private void ButtonOK_Click(object sender, RoutedEventArgs e)
        {
            TableCars selectedCar = new TableCars();

            selectedCar = (TableCars)(from c in context.TableCars
                                      where c.VIN == selectedCarVIN
                                      select c).First();

            TableStatus selectedStatus = new TableStatus();

            selectedStatus = (TableStatus)(from c in context.TableStatus
                                           where c.Status == this.ComboBoxStatus.Text
                                           select c).First();

            TableOrders newRow = new TableOrders();

            newRow.idCar    = selectedCar.Id;
            newRow.idPerson = selectedPersonID;
            newRow.Date     = this.DatePickerBirth.SelectedDate;
            newRow.Amount   = Convert.ToDecimal(this.TextBoxAmount.Text); //!!!
            newRow.StatusID = selectedStatus.Id;

            context.TableOrders.Add(newRow);
            context.SaveChanges();
            this.Close();
        }
Пример #3
0
        private void ButtonDel_Click(object sender, RoutedEventArgs e)
        {
            TablePersons row = new TablePersons();

            row = (TablePersons)this.DataGridPersons.SelectedItems[0];
            int id_del = row.Id;

            context.TablePersons.Remove(context.TablePersons.Find(id_del));
            context.SaveChanges();
            RefreshWindow();
        }
Пример #4
0
        private void RemoveOrder_Click(object sender, RoutedEventArgs e)
        {
            FuncOrders1_Result selectedRow = new FuncOrders1_Result();

            selectedRow = (FuncOrders1_Result)this.DataGridOrders.SelectedItems[0];

            TableOrders rowForDel = new TableOrders();

            rowForDel = (from c in context.TableOrders where c.Id == selectedRow.id select c).First();

            context.TableOrders.Remove(rowForDel);
            context.SaveChanges();
            RefreshWindow();
        }
Пример #5
0
        private void ButtonOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                row.FirstName   = this.TextBoxFNameNew.Text;
                row.LastName    = this.TextBoxLNameNew.Text;
                row.DateOfBirth = this.DatePikerNew.DisplayDate;
                row.Address     = this.TextBoxAddressNew.Text;
                row.Phone       = this.TextBoxPhoneNew.Text;
                row.E_mail      = this.TextBoxEmailNew.Text;

                context.SaveChanges();
                this.Close();
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
        }
Пример #6
0
        private void ButtonOK_Click(object sender, RoutedEventArgs e)
        {
            TableOrders editedOrder = new TableOrders();

            editedOrder = (TableOrders)(from c in context.TableOrders where c.Id == selectedRow.id select c).First();

            editedOrder.idPerson = editedPersonID;
            editedOrder.idCar    = editedCarID;
            editedOrder.Date     = this.DatePickedDateEdited.SelectedDate;
            editedOrder.Amount   = Convert.ToDecimal(this.TextBoxAmountEdited.Text);

            TableStatus editedStatus = new TableStatus();

            editedStatus = (from c in context.TableStatus
                            where c.Status == this.ComboBoxEditStatus.Text
                            select c).First();
            editedOrder.StatusID = editedStatus.Id;

            context.SaveChanges();
            this.Close();
        }
Пример #7
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();
        }
Пример #8
0
        private void ButtonAdd_Click(object sender, RoutedEventArgs e)
        {
            TableCars newCar = new TableCars();
            var       row1   = (TableMakers)(from c in context.TableMakers
                                             where c.Maker == this.ComboBoxMaker.Text
                                             select c).First();

            newCar.MakerID = (int)row1.Id;

            var row2 = (TableModels)(from c in context.TableModels
                                     where c.Model == this.ComboBoxModel.Text
                                     select c).First();

            newCar.ModelID = (int)row2.Id;

            newCar.Year = this.DatePicketYear.SelectedDate;
            newCar.VIN  = this.TextBoxVIN.Text;

            context.TableCars.Add(newCar);
            context.SaveChanges();
            this.Close();
        }
Пример #9
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);
            }
        }