コード例 #1
0
 public void FillData()//заполнить список
 {
     Drivers.Clear();
     foreach (var item in Driverr.GetAllDriver())
     {
         Drivers.Add(item);
     }
 }
コード例 #2
0
        private void button_Click3(object sender, RoutedEventArgs e)
        {
            try
            {
                Car.Items.Clear();
            }
            catch
            {
            }
            var driver = new Driverr()
            {
                Company_Id = MainWindowDriver._companyId,
            };

            Add_Car();
        }
コード例 #3
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            var user = Driverr.GetDriver(Driver.Text);

            if (user == null)
            {
                if (Driver.Text == "")
                {
                    MessageBox.Show("Введите Ф.И.О. ");
                }
                if (Driver.Text != "")
                {
                    if (Car.Text == "")
                    {
                        MessageBox.Show("Выберите гос.номер. ");
                    }
                    if (Car.Text != "")
                    {
                        if (Company.Text == "")
                        {
                            MessageBox.Show("Выберите организацию ");
                        }
                        if (Company.Text != "")
                        {
                            {
                                var driver = new Driverr()
                                {
                                    Company_Id = MainWindowDriver._companyId,
                                    Car_Id     = MainWindowDriver._carId,
                                    Driver     = Driver.Text,
                                    Phone      = Phone.Text,
                                    Adres      = Adres.Text
                                };
                                driver.Insert();
                                Close();
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Такой Водитель уже есть");
            }
        }
コード例 #4
0
 private void btnRemove_Click(object sender, RoutedEventArgs e)
 {
     if (Name_Password.Admin == "Администратор")
     {
         try
         {
             if ((Driverr)lBox.SelectedItem == null)
             {
                 throw new Exception("Не выбрана строка, произведите выбор");
             }
             var id = ((Driverr)lBox.SelectedItem).Driver_Id;
             Driverr.Delete(id);
             if (Radio == "5")
             {
                 FillData6();
             }
             if (Radio == "4")
             {
                 FillData();
             }
             if (Radio == "3")
             {
                 FillData2();
             }
             if (Radio == "2")
             {
                 FillData4();
             }
             if (Radio == "1")
             {
                 FillData();
             }
         }
         catch (Exception h)
         {
             MessageBox.Show(h.Message);
         }
     }
     else
     {
         MessageBox.Show("Права доступа ограничены ");
     }
 }
コード例 #5
0
 private void btnEdit_Click(object sender, RoutedEventArgs e)
 {
     if (Name_Password.Admin == "Администратор")
     {
         try
         {
             _driverId = ((Driverr)lBox.SelectedItem).Driver_Id;
             {
                 driver = (Driverr)lBox.SelectedItem;
                 driver.Update();
                 if (Radio == "5")
                 {
                     FillData6();
                 }
                 if (Radio == "4")
                 {
                     FillData5();
                 }
                 if (Radio == "3")
                 {
                     FillData2();
                 }
                 if (Radio == "2")
                 {
                     FillData4();
                 }
                 if (Radio == "1")
                 {
                     FillData();
                 }
             }
         }
         catch (Exception)
         {
             MessageBox.Show("Не выбрана строка, произведите выбор");
         }
     }
     else
     {
         MessageBox.Show("Права доступа ограничены ");
     }
 }
コード例 #6
0
        public static IEnumerable <Driverr> GetAllDriver2()
        {
            var           commandString = "SELECT D.Driver_Id, D.Company_Id, D.Car_Id, D.Driver, D.Phone, D.Adres, Co.Name, C.Number FROM Drivers AS D Join Companys AS Co ON Co.Company_Id = D.Company_Id Join Cars AS C ON C.Car_Id = D.Car_Id Where C.Number= '" + MainWindowDriver.name + "' ";
            SQLiteCommand getAllCommand = new SQLiteCommand(commandString, connection);

            connection.Open();
            var reader = getAllCommand.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    var driver_Id  = reader.GetInt32(0);
                    var company_Id = reader.GetInt32(1);
                    var car_Id     = reader.GetInt32(2);
                    var driver     = reader.GetString(3);
                    var phone      = reader.GetString(4);
                    var adres      = reader.GetString(5);
                    var name       = reader.GetString(6);
                    var number     = reader.GetString(7);
                    var driverr    = new Driverr
                    {
                        Driver_Id  = driver_Id,
                        Company_Id = company_Id,
                        Car_Id     = car_Id,
                        Name       = name,
                        Driver     = driver,
                        Phone      = phone,
                        Adres      = adres,
                        Number     = number
                    };
                    yield return(driverr);
                }
            }
            ;
            connection.Close();
        }