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();
            }
        }
Ejemplo n.º 2
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();
            }
        }