Exemplo n.º 1
0
        public BindingList <GlobalClass.subjectMapper> SelectSubjectClr()
        {
            string query = @"SELECT a.ID, a.Name, a.Description FROM subject as a";
            BindingList <GlobalClass.subjectMapper> tempSubjectList = new BindingList <GlobalClass.subjectMapper>();

            if (this.openConnection() == true)
            {
                MySqlCommand    cmd        = new MySqlCommand(query, dbConnect);
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    int    I = (int)((long)dataReader["ID"]);
                    string N = (string)dataReader["Name"];
                    string D = (string)dataReader["Description"];
                    GlobalClass.subjectMapper tempSubject = new GlobalClass.subjectMapper(I, N, D);
                    tempSubjectList.Add(tempSubject);
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                this.CloseConnection();

                //return list to be displayed
                return(tempSubjectList);
            }
            else
            {
                return(tempSubjectList);
            }
        }
Exemplo n.º 2
0
 private void SaveBtn_Click(object sender, EventArgs e)
 {
     AlteringSubject             = new GlobalClass.subjectMapper();
     AlteringSubject.Name        = this.subjName.Text;
     AlteringSubject.Description = this.subjDescription.Text;
     elementBase.InsertSubject(AlteringSubject);
     this.Close();
 }
Exemplo n.º 3
0
 public void InsertSubject(GlobalClass.subjectMapper InsertingSubject)
 {
     if (this.openConnection() == true)
     {
         MySqlCommand cmd = new MySqlCommand();
         cmd.Connection = dbConnect;
         string query = @"INSERT INTO subject (`Name`,`Description`)
                             VALUES ('" + InsertingSubject.Name + "','" + InsertingSubject.Description + "')";
         cmd.CommandText = query;
         cmd.ExecuteNonQuery();
         //close connection
         this.CloseConnection();
     }
 }