Esempio n. 1
0
 public void SessionConstructorTest()
 {
     Video video = null; // TODO: Initialize to an appropriate value
     float evaluetion = 0F; // TODO: Initialize to an appropriate value
     string mode = string.Empty; // TODO: Initialize to an appropriate value
     string comment = string.Empty; // TODO: Initialize to an appropriate value
     Session target = new Session(video, evaluetion, mode, comment);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
 public AddScreeningForm(User user, Session session)
     : this(user)
 {
     if (session != null)
     {
         this.session = session;
         this.video = session.getVideo();
         updating = true;
         rtbComment.Text = session.getComment();
         fillVideoInfo(video);
         btnSaveScreening.Text = "Alterar";
         btnSaveScreening.TextAlign = ContentAlignment.MiddleCenter;
     }
 }
Esempio n. 3
0
        public Session createSessionFromDataReader(MySqlDataReader dr)
        {
            Session session;
            String userLogin;
            int code = 0;
            DateTime date;
            String dateString;
            Video video;
            String mode;
            String comment;

            float evaluetion;

            if (dr.Equals(DBNull.Value)) return null;

            if (!dr["comment"].Equals(DBNull.Value))
                comment = dr.GetString("comment");
            else
                comment = "";

            if (dr["code"].Equals(DBNull.Value)) return null;
            code = dr.GetInt32("code");

            if (dr["userLogin"].Equals(DBNull.Value)) return null;
            userLogin = dr.GetString("userLogin");

            if (!dr["evaluetion"].Equals(DBNull.Value))
                evaluetion = (float)Convert.ToDouble(dr.GetDecimal("evaluetion"));
            else
                evaluetion = 0;

            DaoVideo daoVideo = new DaoVideo();
            daoVideo.openConnection();

            video = daoVideo.getVideoByCode(dr.GetInt32("videoCode"));

            date = dr.GetDateTime("date");
            dateString = date.Day + "/" + date.Month + "/" + date.Year;

            if (!dr["modeCode"].Equals(DBNull.Value))
                mode = getModeByCode(dr.GetInt32("modeCode"));
            else
                mode = "";

            session = new Session(userLogin, video, dateString, evaluetion, mode, comment);
            session.setCode(code);
            return session;
        }
Esempio n. 4
0
 public Boolean updateSession(Session session, Type type, String errorMethod)
 {
     return false;
 }
Esempio n. 5
0
 public Boolean updateSession(Session session)
 {
     return updateSession(session, null, null);
 }
Esempio n. 6
0
        public Boolean insertSession(Session session, Type type, String errorMethod)
        {
            int modeCode;

            modeCode = getModeCode(session.getMode());

            String[] dateStrings = new String[2];
            String[] videoCodeStrings = new String[2];
            String[] userLoginStrings = new String[2];
            String[] evaluetionStrings = new String[2];
            String[] modeStrings = new String[2];
            String[] commentStrings = new String[2];

            if (session.getDate() != null)
            {
                dateStrings[0] = "date";
                dateStrings[1] = "'" + session.getDate() + "'";
            }
            else
                return false;

            if (session.getVideoCode() != -1)
            {
                videoCodeStrings[0] = ", videoCode";
                videoCodeStrings[1] = ", " + session.getVideoCode();
            }
            else
                return false;

            if (!session.getUserLogin().Equals(""))
            {
                userLoginStrings[0] = ", userLogin";
                userLoginStrings[1] = ", '" + session.getUserLogin() + "'";
            }
            else
                return false;

            if (session.getEvaluetion() != -1)
            {
                evaluetionStrings[0] = ", evaluetion";
                evaluetionStrings[1] = ", " + session.getEvaluetion().ToString().Replace(",",".") + "";
            }

            if (modeCode != 0)
            {
                modeStrings[0] = ", modeCode";
                modeStrings[1] = ", " + modeCode;
            }

            if (!session.getComment().Equals(""))
            {
                commentStrings[0] = ", comment";
                commentStrings[1] = ", '" + session.getComment() + "'";
            }

            String insertSessionString = "INSERT INTO SESSION (" +
                                                         dateStrings[0] +
                                                         videoCodeStrings[0] +
                                                         userLoginStrings[0] +
                                                         evaluetionStrings[0] +
                                                         modeStrings[0] +
                                                         commentStrings[0] + ") VALUES (" +
                                                         dateStrings[1] +
                                                         videoCodeStrings[1] +
                                                         userLoginStrings[1] +
                                                         evaluetionStrings[1] +
                                                         modeStrings[1] +
                                                         commentStrings[1] + ")";

            //            MessageBox.Show(insertSessionString);
            Boolean insertionResult =
                executeNonQuery(insertSessionString, type, errorMethod, "Insert session failed.");

            session.setCode(getLastVideoCode());

            return insertionResult;
        }
Esempio n. 7
0
 public Boolean insertSession(Session session)
 {
     return insertSession(session, null, null);
 }
        private void createSession()
        {
            float evaluetion;
            if(!float.TryParse(cbbEvaluetion.Text, out evaluetion))
                evaluetion = -1;

            session = new Session(user.getLogin(), video, dtpSession.Value,
                                  evaluetion, cbbMode.Text, rtbComment.Text);
        }