Пример #1
0
        public static HealthOrgClass[] LoadHealthOrgList()
        {
            try
            {
                List <HealthOrgClass> healthClass = new List <HealthOrgClass>();
                string query = $"select id, FullName, ShortName, Address, area_id from childrenshealthorganization where deleted = 0";

                using (MySqlConnection sqlConnection = ConnectionClass.GetStringConnection())
                {
                    sqlConnection.Open();

                    using (MySqlCommand sqlCommand = new MySqlCommand(query, sqlConnection))
                    {
                        using (MySqlDataReader reader = sqlCommand.ExecuteReader())
                        {
                            if (reader.HasRows)
                            {
                                while (reader.Read())
                                {
                                    healthClass.Add(new HealthOrgClass {
                                        id = int.Parse(reader["id"].ToString()), FullName = reader["FullName"].ToString(), ShortName = reader["ShortName"].ToString(), Address = reader["Address"].ToString(), area_id = int.Parse(reader["area_id"].ToString())
                                    });
                                }
                            }
                        }
                    }
                }

                if (healthClass.Count > 0)
                {
                    HealthOrgClass[] ho = new HealthOrgClass[healthClass.Count];

                    for (int i = 0; i < healthClass.Count; i++)
                    {
                        ho[i] = healthClass[i];
                    }

                    return(ho);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, $"\r\n#---------#\r\n{ex.StackTrace}\r\n##---------##\r\n{ex.Message}\r\n###---------###\r\n{ex.Source}");
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
        }
Пример #2
0
        bool EdIn = true; //"true" if you edit data, if you insert data then EdIn = "false"

        public HealthOrgForm(bool _EdIn, int _area_id, int _id)
        {
            try
            {
                InitializeComponent();
                LoadArea();
                EdIn = _EdIn;
                if (_EdIn)
                {
                    health = Classes.HealthOrgClass.LoadHealthOrgList(_id, _area_id);
                    EditData();
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, $"\r\n#---------#\r\n{ex.StackTrace}\r\n##---------##\r\n{ex.Message}\r\n###---------###\r\n{ex.Source}");
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #3
0
        public static HealthOrgClass LoadHealthOrgList(int id, int area_id)
        {
            try
            {
                HealthOrgClass healthClass = new HealthOrgClass();
                string         query       = $"select id, FullName, ShortName, Address, area_id from childrenshealthorganization where deleted = 0 and area_id = {area_id} and id = {id}";

                using (MySqlConnection sqlConnection = ConnectionClass.GetStringConnection())
                {
                    sqlConnection.Open();

                    using (MySqlCommand sqlCommand = new MySqlCommand(query, sqlConnection))
                    {
                        using (MySqlDataReader reader = sqlCommand.ExecuteReader())
                        {
                            if (reader.HasRows)
                            {
                                while (reader.Read())
                                {
                                    healthClass.id        = int.Parse(reader["id"].ToString());
                                    healthClass.FullName  = reader["FullName"].ToString();
                                    healthClass.ShortName = reader["ShortName"].ToString();
                                    healthClass.Address   = reader["Address"].ToString();
                                    healthClass.area_id   = int.Parse(reader["area_id"].ToString());
                                }
                            }
                        }
                    }
                }

                return(healthClass);
            }
            catch (Exception ex)
            {
                logger.Error(ex, $"\r\n#---------#\r\n{ex.StackTrace}\r\n##---------##\r\n{ex.Message}\r\n###---------###\r\n{ex.Source}");
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
        }