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(); }
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; }
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; }
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(); } }
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; }
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; }
private void fillCbbVideoName() { DaoVideo daoVideo = new DaoVideo(); daoVideo.openConnection(this.GetType(), "sqlErrorHandler"); daoVideo.populateComboBox(cbbVideoName, (video != null)? video.getCode(): 0); daoVideo.closeConnection(); }
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(); }