Пример #1
0
        public async Task <List <string> > GetCompanyAllNameDataSqlAsync()
        {
            try
            {
                List <string> workers     = new List <string>();
                ReadDb        db          = new ReadDb();
                string        QueryString = "select Company.NameCompany from Company";

                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    await connection.OpenAsync();

                    SqlCommand command = new SqlCommand(QueryString, connection);
                    using (SqlDataReader sdr = command.ExecuteReader())
                    {
                        while (sdr.Read())
                        {
                            workers.Add(sdr["NameCompany"].ToString());
                        }
                    }
                    return(workers);
                }
            }
            catch (Exception ex)
            {
                return(new List <string>());
            }
        }
Пример #2
0
        public async Task <List <ItemWorker> > GetWorlerDataSqlAsync(string id = "%")
        {
            try
            {
                List <ItemWorker> workers     = new List <ItemWorker>();
                ReadDb            db          = new ReadDb();
                string            QueryString = "select Worker.IdTable, Worker.Surname, Worker._Name, Worker.Patronymic, Worker.EmploymentDate, Position._Name as '_NamePos', Company.NameCompany" +
                                                " from Worker" +
                                                " join Position on Worker.PositionId = Position.IdTable" +
                                                " join Company on Worker.CompanyId = Company.IdTable" +
                                                " where Worker.IdTable like '" + id + "'";

                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    await connection.OpenAsync();

                    SqlCommand command = new SqlCommand(QueryString, connection);
                    using (SqlDataReader sdr = command.ExecuteReader())
                    {
                        while (sdr.Read())
                        {
                            ItemWorker worker = new ItemWorker();
                            worker.IdTable        = Convert.ToInt32(sdr["IdTable"]);
                            worker.Surname        = sdr["Surname"].ToString();
                            worker._Name          = sdr["_Name"].ToString();
                            worker.Patronymic     = sdr["Patronymic"].ToString();
                            worker.EmploymentDate = DateTime.Parse(sdr["EmploymentDate"].ToString());
                            worker.Position       = sdr["_NamePos"].ToString();
                            worker.Company        = sdr["NameCompany"].ToString();
                            workers.Add(worker);
                        }
                    }
                    return(workers);
                }
            }
            catch (Exception ex)
            {
                return(new List <ItemWorker>());
            }
        }
Пример #3
0
        public async Task <List <ItemCompany> > GetCompanyDataSqlAsync()
        {
            try
            {
                List <ItemCompany> workers     = new List <ItemCompany>();
                ReadDb             db          = new ReadDb();
                string             QueryString = "select Company.IdTable, Company.NameCompany, CompanySize._Name as 'CompanySize', FormOfIncorporation._Name as 'FormOfIncorporation'" +
                                                 " from Company" +
                                                 " join FormOfIncorporation on Company.FormOfIncorporationId = FormOfIncorporation.IdTable" +
                                                 " join CompanySize on Company.CompanySizeId = CompanySize.IdTable";

                using (SqlConnection connection = new SqlConnection(connectionString))
                {
                    await connection.OpenAsync();

                    SqlCommand command = new SqlCommand(QueryString, connection);
                    using (SqlDataReader sdr = command.ExecuteReader())
                    {
                        while (sdr.Read())
                        {
                            ItemCompany worker = new ItemCompany();
                            worker.IdTable             = Convert.ToInt32(sdr["IdTable"]);
                            worker.NameCompany         = sdr["NameCompany"].ToString();
                            worker.CompanySize         = sdr["CompanySize"].ToString();
                            worker.FormOfIncorporation = sdr["FormOfIncorporation"].ToString();
                            workers.Add(worker);
                        }
                    }
                    return(workers);
                }
            }
            catch (Exception ex)
            {
                return(new List <ItemCompany>());
            }
        }