private void button4_Click(object sender, EventArgs e) { try { //var id = int.Parse(tID.Text); var name = tName.Text; var price = int.Parse(tPrice.Text); var piece = int.Parse(tPiece.Text); var date = tDate.Text; var producer = tProducer.Text; var author = tAuthor.Text; var result = _musicBook.GetByName(name, "Computers"); var fs = new FileStream(imgLoc, FileMode.Open, FileAccess.Read); var br = new BinaryReader(fs); img = br.ReadBytes((int)fs.Length); if (result.Rows.Count > 0) { lberror.ForeColor = Color.Red; searchError.Text = CommonFunctions.ReturnString("exist"); } else { _musicBook.Add(name, "MusicBook", price, piece, date, producer, author); _musicBook.AddImage(int.Parse(_musicBook.GetByName(name, "MusicBook").Rows[0][0].ToString()), img, "MusicBook"); lberror.ForeColor = Color.Green; lberror.Text = CommonFunctions.ReturnString("success"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void bunifuCustomDataGrid4_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex > -1) { label16.Text = _book.GetShort().Rows[e.RowIndex][4].ToString(); label24.Text = _book.GetShort().Rows[e.RowIndex][0].ToString(); label28.Text = _book.GetShort().Rows[e.RowIndex][3].ToString(); label14.Text = _book.GetShort().Rows[e.RowIndex][1].ToString(); label25.Text = _book.GetShort().Rows[e.RowIndex][2].ToString(); byte[] img; if (_book.GetByName(label24.Text, "MusicBook").Rows[0][8].ToString() != "NULL") { img = (byte[])(_book.GetByName(label24.Text, "MusicBook").Rows[0][8]); if (img == null) { pictureBox19.Image = null; } else { var ms = new MemoryStream(img); pictureBox19.Image = Image.FromStream(ms); } } } xtraTabPage8.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void accordionControlElement5_Click(object sender, EventArgs e) { try { bunifuCustomDataGrid4.Columns.Clear(); _book = new MusicBook(); if (_book.GetShort().Rows.Count > 0) { bunifuCustomDataGrid4.DataSource = _book.GetShort(); //AddButton(bunifuCustomDataGrid4); label16.Text = _book.GetShort().Rows[0][4].ToString(); label24.Text = _book.GetShort().Rows[0][0].ToString(); label28.Text = _book.GetShort().Rows[0][3].ToString(); label14.Text = _book.GetShort().Rows[0][1].ToString(); label25.Text = _book.GetShort().Rows[0][2].ToString(); byte[] img; if (_book.GetByName(label24.Text, "MusicBook").Rows[0][8].ToString() != "NULL") { img = (byte[])(_book.GetByName(label24.Text, "MusicBook").Rows[0][8]); if (img == null) { pictureBox19.Image = null; } else { var ms = new MemoryStream(img); pictureBox19.Image = Image.FromStream(ms); } } } xtraTabPage8.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click(object sender, EventArgs e) { if (cb.SelectedIndex == 0) { if (searchID.Text.Trim() == "" && searchName.Text.Trim() == "") { searchError.Text = "Parameters can not be empty."; } else { if (searchID.Text.Trim() != "" && searchName.Text.Trim() == "") { dataGridView1.DataSource = comp.GetById(int.Parse(searchID.Text.Trim()), "Computers"); } else if (searchID.Text.Trim() == "" && searchName.Text.Trim() != "") { dataGridView1.DataSource = comp.GetByName(searchName.Text.Trim(), "Computers"); } else { searchError.Text = "You can only search with only one parameter"; } } } else if (cb.SelectedIndex == 1) { if (searchID.Text.Trim() == "" && searchName.Text.Trim() == "") { searchError.Text = "Parameters can not be empty."; } else { if (searchID.Text.Trim() != "" && searchName.Text.Trim() == "") { dataGridView1.DataSource = SmartPhones.GetById(int.Parse(searchID.Text.Trim()), "SmartPhones"); } else if (searchID.Text.Trim() == "" && searchName.Text.Trim() != "") { dataGridView1.DataSource = SmartPhones.GetByName(searchName.Text.Trim(), "SmartPhones"); } else { searchError.Text = "You can only search with only one parameter"; } } } else if (cb.SelectedIndex == 2) { if (searchID.Text.Trim() == "" && searchName.Text.Trim() == "") { searchError.Text = "Parameters can not be empty."; } else { if (searchID.Text.Trim() != "" && searchName.Text.Trim() == "") { dataGridView1.DataSource = MusicBook.GetById(int.Parse(searchID.Text.Trim()), "MusicBook"); } else if (searchID.Text.Trim() == "" && searchName.Text.Trim() != "") { dataGridView1.DataSource = MusicBook.GetByName(searchName.Text.Trim(), "MusicBook"); } else { searchError.Text = "You can only search with only one parameter"; } } } else { searchError.Text = "Please select a category."; } }