public ShowCivil()
 {
     InitializeComponent();
     DataContext = _civilModelView = new ModelView.CivilModelView();
     _civilModelView.GetCivilEngineer();
     _civilModelView.IsUpdateBtnVisible = Visibility.Collapsed;
 }
        /// <summary>
        /// Retutn the selected Civil by Id
        /// </summary>
        /// <param name="civilId"></param>
        /// <returns></returns>
        public ObservableCollection <ModelView.CivilModelView> ReturnCivilById(int civilId)
        {
            lock (_lockSQLite)
            {
                _listOfOneCivilEngineer = new ObservableCollection <ModelView.CivilModelView>();

                try
                {
                    _sqliteConnection = new SQLiteConnection("Data Source=" + _SQLiteCredential + ";Version=3;");
                    _sqliteConnection.OpenAsync();
                    string selectCivilEngineer = @"Select * from CivilEngineerTable where CivilId ='" + civilId + "'";

                    _sqliteCommand = new SQLiteCommand(selectCivilEngineer, _sqliteConnection);
                    SQLiteDataReader reader = _sqliteCommand.ExecuteReader();

                    while (reader.Read())
                    {
                        _onecivilEngineer = new ModelView.CivilModelView
                        {
                            CivilId           = int.Parse(reader["CivilId"].ToString()),
                            CivilFirstName    = reader["CivilFirstName"].ToString(),
                            CivilLastName     = reader["CivilLastName"].ToString(),
                            Speciality        = reader["CivilSpeciality"].ToString(),
                            NumberTEE         = reader["NumberTEE"].ToString(),
                            CivilAFM          = reader["CivilAFM"].ToString(),
                            CivilDOY          = reader["CivilDOY"].ToString(),
                            CivilTele         = reader["CivilTele"].ToString(),
                            CivilNumberID     = reader["CivilNumberID"].ToString(),
                            Nomos             = reader["Nomos"].ToString(),
                            CivilMunicipality = reader["CivilMunicipality"].ToString(),
                            PlaceOfHouse      = reader["PlaceOfHouse"].ToString(),
                            CivilAddress      = reader["CivilAddress"].ToString(),
                            CivilNumber       = reader["CivilNumber"].ToString(),
                            CivilPostCode     = reader["CivilPostCode"].ToString()
                        };
                        _listOfOneCivilEngineer.Add(_onecivilEngineer);
                    }
                }
                catch (Exception)
                {
                    _listOfOneCivilEngineer = new ObservableCollection <ModelView.CivilModelView>();
                }
                finally
                {
                    _sqliteConnection.Close();
                }
                return(_listOfOneCivilEngineer);
            }
        }
        /// <summary>
        /// Return all the Civils to display them into PDF
        /// </summary>
        /// <returns></returns>
        public ObservableCollection <ModelView.CivilModelView> ReturnInfoOfAllCivilEngineer()
        {
            lock (_lockSQLite)
            {
                _listOfCivilEngineer = new ObservableCollection <ModelView.CivilModelView>();

                try
                {
                    _sqliteConnection = new SQLiteConnection("Data Source=" + _SQLiteCredential + ";Version=3;");
                    _sqliteConnection.OpenAsync();
                    string selectCivilEngineer = @"Select CivilFirstName,CivilLastName,CivilId,CivilSpeciality,CivilTele from CivilEngineerTable";

                    _sqliteCommand = new SQLiteCommand(selectCivilEngineer, _sqliteConnection);
                    SQLiteDataReader reader = _sqliteCommand.ExecuteReader();

                    while (reader.Read())
                    {
                        _civilEngineer = new ModelView.CivilModelView
                        {
                            CivilFirstName = reader["CivilFirstName"].ToString(),
                            CivilLastName  = reader["CivilLastName"].ToString(),
                            CivilId        = int.Parse(reader["CivilId"].ToString()),
                            Speciality     = reader["CivilSpeciality"].ToString(),
                            CivilTele      = reader["CivilTele"].ToString()
                        };
                        _listOfCivilEngineer.Add(_civilEngineer);
                    }
                }
                catch (Exception)
                {
                    _listOfCivilEngineer = new ObservableCollection <ModelView.CivilModelView>();
                }
                finally
                {
                    _sqliteConnection.Close();
                }

                return(_listOfCivilEngineer);
            }
        }
Esempio n. 4
0
 public CreateCivil()
 {
     InitializeComponent();
     DataContext = _CivilModelView = new ModelView.CivilModelView();
 }