示例#1
0
        private void AddGroup_Load(object sender, EventArgs e)
        {
            string connection = "Data Source= DESKTOP-A4JVK6F\\SQLEXPRESS; Initial Catalog=AZTU; Integrated Security=true;";

            using (SqlConnection sqlConnection = new SqlConnection(connection))
            {
                sqlConnection.Open();
                string         facConnect = "Data Source=DESKTOP-A4JVK6F\\SQLEXPRESS; Initial Catalog=AZTU; Integrated Security=true;";
                List <Faculty> faculties  = new List <Faculty>();

                using (SqlConnection facConnection = new SqlConnection(facConnect))
                {
                    facConnection.Open();
                    string facQuery = "SELECT F.ID AS FacID, F.Name AS FacName FROM Faculties AS F";
                    using (SqlCommand facCommand = new SqlCommand(facQuery, facConnection))
                    {
                        using (SqlDataReader sqlDataReader = facCommand.ExecuteReader())
                        {
                            using (DataTable dataTable = new DataTable())
                            {
                                while (sqlDataReader.Read())
                                {
                                    Faculty faculty = new Faculty()
                                    {
                                        ID   = int.Parse(sqlDataReader["FacID"].ToString()),
                                        Name = sqlDataReader["FacName"].ToString()
                                    };
                                    faculties.Add(faculty);
                                }
                            }
                        }
                    }
                }

                List <FacCombo> facCombos = new List <FacCombo>();
                for (int i = 0; i < faculties.Count; i++)
                {
                    FacCombo facCombo = new FacCombo()
                    {
                        ID   = faculties[i].ID,
                        Name = faculties[i].Name
                    };
                    facCombos.Add(facCombo);
                }
                cmbx_faculty.ValueMember   = "ID";
                cmbx_faculty.DisplayMember = "Name";
                cmbx_faculty.DataSource    = facCombos;
            }
        }
示例#2
0
        private void StudentRatingForFaculty_Load(object sender, EventArgs e)
        {
            string connection = "Data Source= DESKTOP-A4JVK6F\\SQLEXPRESS; Initial Catalog=AZTU; Integrated Security=true;";

            using (SqlConnection sqlConnection = new SqlConnection(connection))
            {
                sqlConnection.Open();

                //--------------- Session combobox on load--------------------------

                string sesQuery = " SELECT ID ,Name FROM Sessions";
                using (SqlCommand sesCommand = new SqlCommand(sesQuery, sqlConnection))
                {
                    SqlDataReader sesReader = sesCommand.ExecuteReader();
                    DataTable     sesTable  = new DataTable();

                    sesTable.Columns.Add("ID", typeof(string));
                    sesTable.Columns.Add("Name", typeof(string));

                    sesTable.Load(sesReader);

                    cmbx_session.ValueMember   = "ID";
                    cmbx_session.DisplayMember = "Name";
                    cmbx_session.DataSource    = sesTable;
                }

                //----------------- Faculty combobox on load ----------------------------
                string         facConnect = "Data Source= DESKTOP-A4JVK6F\\SQLEXPRESS; Initial Catalog=AZTU; Integrated Security=true;";
                List <Faculty> faculties  = new List <Faculty>();

                using (SqlConnection facConnection = new SqlConnection(facConnect))
                {
                    facConnection.Open();
                    string facQuery = "SELECT F.ID AS FacID, F.Name AS FacName FROM Faculties AS F";
                    using (SqlCommand facCommand = new SqlCommand(facQuery, facConnection))
                    {
                        using (SqlDataReader sqlDataReader = facCommand.ExecuteReader())
                        {
                            using (DataTable dataTable = new DataTable())
                            {
                                while (sqlDataReader.Read())
                                {
                                    Faculty faculty = new Faculty()
                                    {
                                        ID   = int.Parse(sqlDataReader["FacID"].ToString()),
                                        Name = sqlDataReader["FacName"].ToString()
                                    };
                                    faculties.Add(faculty);
                                }
                            }
                        }
                    }
                }

                List <FacCombo> facCombos = new List <FacCombo>();
                for (int i = 0; i < faculties.Count; i++)
                {
                    FacCombo facCombo = new FacCombo()
                    {
                        ID   = faculties[i].ID,
                        Name = faculties[i].Name
                    };
                    facCombos.Add(facCombo);
                }
                cmbx_faculty.ValueMember   = "ID";
                cmbx_faculty.DisplayMember = "Name";
                cmbx_faculty.DataSource    = facCombos;
            }
        }
示例#3
0
        private void AddPountForm_Load(object sender, EventArgs e)
        {
            #region profession combo fil on form load
            //string conString = "Data Source=DESKTOP-6D6VFHT\\TSQL;Initial Catalog=AZTU;Integrated Security=SSPI";
            //string PrfQuery = "Select ID,Name From Professions";

            //SqlConnection sqlConnection = new SqlConnection(conString);
            //sqlConnection.Open();
            //SqlCommand prfCommand = new SqlCommand(PrfQuery, sqlConnection);

            //SqlDataReader PrfReader = prfCommand.ExecuteReader();

            //DataTable PrfDtable = new DataTable();

            //PrfDtable.Columns.Add("ID", typeof(string));
            //PrfDtable.Columns.Add("Name", typeof(string));

            //PrfDtable.Load(PrfReader);

            //cmbx_profession.ValueMember = "ID";
            //cmbx_profession.DisplayMember = "Name";
            //cmbx_profession.DataSource = PrfDtable;
            //grbx_subjects.Hide();
            #endregion

            string         facConnect = "Data Source= DESKTOP-A4JVK6F\\SQLEXPRESS; Initial Catalog=AZTU; Integrated Security=true;";
            List <Faculty> faculties  = new List <Faculty>();

            using (SqlConnection facConnection = new SqlConnection(facConnect))
            {
                facConnection.Open();
                string facQuery = "SELECT F.ID AS FacID, F.Name AS FacName FROM Faculties AS F";
                using (SqlCommand facCommand = new SqlCommand(facQuery, facConnection))
                {
                    //SqlDataReader facReader = facCommand.ExecuteReader();
                    //DataTable facTable = new DataTable();

                    //facTable.Columns.Add("ID", typeof(string));
                    //facTable.Columns.Add("Name", typeof(string));

                    //facTable.Load(facReader);
                    using (SqlDataReader sqlDataReader = facCommand.ExecuteReader())
                    {
                        using (DataTable dataTable = new DataTable())
                        {
                            while (sqlDataReader.Read())
                            {
                                Faculty faculty = new Faculty()
                                {
                                    ID   = int.Parse(sqlDataReader["FacID"].ToString()),
                                    Name = sqlDataReader["FacName"].ToString()
                                };
                                faculties.Add(faculty);
                            }
                        }
                    }
                }
            }

            List <FacCombo> facCombos = new List <FacCombo>();
            for (int i = 0; i < faculties.Count; i++)
            {
                FacCombo facCombo = new FacCombo()
                {
                    ID   = faculties[i].ID,
                    Name = faculties[i].Name
                };
                facCombos.Add(facCombo);
            }
            cmbx_faculty.ValueMember   = "ID";
            cmbx_faculty.DisplayMember = "Name";
            cmbx_faculty.DataSource    = facCombos;
        }