private void btnAddCategory_Click(object sender, EventArgs e)
 {
     if (verifyStringToBeAdded(cbbCategory.Text, cbbCategory.Items.Cast<String>()))
     {
         DaoVideo daoVideo = new DaoVideo();
         daoVideo.openConnection(this.GetType(), "sqlErrorHandler");
         daoVideo.insertCategory(cbbCategory.Text, this.GetType(), "sqlErrorHandler");
         daoVideo.closeConnection();
         loadCategories();
         updateLbCategory();
     }
     cbbCategory.Focus();
 }
Exemplo n.º 2
0
 public int getLastVideoCode()
 {
     int lastCode = 0;
     DaoVideo daoVideo = new DaoVideo();
     daoVideo.openConnection();
     MySqlDataReader dataReader = daoVideo.executeQuery("SHOW TABLE STATUS LIKE 'VIDEO'");
     if (dataReader != null && dataReader.HasRows)
     {
         dataReader.Read();
         lastCode = dataReader.GetInt16("auto_increment") - 1;
     }
     daoVideo.closeConnection();
     return lastCode;
 }
        private void btnAddTag_Click(object sender, EventArgs e)
        {
            // TODO: make a funcion to comport the next if statement and change the 'stringsToBeAdded' function
            if (cbbVideoTags.Text.Length == 0)
            {
                btnAddCategory.Enabled = false;
            }

            if (verifyStringToBeAdded(cbbVideoTags.Text,lbVideoTags.Items.Cast<String>()))
            {
                if(!cbbVideoTags.Items.Contains(cbbVideoTags.Text))
                {
                    DaoVideo daoVideo = new DaoVideo();
                    daoVideo.openConnection(this.GetType(), "sqlErrorHandler");
                    daoVideo.insertTag(cbbVideoTags.Text, this.GetType(), "sqlErrorHandler");
                    daoVideo.closeConnection();

                }
                lbVideoTags.Items.Add(cbbVideoTags.Text);
                cbbVideoTags.Text = "";
                loadItemsIntoCbbVideoTags();

            }
            cbbVideoTags.Focus();
        }
        private void VideoRegistrationForm_Load(object sender, EventArgs e)
        {
            this.MinimumSize = this.Size;

            DaoVideo daoVideo = new DaoVideo();
            daoVideo.openConnection(this.GetType(), "sqlErrorHandler");
            daoVideo.createTable(this.GetType(), "sqlErrorHandler");
            daoVideo.closeConnection();

            setMtbDurationMask();
            loadItemsIntoCbbVideoTags();
            loadCategories();
        }
 private void loadItemsIntoCbbVideoTags()
 {
     DaoVideo daoVideo = new DaoVideo();
     daoVideo.openConnection(this.GetType(), "sqlErrorHandler");
     cbbVideoTags.Items.Clear();
     cbbVideoTags.Items.AddRange(daoVideo.retrieveAllTags().ToArray());
     daoVideo.closeConnection();
 }
        private void btnRegisterVideo_Click(object sender, EventArgs e)
        {
            if (!verifyRequiredFields())
                MessageBox.Show("Preencha titulo nacional ou titulo original para poder registrar.");
            else
            {
                createVideo();
                DaoVideo daoVideo = new DaoVideo();
                daoVideo.openConnection(this.GetType(), "sqlErrorHandler");

                if (updating)
                {
                    if (daoVideo.updateVideo(video, this.GetType(), "sqlErrorHandler"))
                    {
            //                        MessageBox.Show("Atualizações salvas!");
                    }
                }
                else
                {
                    if (daoVideo.insertVideo(video, this.GetType(), "sqlErrorHandler"))
                    {
            //                        MessageBox.Show("Video registrado!");
                    }
                }

                daoVideo.closeConnection();
                this.Close();
            }
        }
Exemplo n.º 7
0
 string getCategory(int code)
 {
     String res;
     DaoVideo daoVideo = new DaoVideo();
     daoVideo.openConnection();
     MySqlDataReader categoryDataReader = daoVideo.executeQuery(
         "SELECT name FROM CATEGORY WHERE code = " + code);
     if (categoryDataReader == null || !categoryDataReader.HasRows)
         return null;
     categoryDataReader.Read();
     res = categoryDataReader.GetString("name");
     daoVideo.closeConnection();
     return res;
 }
Exemplo n.º 8
0
        public List<String> populateTags(int videoCode)
        {
            List<String> tags = new List<string>();
            String retrieveTagsCommand = "SELECT NAME FROM TAG " +
                                         "JOIN VIDEO_TAG on TAG.code = VIDEO_TAG.tagCode " +
                                         "WHERE VIDEO_TAG.videoCode = " + videoCode;

            DaoVideo daoVideo = new DaoVideo();
            daoVideo.openConnection();
            MySqlDataReader dataReader = daoVideo.executeQuery(retrieveTagsCommand, this.GetType(), "er", "pfff...");

            if (dataReader != null && dataReader.HasRows)
                while (dataReader.Read())
                {
                    tags.Add(dataReader["name"].ToString());
                }
            daoVideo.closeConnection();
            return tags;
        }
Exemplo n.º 9
0
 private void fillCbbVideoName()
 {
     DaoVideo daoVideo = new DaoVideo();
     daoVideo.openConnection(this.GetType(), "sqlErrorHandler");
     daoVideo.populateComboBox(cbbVideoName, (video != null)? video.getCode(): 0);
     daoVideo.closeConnection();
 }
Exemplo n.º 10
0
 private void cbbVideoName_SelectedValueChanged(object sender, EventArgs e)
 {
     DaoVideo daoVideo = new DaoVideo();
     daoVideo.openConnection();
     if (cbbVideoName.SelectedValue != null)
     {
         if (cbbVideoName.SelectedValue is int)
         {
             int selectedVideoCode = (int)cbbVideoName.SelectedValue;
             if(!updating)
                 video = daoVideo.getVideoByCode((int)cbbVideoName.SelectedValue);
             if (video != null)
             {
                 btnEditVideo.Enabled = true;
      //                       MessageBox.Show("selected ... changed");
                 fillVideoInfo(video);
             }
         }
     }
     daoVideo.closeConnection();
 }