Beispiel #1
0
        public async Task <bool> UploadData()
        {
            bool isUpdate = false;

            //Выгрузка записей
            isUpdate = await UploadEntry();

            //Выгрузка пациентов
            isUpdate = await UploadPatient();

            if (connect.IsConnect())
            {
                //Выгрузка связи Тип услуги-Услуги-Специалист
                string selectServiceQuery = "SELECT * FROM type_service;";
                using (MySqlCommand command = new MySqlCommand(selectServiceQuery, connect.GetConnect))
                {
                    using (DbDataReader reader = await command.ExecuteReaderAsync())
                    {
                        if (reader.HasRows)
                        {
                            isUpdate = true;
                            while (await reader.ReadAsync())
                            {
                                GetTypeService.Add(new TypeService()
                                {
                                    Lable = reader.GetString(1),
                                    GetServiceOfDoctor = GetDoctorOfService(await reader.GetFieldValueAsync <uint>(0))
                                });
                            }
                        }
                        reader.Close();
                    }
                }
                connect.Close();
            }
            return(isUpdate);
        }
Beispiel #2
0
 public async Task Auth(string login, string pwd)
 {
     if (connect.IsConnect())
     {
         string authQuery = "SELECT id_user, id_group FROM accounts " +
                            "WHERE login = @login AND pwd = @pwd LIMIT 1;";
         using (MySqlCommand command = new MySqlCommand(authQuery, connect.GetConnect))
         {
             command.Parameters.AddWithValue("@login", login);                    //логин
             command.Parameters.AddWithValue("@pwd", GetHash(MD5.Create(), pwd)); //пароль
             using (System.Data.Common.DbDataReader reader = await command.ExecuteReaderAsync())
             {
                 if (reader.HasRows)
                 {
                     while (await reader.ReadAsync())
                     {
                         HashID  = Encoding.UTF8.GetBytes(reader.GetString(0)); //перевод хэша в массив битов
                         idGroup = await reader.GetFieldValueAsync <uint>(1);
                     }
                     reader.Close();
                 }
                 else
                 {
                     AuthoStatysEvent("Неправильный логин или пароль");
                 }
             }
         }
         if (idGroup.Equals(1122)) //Регистратор
         {
             string selectRegistratorQuery = "SELECT id, fio FROM registrator " +
                                             "WHERE id_user = @idUser";
             using (MySqlCommand command = new MySqlCommand(selectRegistratorQuery, connect.GetConnect))
             {
                 string id = Encoding.UTF8.GetString(HashID); //перевод массива битов в хэш
                 command.Parameters.AddWithValue("@idUser", id);
                 using (System.Data.Common.DbDataReader reader = await command.ExecuteReaderAsync())
                 {
                     if (reader.HasRows)
                     {
                         while (await reader.ReadAsync())
                         {
                             GetEmployees = new Registrator()
                             {
                                 Id  = await reader.GetFieldValueAsync <uint>(0),
                                 Fio = reader.GetString(1)
                             };
                         }
                         reader.Close();
                     }
                 }
             }
             GetGroup = Group.Registrator;
         }
         else if (idGroup.Equals(2211))  //Доктор
         {
             string selectRegistratorQuery = "SELECT id, fio FROM doctor WHERE id_user = @idUser";
             using (MySqlCommand command = new MySqlCommand(selectRegistratorQuery, connect.GetConnect))
             {
                 string id = Encoding.UTF8.GetString(HashID); //перевод массива битов в хэш
                 command.Parameters.AddWithValue("@idUser", id);
                 using (System.Data.Common.DbDataReader reader = await command.ExecuteReaderAsync())
                 {
                     if (reader.HasRows)
                     {
                         while (await reader.ReadAsync())
                         {
                             GetEmployees = new Doctor()
                             {
                                 Id  = await reader.GetFieldValueAsync <uint>(0),
                                 Fio = reader.GetString(1)
                             };
                         }
                         reader.Close();
                     }
                 }
             }
             GetGroup = Group.Doctor;
         }
         connect.Close();
     }
 }