Beispiel #1
0
 private void fillDataGridView()
 {
     DaoSession daoSession = new DaoSession();
     daoSession.openConnection();
     daoSession.populateDataGridView(dgvLastWatched, user.getLogin());
     daoSession.closeConnection();
 }
 private void btnAddMode_Click(object sender, EventArgs e)
 {
     if (verifyStringToBeAdded(cbbMode.Text, cbbMode.Items.Cast<String>()))
     {
         DaoSession daoSession = new DaoSession();
         daoSession.openConnection(this.GetType(), "sqlErrorHandler");
         daoSession.insertMode(cbbMode.Text, this.GetType(), "sqlErrorHandler");
         daoSession.closeConnection();
         loadModes();
         updateLbMode();
     }
     cbbMode.Focus();
 }
Beispiel #3
0
        private void dgvLastWatched_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            String codeString = dgvLastWatched.Rows[e.RowIndex].Cells["code"].FormattedValue.ToString();

            DaoSession daoSession = new DaoSession();
            daoSession.openConnection();
            Session s = daoSession.getSessionByCode(int.Parse(codeString));
            daoSession.closeConnection();

            if (s != null)
            {
                AddScreeningForm asf = new AddScreeningForm(user, s);
                asf.ShowDialog();
                asf.Dispose();
            }
        }
Beispiel #4
0
 private String getModeByCode(int code)
 {
     String res;
     DaoSession daoSession = new DaoSession();
     daoSession.openConnection();
     MySqlDataReader modeDataReader = daoSession.executeQuery(
         "SELECT name FROM MODE WHERE code = " + code);
     if (modeDataReader == null || !modeDataReader.HasRows)
         return null;
     modeDataReader.Read();
     res = modeDataReader.GetString("name");
     daoSession.closeConnection();
     return res;
 }
Beispiel #5
0
 public int getLastVideoCode()
 {
     int lastCode = 0;
     DaoSession daoSession = new DaoSession();
     daoSession.openConnection();
     MySqlDataReader dataReader = daoSession.executeQuery("SHOW TABLE STATUS LIKE 'SESSION'");
     if (dataReader != null && dataReader.HasRows)
     {
         dataReader.Read();
         lastCode = dataReader.GetInt16("auto_increment") - 1;
     }
     daoSession.closeConnection();
     return lastCode;
 }
Beispiel #6
0
        private void simpleQuery()
        {
            DaoSession daoSession = new DaoSession();
            daoSession.openConnection();
            List<Session> sessions = daoSession.simpleQuery(tbSimple.Text, user.getLogin());
            daoSession.closeConnection();

            String output = "";
            if (sessions != null)
                foreach (Session s in sessions)
                {
                    Video v = s.getVideo();
                    output += s.getDate() + " " + v.getNationalTitle() + " " + v.getDirector() + " " + s.getEvaluetion() + " " + s.getMode() + " " + s.getComment() + Environment.NewLine;
                    AddScreeningForm asf = new AddScreeningForm(user, s);
                    asf.ShowDialog();
                    asf.Dispose();
                }
            MessageBox.Show(output);
        }
Beispiel #7
0
        private void MainForm_Shown(object sender, EventArgs e)
        {
            LoginForm lf = new LoginForm();
            this.AddOwnedForm(lf);
            lf.ShowDialog(this);
            user = lf.getUser();
            if (user == null)
                Application.Exit();
            else
            {
                ssMain.Items.Add("Usuário: " + user.getName());

                DaoSession daoSession = new DaoSession();
                daoSession.openConnection(this.GetType(), "sqlErrorHandler");
                daoSession.createTable(this.GetType(), "sqlErrorHandler");
                daoSession.closeConnection();

                fillDataGridView();
            }
        }
 private void loadModes()
 {
     DaoSession daoSession = new DaoSession();
     daoSession.openConnection(this.GetType(), "sqlErrorHandler");
     cbbMode.Items.Clear();
     cbbMode.Items.AddRange(daoSession.retrieveAllModes().ToArray());
     daoSession.closeConnection();
 }
        private void btnSaveScreening_Click(object sender, EventArgs e)
        {
            if (!verifyRequiredFields())
                MessageBox.Show("Preencha titulo nacional ou titulo original para poder registrar.");
            else
            {
                createSession();
                DaoSession daoSession = new DaoSession();
                daoSession.openConnection(this.GetType(), "sqlErrorHandler");

                if (updating)
                {
                    if (daoSession.updateSession(session, this.GetType(), "sqlErrorHandler"))
                    {
                        //                        MessageBox.Show("Atualizações salvas!");
                    }
                }
                else
                {
                    if (daoSession.insertSession(session, this.GetType(), "sqlErrorHandler"))
                    {
                        //                        MessageBox.Show("Video registrado!");
                    }
                }
                daoSession.closeConnection();
                this.Close();
            }
        }