示例#1
0
        public static void SetCurriculum(Curriculum curr)
        {
            SqlConnection     sConn = new SqlConnection(Globals.connString);
            DataSet           Data  = new DataSet();
            SqlDataAdapter    da;
            SqlCommandBuilder cmdBuilder;

            //Set the connection string of the SqlConnection object to connect
            //to the SQL Server database in which you created the sample
            //table.

            try { sConn.Open(); }
            catch (Exception ex) { throw ex; }

            //Initialize the SqlDataAdapter object by specifying a Select command
            //that retrieves data from the sample table.
            da = new SqlDataAdapter("SELECT * FROM Curriculum WHERE semester_id=" + curr.Semester, sConn);

            //Initialize the SqlCommandBuilder object to automatically generate and initialize
            //the UpdateCommand, InsertCommand, and DeleteCommand properties of the SqlDataAdapter.
            cmdBuilder = new SqlCommandBuilder(da);

            //Populate the DataSet by running the Fill method of the SqlDataAdapter.
            da.Fill(Data, "DATA");
            Data.Tables["DATA"].Rows[0]["Courses"] = "";
            foreach (Course crs in curr.Courses)
            {
                Data.Tables["DATA"].Rows[0]["Courses"] += crs.Name + ",";
            }

            da.Update(Data, "DATA");
            //Close the database connection.
            sConn.Close();
        }
示例#2
0
        public CreateCurri(List <Course> l_c)
        {
            InitializeComponent();

            String[] arr = new String[8];
            sm = new Curriculum [8];
            for (int i = 0; i < 8; i++)
            {
                sm[i]         = new Curriculum();
                sm[i].Courses = new List <Course>();
                string[] words = SqlWorker.GetCurriculumString(i + 1).Split(',');
                foreach (string word in words)
                {
                    if (word == "")
                    {
                        continue;
                    }
                    Course temp = l_c.Find(crs => crs.Name == word);
                    sm[i].Courses.Add(temp);
                }
            }
            foreach (Course cur in this.sm[0].Courses)
            {
                if (cur == null)
                {
                    continue;
                }
                this.semester_list_box.Items.Add(cur);
            }

            foreach (Course cur in l_c)
            {
                Boolean flag = true;
                for (int i = 0; i < 8; i++)
                {
                    if (sm[i].Courses != null)
                    {
                        foreach (Course c in sm[i].Courses)
                        {
                            if (cur.Name == c.Name)
                            {
                                flag = false;
                            }
                        }
                    }
                }
                if (flag)
                {
                    this.courses_list_box.Items.Add(cur);
                }
            }

            this.add_btn.Enabled   = false;
            this.rem_btn.Enabled   = false;
            this.rem_btn.BackColor = Color.Gray;
            this.add_btn.BackColor = Color.Gray;
        }
示例#3
0
        private void Show_Curri_btn_Click(object sender, EventArgs e)
        {
            List <Curriculum> l_c = new List <Curriculum>();

            for (int i = 1; i < 9; i++)
            {
                Curriculum cur = new Curriculum(i);
                l_c.Add(cur);
            }
            Form form = new CurriculumsList(l_c);

            form.Show();
        }