示例#1
0
 public StudentCatalog getCatalog()
 {
     if (catalog == null)
     {
         catalog = new StudentCatalog();
     }
     return(catalog);
 }
示例#2
0
 public void writeStudents(StudentCatalog catalog)
 {
     using (StreamWriter file = new StreamWriter(studentslist)) {
         List <Student> list = catalog.getList();
         foreach (Student student in list)
         {
             file.WriteLine(student.Id + " " + student.Name + " " + student.Surname + " " + student.BirthDate);
         }
     }
 }
        private void setup()
        {
            ObjectFactory factory = ObjectFactory.getInstance();

            mainform = factory.getMainForm();
            catalog  = factory.getCatalog();
            query    = (QueryBase)factory.create("query");
            conn     = (ConnectionBase)factory.create("connection");
            conn.setConnString(ProjectVariables.getConnectionString());
            query.setConnection(conn);

            if (setting == add_arg)//adding operation
            {
                button1.Text = "Add";
            }
            else
            {                 //updating opertaion
                button1.Text = "Update";
                setTextBoxes();
            }
        }
示例#4
0
        private void setup()
        {
            ObjectFactory factory = ObjectFactory.getInstance();

            factory.setMainForm(this);
            catalog = factory.getCatalog();
            query   = (QueryBase)factory.create("query");
            conn    = (ConnectionBase)factory.create("connection");
            conn.setConnString(ProjectVariables.getConnectionString());
            query.setConnection(conn);

            try
            {
                conn.Connect();
                string selectQ = "SELECT * FROM students";
                query.setSQL(selectQ);
                query.executeQuery();
                int i = 0;
                query.first();
                while (!query.eof())
                {
                    Student student = new Student();
                    student.Id        = query.getFiedValueINT("ID");
                    student.Name      = query.getFiedValueSTRING("NAME");
                    student.Surname   = query.getFiedValueSTRING("SURNAME");
                    student.BirthDate = query.getFiedValueSTRING("BIRTH_DATE");
                    catalog.add(student);
                    Console.WriteLine(i); i++;
                    query.next();
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Setup error:" + ex.ToString());
            }
            finally
            {
                conn.Disconnect();
            }
        }