예제 #1
0
 public RegistrationForm()
 {
     InitializeComponent();
     rcc    = new RegisterCourseController();
     labels = new List <Label>();
     cf     = new CourseFactory();
     row    = 0;
     saved  = false;
 }
예제 #2
0
        public static CourseFactory getInstance()
        {
            Object sync = new object();

            lock (sync)
            {
                if (instance == null)
                {
                    instance = new CourseFactory();
                }
                return(instance);
            }
        }
예제 #3
0
        public CourseFactory()
        {
            cList = new List <Course>();

            string          connectionString = "SERVER=localhost;DATABASE=cse327;UID=maac;PASSWORD=1416;";
            MySqlConnection connection       = new MySqlConnection(connectionString);

            connection.Open();

            string       query  = "select * from courses;";
            MySqlCommand sqlcmd = new MySqlCommand(query, connection);

            MySqlDataReader reader = sqlcmd.ExecuteReader();

            while (reader.Read())
            {
                Course x = new Course(reader.GetString(0), reader.GetString(1), reader.GetInt32(2), reader.GetInt32(3));
                cList.Add(x);
            }
            connection.Close();

            connectionString = "SERVER=localhost;DATABASE=cse327;UID=maac;PASSWORD=1416;";
            connection       = new MySqlConnection(connectionString);
            connection.Open();

            query  = "select * from programs;";
            sqlcmd = new MySqlCommand(query, connection);


            reader = sqlcmd.ExecuteReader();

            while (reader.Read())
            {
                foreach (Course c in cList)
                {
                    if (reader.GetString(0) == c.getId())
                    {
                        c.setProgram(reader.GetString(2));
                        break;
                    }
                }
            }

            connection.Close();


            instance = this;
        }
예제 #4
0
        public void update()
        {
            labels.ForEach(x => panel1.Controls.Remove(x));
            Label         p;
            CourseFactory cf = new CourseFactory();

            courses = CourseFactory.getInstance().getCList();
            for (int i = 0; i < courses.Count; i++)
            {
                p = new Label()
                {
                    Text = courses[i].getId(), Location = new Point(label10.Location.X, i * 30), Size = new Size(80, 20)
                };
                panel1.Controls.Add(p);
                labels.Add(p);

                p = new Label()
                {
                    Text = courses[i].getTitle(), Location = new Point(label9.Location.X, i * 30), Size = new Size(300, 20)
                };
                panel1.Controls.Add(p);
                labels.Add(p);

                p = new Label()
                {
                    Text = courses[i].getCredit().ToString(), Location = new Point(label8.Location.X, i * 30)
                };
                panel1.Controls.Add(p);
                labels.Add(p);

                p = new Label()
                {
                    Text = courses[i].getTuitionPerCredit().ToString(), Location = new Point(label7.Location.X, i * 30)
                };
                panel1.Controls.Add(p);
                labels.Add(p);

                p = new Label()
                {
                    Text = courses[i].getProgram(), Location = new Point(label6.Location.X, i * 30)
                };
                panel1.Controls.Add(p);
                labels.Add(p);
            }
        }
예제 #5
0
 public int getExtraFeeAmount()
 {
     iefc = CourseFactory.getInstance().getExtraFeeCalculator();
     return(iefc.getExtraAmount(this.getTotal()));
 }
예제 #6
0
 public Course getCourse(string id)
 {
     return(CourseFactory.getInstance().getCourse(id));
 }
예제 #7
0
 public bool addCourse(string id)
 {
     return(reg.addCourse(CourseFactory.getInstance().getCourse(id)));
 }