Exemplo n.º 1
0
        public void loadAnhTheLoai()
        {
            conboboxtrangTheLoai.Visible = true;
            comboboxTrangAlbum.Visible   = false;
            boxPhanTrang.Visible         = false;
            resetLaiBoxAnh();
            TheLoai theLoai   = new TheLoai();
            HinhAnh anh       = new HinhAnh();
            String  maTheLoai = theLoai.layMaTrung(comboboxLocTheLoai.GetItemText(comboboxLocTheLoai.SelectedItem));

            List <HinhAnh> danhSachAnhCungTheLoai = anh.layHinhTheoMaTheLoai(maTheLoai);

            int trangTheoTheLoai = tinhSoTrang(danhSachAnhCungTheLoai.Count);

            hienThiSoTrangTheoTrangTheLoai(trangTheoTheLoai);
            List <HinhAnh> danhSachAnhTheoLoaiTrangDau = anh.layAnhTrangDauTienTheoTheLoai(maTheLoai, 1, 15);


            if (danhSachAnhCungTheLoai.Count >= 15)
            {
                hienThiAnh(danhSachAnhTheoLoaiTrangDau);
            }
            else
            {
                hienThiAnh(danhSachAnhCungTheLoai);
            }

            hienThiTenHinh();
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        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;
        }