private void InsertCategory() { // Checks // Should check if name already exist /*********TODO*********/ CategoryObject obj = null; try { obj = GetFilledCategoryObject(); Database_Connector.Insert.Category(obj); DialogResult = DialogResult.OK; } catch (ArgumentNullException) { MessageBox.Show("PRICE_IS_NULL"); } catch (FormatException) { MessageBox.Show("PRICE_INVALIDE_FORMAT"); } catch (OverflowException) { MessageBox.Show("PRICE_VALUE_OVERFLOW"); } catch (Exception e) { MessageBox.Show(e.Message); } }
private void ImportFromIMDB() { string URL = tb_Url.Text; string id; int IndexIDStart; int IndexIDEnd; IndexIDStart = URL.IndexOf("/title/") + 7; if (IndexIDStart == -1) { throw new Exception("IMDB_ID_NOT_FOUND"); } IndexIDEnd = URL.IndexOf("/", IndexIDStart); if (IndexIDEnd == -1 && URL.IndexOf("tt") == 0) { id = URL; } else if (IndexIDEnd != -1) { id = URL.Substring(IndexIDStart, IndexIDEnd - IndexIDStart); } else { throw new Exception("ID_FORMAT_INVALID"); } MovieObject movie = Database_Connector.GetFromIMDB(id); movie.Category = CategoryObject.GetCategoryID(GetSelectedCategory()); Database_Connector.Insert.Movie(movie); }
private MovieObject GetMovieFromSelectedRow() { foreach (DataGridViewRow row in dgv_SearchResults.SelectedRows) { MovieObject movie = new MovieObject(); DateTime date = (DateTime)row.Cells[6].Value; movie.ID = int.Parse(row.Cells[0].Value.ToString()); movie.Nom_en = row.Cells[1].Value.ToString(); movie.Nom_fr = row.Cells[2].Value.ToString(); movie.Description_en = row.Cells[3].Value.ToString(); movie.Description_fr = row.Cells[4].Value.ToString(); movie.Director = row.Cells[5].Value.ToString(); movie.Date = date; movie.Rated = row.Cells[7].Value.ToString(); movie.Runtime = int.Parse(row.Cells[8].Value.ToString()); var data = (Byte[])(row.Cells[9].Value); var stream = new MemoryStream(data); movie.Poster = Image.FromStream(stream); movie.Category = CategoryObject.GetCategoryID(row.Cells[11].Value.ToString()); return(movie); } return(new MovieObject()); }
private void ModifyCategory() { CategoryObject obj = null; try { obj = GetFilledCategoryObject(); Database_Connector.Update.Category(obj); DialogResult = DialogResult.OK; } catch (ArgumentNullException) { MessageBox.Show("PRICE_IS_NULL"); } catch (FormatException) { MessageBox.Show("PRICE_INVALIDE_FORMAT"); } catch (OverflowException) { MessageBox.Show("PRICE_VALUE_OVERFLOW"); } catch (Exception e) { MessageBox.Show(e.Message); } }
public CategoryCU(CategoryObject obj) : this() { Modification_Mode = true; LoadLanguage(); FillTextboxes(obj); }
private void FillTextboxes(CategoryObject obj) { obj_id = obj.ID; tb_Name_En.Text = obj.Name_En; tb_Name_Fr.Text = obj.Name_Fr; tb_Description_En.Text = obj.Description_En; tb_Description_Fr.Text = obj.Description_Fr; tb_Price.Text = obj.Price.ToString(); }
private CategoryObject GetCategoryFromSelected() { CategoryObject obj = new CategoryObject(); DataGridViewRow dgvRow = dgv_View.SelectedRows[0]; obj.ID = int.Parse(dgvRow.Cells[0].Value.ToString()); obj.Name_En = dgvRow.Cells[1].Value.ToString(); obj.Name_Fr = dgvRow.Cells[2].Value.ToString(); obj.Description_En = dgvRow.Cells[3].Value.ToString(); obj.Description_Fr = dgvRow.Cells[4].Value.ToString(); obj.Price = decimal.Parse(dgvRow.Cells[5].Value.ToString()); return(obj); }
private CategoryObject GetCategoryFromSelected() { CategoryObject obj = new CategoryObject(); DataGridViewRow dgvRow = dgv_View.SelectedRows[0]; obj.ID = int.Parse(dgvRow.Cells[0].Value.ToString()); obj.Name_En = dgvRow.Cells[1].Value.ToString(); obj.Name_Fr = dgvRow.Cells[2].Value.ToString(); obj.Description_En = dgvRow.Cells[3].Value.ToString(); obj.Description_Fr = dgvRow.Cells[4].Value.ToString(); obj.Price = decimal.Parse(dgvRow.Cells[5].Value.ToString()); return obj; }
private CategoryObject GetFilledCategoryObject() { if (tb_Name_En.Text.Equals(string.Empty)) throw new Exception("NAME_EN_EMPTY"); if (tb_Name_Fr.Text.Equals(string.Empty)) throw new Exception("NAME_FR_EMPTY"); CategoryObject obj = new CategoryObject(); obj.ID = obj_id; obj.Name_En = tb_Name_En.Text; obj.Name_Fr = tb_Name_Fr.Text; obj.Description_En = tb_Description_En.Text; obj.Description_Fr = tb_Description_Fr.Text; obj.Price = decimal.Parse(tb_Price.Text); return obj; }
public static void Category(CategoryObject obj) { string update = "UPDATE categories SET NAME_EN=:nameEN, NAME_FR=:nameFR, DESCRIPTION_EN=:descEN, DESCRIPTION_FR=:descFR, PRICE=:price WHERE ID=:categoryID"; OracleCommand cmd = new OracleCommand(update, GetConnection()); cmd.Parameters.Add(new OracleParameter("nameEN", obj.Name_En)); cmd.Parameters.Add(new OracleParameter("nameFR", obj.Name_Fr)); cmd.Parameters.Add(new OracleParameter("descEN", obj.Description_En)); cmd.Parameters.Add(new OracleParameter("descFR", obj.Description_Fr)); cmd.Parameters.Add(new OracleParameter("price", obj.Price)); cmd.Parameters.Add(new OracleParameter("categoryID", obj.ID)); cmd.ExecuteNonQuery(); Database.Update.Categories(); }
public static void Category(CategoryObject obj) { string insert = "INSERT INTO categories VALUES (CATEGORYID.NEXTVAL, :name_en, :name_fr, :description_en, :description_fr, :price)"; OracleCommand cmd = new OracleCommand(insert, GetConnection()); cmd.Parameters.Add(new OracleParameter("name_en", obj.Name_En)); cmd.Parameters.Add(new OracleParameter("name_fr", obj.Name_Fr)); cmd.Parameters.Add(new OracleParameter("description_en", obj.Description_En)); cmd.Parameters.Add(new OracleParameter("description_fr", obj.Description_Fr)); cmd.Parameters.Add(new OracleParameter("price", obj.Price)); cmd.ExecuteNonQuery(); CloseConnection(); Database.Update.Categories(); }
private void LoadText() { try { pictureBox1.Image = movie.Poster; lb_TitreEN.Text = movie.Nom_en; lb_TitreFR.Text = movie.Nom_fr; lb_DescEN.Text = movie.Description_en; lb_DescFR.Text = movie.Description_fr; lb_Rating.Text = movie.Rated; lb_Time.Text = movie.Runtime.ToString(); lb_Director.Text = movie.Director; dtp.Text = movie.Date.ToString("dd/MM/yyyy"); cb_Categories.Text = CategoryObject.GetCategoryName(movie.Category); } catch (Exception) { } }
private CategoryObject GetFilledCategoryObject() { if (tb_Name_En.Text.Equals(string.Empty)) { throw new Exception("NAME_EN_EMPTY"); } if (tb_Name_Fr.Text.Equals(string.Empty)) { throw new Exception("NAME_FR_EMPTY"); } CategoryObject obj = new CategoryObject(); obj.ID = obj_id; obj.Name_En = tb_Name_En.Text; obj.Name_Fr = tb_Name_Fr.Text; obj.Description_En = tb_Description_En.Text; obj.Description_Fr = tb_Description_Fr.Text; obj.Price = decimal.Parse(tb_Price.Text); return(obj); }
private void btn_Modify_Click(object sender, EventArgs e) { try { MovieObject oMovie = new MovieObject(); oMovie.Category = CategoryObject.GetCategoryID(cb_Categories.Text); oMovie.ID = movie.ID; oMovie.Nom_en = lb_TitreEN.Text.ToString(); oMovie.Nom_fr = lb_TitreFR.Text.ToString(); oMovie.Description_fr = lb_DescFR.Text.ToString(); oMovie.Description_en = lb_DescEN.Text.ToString(); //oMovie.Date = DateTime.ParseExact(date, "dd/MM/yyyy", CultureInfo.InvariantCulture); oMovie.Date = DateTime.ParseExact(dtp.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); oMovie.Rated = lb_Rating.Text.ToString(); oMovie.Runtime = int.Parse(lb_Time.Text.ToString()); oMovie.Director = lb_Director.Text.ToString(); oMovie.Poster = pictureBox1.Image; Database_Connector.Update.Movie(oMovie); MessageBox.Show("Modification fait!"); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }