private void btnxoaThuocTheLoai_Click(object sender, EventArgs e) { String maTheLoai2 = ""; HinhAnh hinh = new HinhAnh(); TheLoai tl = new TheLoai(); maTheLoai2 = tl.layMaTrung(txtTenTheLoai.Text); hinh.xoaAnhTheoMaTheLoai(maTheLoai2); MetroMessageBox.Show(Owner, "Xóa Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void comboboxTrangAlbum_SelectedIndexChanged(object sender, EventArgs e) { resetLaiBoxAnh(); int sotrang = Int32.Parse(comboboxTrangAlbum.SelectedIndex.ToString()); HinhAnh anh = new HinhAnh(); Album album = new Album(); String maAlbum = album.layMaTrung(comboboxLocAlbum.GetItemText(comboboxLocAlbum.SelectedItem)); List <HinhAnh> danhSachAnhTheoTrangTheoAlbum = anh.layHinhTheoAlbumTheoTrang(maAlbum, sotrang * 15, 15); hienThiAnh(danhSachAnhTheoTrangTheoAlbum); hienThiTenHinh(); }
private void conboboxtrangTheLoai_SelectedIndexChanged(object sender, EventArgs e) { resetLaiBoxAnh(); int sotrang = Int32.Parse(conboboxtrangTheLoai.SelectedIndex.ToString()); HinhAnh anh = new HinhAnh(); TheLoai theLoai = new TheLoai(); String maTheLoai = theLoai.layMaTrung(comboboxLocTheLoai.GetItemText(comboboxLocTheLoai.SelectedItem)); List <HinhAnh> danhSachAnhTheoTrangTheoTheLoai = anh.layHinhTheLoaiTheoTrang(maTheLoai, sotrang * 15, 15); hienThiAnh(danhSachAnhTheoTrangTheoTheLoai); hienThiTenHinh(); }
private void pictureBox1_Click(object sender, EventArgs e) { count = count - 1; if (count < 0) { count = 0; } HinhAnh loadAnh = new HinhAnh(); List <HinhAnh> dataAnh = loadAnh.layAnh(); hinhXemFull.Image = new Bitmap(@dataAnh[count].DuongDan); }
public void hienThiBoxAnh(HinhAnh anh, PictureBox boxAnh) { try { if (anh != null) { boxAnh.Image = new Bitmap(@anh.DuongDan); boxAnh.Name = anh.DuongDan; } } catch (Exception ex) { } }
private void boxPhanTrang_SelectedIndexChanged(object sender, EventArgs e) { if (Int32.Parse(boxPhanTrang.SelectedIndex.ToString()) != 0) { resetLaiBoxAnh(); } int soTrang = Int32.Parse(boxPhanTrang.SelectedIndex.ToString()); HinhAnh anh = new HinhAnh(); List <HinhAnh> danhSachAnhTheoTang = anh.layHinhTheoTrang(soTrang * 15, 15); hienThiAnh(danhSachAnhTheoTang); hienThiTenHinh(); disableCheckBox(); }
private void pictureBox2_Click(object sender, EventArgs e) { HinhAnh anh = new HinhAnh(); try { count = count + 1; if (count > anh.layAnh().Count()) { count = anh.layAnh().Count(); } HinhAnh loadAnh = new HinhAnh(); List <HinhAnh> dataAnh = loadAnh.layAnh(); hinhXemFull.Image = new Bitmap(@dataAnh[count].DuongDan); } catch (Exception ex) { } }
void pic_Click(object sender, EventArgs e) { PictureBox pic = (PictureBox)sender; String tenTheLoai = ""; String tenAlbum = ""; HinhAnh anh = new HinhAnh(); TheLoai theLoai = new TheLoai(); Album alBum = new Album(); anh = anh.layHinhTheoDuongDan(pic.Name); if (anh.MaTheLoai != null) { try { tenTheLoai = theLoai.layTheLoaiTheoMaTheLoai(anh.MaTheLoai).TenTheLoai; } catch (Exception) { } } if (anh.MaAlbum != null) { try { tenAlbum = alBum.layAlbumTheoMaAlbum(anh.MaAlbum).TenAlbum; } catch (Exception) { } } piHinhAnhFull.Image = pic.Image; labelTenAnh.Text = anh.TenHinh; panelThongTin.Visible = true; labelTheLoai.Text = tenTheLoai; labelAlbum.Text = tenAlbum; }
public bool capNhatAnh(HinhAnh anh) { try { var ketQua = from HinhAnh in ketNoi.HinhAnhs where HinhAnh.DuongDan == anh.DuongDan select HinhAnh; foreach (var tam in ketQua) { tam.TenHinh = anh.TenHinh; tam.MaTheLoai = anh.MaTheLoai; tam.GhiChu = anh.GhiChu; tam.MaAlbum = anh.MaAlbum; } ketNoi.SubmitChanges(); return(true); } catch (Exception) { return(false); } }
public void loadAnhTuDaTa() { boxPhanTrang.Visible = true; comboboxTrangAlbum.Visible = false; conboboxtrangTheLoai.Visible = false; HinhAnh anh = new HinhAnh(); int dem = anh.demAnh(); List <HinhAnh> danhSachAnhTrangDau; hienThiSoTrang(tinhSoTrang(dem)); if (dem >= 15) { danhSachAnhTrangDau = anh.layAnhTrangDauTien(1, 15); hienThiAnh(danhSachAnhTrangDau); } else { danhSachAnhTrangDau = anh.layAnh(); hienThiAnh(danhSachAnhTrangDau); } }
private void metroTile1_Click(object sender, EventArgs e) { DialogResult result = folderBrowserDialog1.ShowDialog(); String[] files = null; try { files = Directory.GetFiles(folderBrowserDialog1.SelectedPath); if (result == DialogResult.OK) { int i = 0; while (files != null) { if (files[i].EndsWith(".jpg") || files[i].EndsWith(".png") || files[i].EndsWith(".GIF") || files[i].EndsWith(".bmp") || files[i].EndsWith(".jpeg")) { HinhAnh anh = new HinhAnh(); anh.DuongDan = files[i]; anh.TenHinh = Path.GetFileNameWithoutExtension(files[i]); anh.ThemAnh(); } i++; } } } catch (Exception) { } loadAnhRaFlow(); }
private void btnXoa_Click(object sender, EventArgs e) { HinhAnh anh = new HinhAnh(); List <HinhAnh> danhSachCheckBox = new List <HinhAnh>(); if (checkBoxHinh1.CheckState == CheckState.Checked) { HinhAnh hinh1 = new HinhAnh(); hinh1 = hinh1.layHinhTheoDuongDan(hinhAnh1.Name); danhSachCheckBox.Add(hinh1); } if (checkBoxHinh2.CheckState == CheckState.Checked) { HinhAnh hinh2 = new HinhAnh(); hinh2 = hinh2.layHinhTheoDuongDan(hinhAnh2.Name); danhSachCheckBox.Add(hinh2); } if (checkBoxHinh3.CheckState == CheckState.Checked) { HinhAnh hinh3 = new HinhAnh(); hinh3 = hinh3.layHinhTheoDuongDan(hinhAnh3.Name); danhSachCheckBox.Add(hinh3); } if (checkBoxHinh4.CheckState == CheckState.Checked) { HinhAnh hinh4 = new HinhAnh(); hinh4 = hinh4.layHinhTheoDuongDan(hinhAnh4.Name); danhSachCheckBox.Add(hinh4); } if (checkBoxHinh5.CheckState == CheckState.Checked) { HinhAnh hinh5 = new HinhAnh(); hinh5 = hinh5.layHinhTheoDuongDan(hinhAnh5.Name); danhSachCheckBox.Add(hinh5); } if (checkBoxHinh6.CheckState == CheckState.Checked) { HinhAnh hinh6 = new HinhAnh(); hinh6 = hinh6.layHinhTheoDuongDan(hinhAnh6.Name); danhSachCheckBox.Add(hinh6); } if (checkBoxHinh7.CheckState == CheckState.Checked) { HinhAnh hinh7 = new HinhAnh(); hinh7 = hinh7.layHinhTheoDuongDan(hinhAnh7.Name); danhSachCheckBox.Add(hinh7); } if (checkBoxHinh8.CheckState == CheckState.Checked) { HinhAnh hinh8 = new HinhAnh(); hinh8 = hinh8.layHinhTheoDuongDan(hinhAnh8.Name); danhSachCheckBox.Add(hinh8); } if (checkBoxHinh9.CheckState == CheckState.Checked) { HinhAnh hinh9 = new HinhAnh(); hinh9 = hinh9.layHinhTheoDuongDan(hinhAnh9.Name); danhSachCheckBox.Add(hinh9); } if (checkBoxHinh10.CheckState == CheckState.Checked) { HinhAnh hinh10 = new HinhAnh(); hinh10 = hinh10.layHinhTheoDuongDan(hinhAnh10.Name); danhSachCheckBox.Add(hinh10); } if (checkBoxHinh11.CheckState == CheckState.Checked) { HinhAnh hinh11 = new HinhAnh(); hinh11 = hinh11.layHinhTheoDuongDan(hinhAnh11.Name); danhSachCheckBox.Add(hinh11); } if (checkBoxHinh12.CheckState == CheckState.Checked) { HinhAnh hinh12 = new HinhAnh(); hinh12 = hinh12.layHinhTheoDuongDan(hinhAnh12.Name); danhSachCheckBox.Add(hinh12); } if (checkBoxHinh13.CheckState == CheckState.Checked) { HinhAnh hinh13 = new HinhAnh(); hinh13 = hinh13.layHinhTheoDuongDan(hinhAnh13.Name); danhSachCheckBox.Add(hinh13); } if (checkBoxHinh14.CheckState == CheckState.Checked) { HinhAnh hinh14 = new HinhAnh(); hinh14 = hinh14.layHinhTheoDuongDan(hinhAnh14.Name); danhSachCheckBox.Add(hinh14); } if (checkBoxHinh15.CheckState == CheckState.Checked) { HinhAnh hinh15 = new HinhAnh(); hinh15 = hinh15.layHinhTheoDuongDan(hinhAnh15.Name); danhSachCheckBox.Add(hinh15); } for (int i = 0; i <= danhSachCheckBox.Count - 1; i++) { anh.xoaAnhTheoDuongDan(danhSachCheckBox[i].DuongDan); } danhSachCheckBox.Clear(); MetroMessageBox.Show(this, "Xóa Thành Công.", "Thông Báo", MessageBoxButtons.OK); loadAnhTuDaTa(); resetCheckbox(); if (comboboxLocTheLoai.SelectedIndex > -1) { loadAnhTheLoai(); } else if (comboboxAlbum.SelectedIndex > -1) { loadAnhAlbum(); } else { loadAnhTuDaTa(); } }
public void hienThiAnh(List <HinhAnh> danhSachAnh) { HinhAnh anhtrong = new HinhAnh(); anhtrong.DuongDan = ""; for (int i = 0; i < danhSachAnh.Count; i++) { if (danhSachAnh[i] != null) { switch (i) { case 0: hienThiBoxAnh(danhSachAnh[i], hinhAnh1); break; case 1: hienThiBoxAnh(danhSachAnh[i], hinhAnh2); break; case 2: hienThiBoxAnh(danhSachAnh[i], hinhAnh3); break; case 3: hienThiBoxAnh(danhSachAnh[i], hinhAnh4); break; case 4: hienThiBoxAnh(danhSachAnh[i], hinhAnh5); break; case 5: hienThiBoxAnh(danhSachAnh[i], hinhAnh6); break; case 6: hienThiBoxAnh(danhSachAnh[i], hinhAnh7); break; case 7: hienThiBoxAnh(danhSachAnh[i], hinhAnh8); break; case 8: hienThiBoxAnh(danhSachAnh[i], hinhAnh9); break; case 9: hienThiBoxAnh(danhSachAnh[i], hinhAnh10); break; case 10: hienThiBoxAnh(danhSachAnh[i], hinhAnh11); break; case 11: hienThiBoxAnh(danhSachAnh[i], hinhAnh12); break; case 12: hienThiBoxAnh(danhSachAnh[i], hinhAnh13); break; case 13: hienThiBoxAnh(danhSachAnh[i], hinhAnh14); break; case 14: hienThiBoxAnh(danhSachAnh[i], hinhAnh15); break; default: break; } } } }
partial void DeleteHinhAnh(HinhAnh instance);
partial void UpdateHinhAnh(HinhAnh instance);
partial void InsertHinhAnh(HinhAnh instance);
private void btnChinhSua_Click(object sender, EventArgs e) { HinhAnh anh = new HinhAnh(); TheLoai theLoai = new TheLoai(); Album alBum = new Album(); anh.DuongDan = duongDan; anh.TenHinh = textTen.Text; anh.GhiChu = textGhiChu.Text; String maTheLoai = ""; String maAlBum = ""; //kiem tra trung the loai va album if (textTheLoai.Text != "" && theLoai.kiemTraTrungTheLoai(textTheLoai.Text.ToLower()) == false) { maTheLoai = theLoai.layMaTrung(textTheLoai.Text.ToLower()); } if (textAlbum.Text != "" && alBum.kiemTraTrungAlbum(textAlbum.Text.ToLower()) == false) { maAlBum = alBum.layMaTrung(textAlbum.Text.ToLower()); } if (textTheLoai.Text != "" && theLoai.kiemTraTrungTheLoai(textTheLoai.Text.ToLower()) == true) { TheLoai themMoi = new TheLoai(textTheLoai.Text); themMoi.themTheLoai(themMoi); maTheLoai = themMoi.MaTheLoai; } if (textAlbum.Text != "" && alBum.kiemTraTrungAlbum(textAlbum.Text.ToLower()) == true) { Album themMoi = new Album(textAlbum.Text); themMoi.themAlbum(themMoi); maAlBum = themMoi.MaAlbum; } List <HinhAnh> danhSachCheckBox = new List <HinhAnh>(); if (checkBoxHinh1.CheckState == CheckState.Checked) { HinhAnh hinh1 = new HinhAnh(); hinh1 = hinh1.layHinhTheoDuongDan(hinhAnh1.Name); danhSachCheckBox.Add(hinh1); } if (checkBoxHinh2.CheckState == CheckState.Checked) { HinhAnh hinh2 = new HinhAnh(); hinh2 = hinh2.layHinhTheoDuongDan(hinhAnh2.Name); danhSachCheckBox.Add(hinh2); } if (checkBoxHinh3.CheckState == CheckState.Checked) { HinhAnh hinh3 = new HinhAnh(); hinh3 = hinh3.layHinhTheoDuongDan(hinhAnh3.Name); danhSachCheckBox.Add(hinh3); } if (checkBoxHinh4.CheckState == CheckState.Checked) { HinhAnh hinh4 = new HinhAnh(); hinh4 = hinh4.layHinhTheoDuongDan(hinhAnh4.Name); danhSachCheckBox.Add(hinh4); } if (checkBoxHinh5.CheckState == CheckState.Checked) { HinhAnh hinh5 = new HinhAnh(); hinh5 = hinh5.layHinhTheoDuongDan(hinhAnh5.Name); danhSachCheckBox.Add(hinh5); } if (checkBoxHinh6.CheckState == CheckState.Checked) { HinhAnh hinh6 = new HinhAnh(); hinh6 = hinh6.layHinhTheoDuongDan(hinhAnh6.Name); danhSachCheckBox.Add(hinh6); } if (checkBoxHinh7.CheckState == CheckState.Checked) { HinhAnh hinh7 = new HinhAnh(); hinh7 = hinh7.layHinhTheoDuongDan(hinhAnh7.Name); danhSachCheckBox.Add(hinh7); } if (checkBoxHinh8.CheckState == CheckState.Checked) { HinhAnh hinh8 = new HinhAnh(); hinh8 = hinh8.layHinhTheoDuongDan(hinhAnh8.Name); danhSachCheckBox.Add(hinh8); } if (checkBoxHinh9.CheckState == CheckState.Checked) { HinhAnh hinh9 = new HinhAnh(); hinh9 = hinh9.layHinhTheoDuongDan(hinhAnh9.Name); danhSachCheckBox.Add(hinh9); } if (checkBoxHinh10.CheckState == CheckState.Checked) { HinhAnh hinh10 = new HinhAnh(); hinh10 = hinh10.layHinhTheoDuongDan(hinhAnh10.Name); danhSachCheckBox.Add(hinh10); } if (checkBoxHinh11.CheckState == CheckState.Checked) { HinhAnh hinh11 = new HinhAnh(); hinh11 = hinh11.layHinhTheoDuongDan(hinhAnh11.Name); danhSachCheckBox.Add(hinh11); } if (checkBoxHinh12.CheckState == CheckState.Checked) { HinhAnh hinh12 = new HinhAnh(); hinh12 = hinh12.layHinhTheoDuongDan(hinhAnh12.Name); danhSachCheckBox.Add(hinh12); } if (checkBoxHinh13.CheckState == CheckState.Checked) { HinhAnh hinh13 = new HinhAnh(); hinh13 = hinh13.layHinhTheoDuongDan(hinhAnh13.Name); danhSachCheckBox.Add(hinh13); } if (checkBoxHinh14.CheckState == CheckState.Checked) { HinhAnh hinh14 = new HinhAnh(); hinh14 = hinh14.layHinhTheoDuongDan(hinhAnh14.Name); danhSachCheckBox.Add(hinh14); } if (checkBoxHinh15.CheckState == CheckState.Checked) { HinhAnh hinh15 = new HinhAnh(); hinh15 = hinh15.layHinhTheoDuongDan(hinhAnh15.Name); danhSachCheckBox.Add(hinh15); } anh.MaTheLoai = maTheLoai; anh.MaAlbum = maAlBum; anh.TenHinh = textTen.Text; anh.GhiChu = textGhiChu.Text; if (kiemTraCheck() == true) { if (thayDoiTheLoai == true) { for (int i = 0; i <= danhSachCheckBox.Count - 1; i++) { HinhAnh hinhTam = new HinhAnh(); hinhTam.DuongDan = danhSachCheckBox[i].DuongDan; hinhTam.MaTheLoai = maTheLoai; hinhTam.MaAlbum = anh.layHinhTheoDuongDan(danhSachCheckBox[i].DuongDan).MaAlbum; hinhTam.TenHinh = anh.layTenTheoDuongDan(danhSachCheckBox[i].DuongDan); hinhTam.GhiChu = (anh.layHinhTheoDuongDan(danhSachCheckBox[i].DuongDan)).GhiChu; anh.capNhatAnh(hinhTam); } } if (thayDoiAlbum == true) { for (int i = 0; i <= danhSachCheckBox.Count - 1; i++) { HinhAnh hinhTam = new HinhAnh(); hinhTam.DuongDan = danhSachCheckBox[i].DuongDan; hinhTam.MaTheLoai = anh.layHinhTheoDuongDan(danhSachCheckBox[i].DuongDan).MaTheLoai; hinhTam.MaAlbum = maAlBum; hinhTam.TenHinh = anh.layTenTheoDuongDan(danhSachCheckBox[i].DuongDan); hinhTam.GhiChu = (anh.layHinhTheoDuongDan(danhSachCheckBox[i].DuongDan)).GhiChu; anh.capNhatAnh(hinhTam); } if (thayDoiAlbum == true && thayDoiTheLoai == true) { for (int i = 0; i <= danhSachCheckBox.Count - 1; i++) { HinhAnh hinhTam = new HinhAnh(); hinhTam.DuongDan = danhSachCheckBox[i].DuongDan; hinhTam.MaTheLoai = maTheLoai; hinhTam.MaAlbum = maAlBum; hinhTam.TenHinh = anh.layTenTheoDuongDan(danhSachCheckBox[i].DuongDan); hinhTam.GhiChu = (anh.layHinhTheoDuongDan(danhSachCheckBox[i].DuongDan)).GhiChu; anh.capNhatAnh(hinhTam); } } } } if (textAlbum.Text == "" && textTheLoai.Text == "") { MetroMessageBox.Show(Owner, "Bạn Chưa Điền Thông Tin", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error, 100); } else { MetroMessageBox.Show(Owner, "Cập Nhật Thành Công.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information, 100); } anh.capNhatAnh(anh); panelChinhSua.Visible = false; tenHinh1.Text = anh.layTenTheoDuongDan(hinhAnh1.Name); tenHinh2.Text = anh.layTenTheoDuongDan(hinhAnh2.Name); tenHinh3.Text = anh.layTenTheoDuongDan(hinhAnh3.Name); tenHinh4.Text = anh.layTenTheoDuongDan(hinhAnh4.Name); tenHinh5.Text = anh.layTenTheoDuongDan(hinhAnh5.Name); tenHinh6.Text = anh.layTenTheoDuongDan(hinhAnh6.Name); tenHinh7.Text = anh.layTenTheoDuongDan(hinhAnh7.Name); tenHinh8.Text = anh.layTenTheoDuongDan(hinhAnh8.Name); tenHinh9.Text = anh.layTenTheoDuongDan(hinhAnh9.Name); tenHinh10.Text = anh.layTenTheoDuongDan(hinhAnh10.Name); tenHinh11.Text = anh.layTenTheoDuongDan(hinhAnh11.Name); tenHinh12.Text = anh.layTenTheoDuongDan(hinhAnh12.Name); tenHinh13.Text = anh.layTenTheoDuongDan(hinhAnh13.Name); tenHinh14.Text = anh.layTenTheoDuongDan(hinhAnh14.Name); tenHinh15.Text = anh.layTenTheoDuongDan(hinhAnh15.Name); resetCheckbox(); thayDoiTheLoai = false; thayDoiAlbum = false; }
private void XemAnh_Load(object sender, EventArgs e) { boxPhanTrang.Visible = true; TheLoai theLoaia = new TheLoai(); List <TheLoai> danhSachTheLoai = theLoaia.layTheLoai(); for (int i = 0; i <= danhSachTheLoai.Count - 1; i++) { comboboxTheLoai.Items.Add(danhSachTheLoai[i].TenTheLoai); comboboxLocTheLoai.Items.Add(danhSachTheLoai[i].TenTheLoai); } Album albuma = new Album(); List <Album> danhSachAlbum = albuma.layAlbum(); for (int i = 0; i <= danhSachAlbum.Count - 1; i++) { comboboxAlbum.Items.Add(danhSachAlbum[i].TenAlbum); comboboxLocAlbum.Items.Add(danhSachAlbum[i].TenAlbum); } if (chucNangDangChon != 1) { HinhAnh anh = new HinhAnh(); chucNangDangChon = 1; int dem = anh.demAnh(); List <HinhAnh> danhSachAnhTrangDau; hienThiSoTrang(tinhSoTrang(dem)); if (dem >= 15) { danhSachAnhTrangDau = anh.layAnhTrangDauTien(1, 15); hienThiAnh(danhSachAnhTrangDau); } else { danhSachAnhTrangDau = anh.layAnh(); hienThiAnh(danhSachAnhTrangDau); } disableCheckBox(); } HinhAnh anhao = new HinhAnh(); try { tenHinh1.Text = anhao.layTenTheoDuongDan(hinhAnh1.Name); tenHinh2.Text = anhao.layTenTheoDuongDan(hinhAnh2.Name); tenHinh3.Text = anhao.layTenTheoDuongDan(hinhAnh3.Name); tenHinh4.Text = anhao.layTenTheoDuongDan(hinhAnh4.Name); tenHinh5.Text = anhao.layTenTheoDuongDan(hinhAnh5.Name); tenHinh6.Text = anhao.layTenTheoDuongDan(hinhAnh6.Name); tenHinh7.Text = anhao.layTenTheoDuongDan(hinhAnh7.Name); tenHinh8.Text = anhao.layTenTheoDuongDan(hinhAnh8.Name); tenHinh9.Text = anhao.layTenTheoDuongDan(hinhAnh9.Name); tenHinh10.Text = anhao.layTenTheoDuongDan(hinhAnh10.Name); tenHinh11.Text = anhao.layTenTheoDuongDan(hinhAnh11.Name); tenHinh12.Text = anhao.layTenTheoDuongDan(hinhAnh12.Name); tenHinh13.Text = anhao.layTenTheoDuongDan(hinhAnh13.Name); tenHinh14.Text = anhao.layTenTheoDuongDan(hinhAnh14.Name); tenHinh15.Text = anhao.layTenTheoDuongDan(hinhAnh15.Name); } catch (Exception) { } }