示例#1
0
        public bool themTheLoai(TheLoai theLoai)
        {
            try
            {
                ketNoi.TheLoais.InsertOnSubmit(theLoai);
                ketNoi.SubmitChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
示例#2
0
        private void btnXoaTheLoai_Click(object sender, EventArgs e)
        {
            TheLoai tl = new TheLoai();

            try
            {
                String maTheLoai = gridDanhSachTheLoai.CurrentRow.Cells[0].ToString();
                if (maTheLoai != null)
                {
                    tl.xoaTheoMaTheLoai(gridDanhSachTheLoai.CurrentRow.Cells[0].ToString());
                }
            }
            catch (Exception)
            {
            }
        }
示例#3
0
        private void FullScreen_Load(object sender, EventArgs e)
        {
            Album tl2 = new Album();

            gridDanhSachAlbum.DataSource            = tl2.layAlbum();
            gridDanhSachAlbum.Columns[0].HeaderText = "Album";
            gridDanhSachAlbum.Columns[1].HeaderText = "Tên Album";
            gridDanhSachAlbum.Columns[0].Width      = 650;
            gridDanhSachAlbum.Columns[1].Width      = 650;
            TheLoai tl = new TheLoai();

            gridDanhSachTheLoai.DataSource            = tl.layTheLoai();
            gridDanhSachTheLoai.Columns[0].HeaderText = "Mã Thể Loại";
            gridDanhSachTheLoai.Columns[1].HeaderText = "Tên Thể Loại";
            gridDanhSachTheLoai.Columns[0].Width      = 650;
            gridDanhSachTheLoai.Columns[1].Width      = 650;
        }
示例#4
0
        public bool capNhat(TheLoai theLoai)
        {
            try
            {
                var ketQua = from hinh in ketNoi.TheLoais
                             where hinh.MaTheLoai == theLoai.MaTheLoai
                             select hinh;
                foreach (var tam in ketQua)
                {
                    tam.TenTheLoai = theLoai.TenTheLoai;
                }

                ketNoi.SubmitChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
示例#5
0
        private void btnThemTheLoai_Click(object sender, EventArgs e)
        {
            TheLoai tl = new TheLoai();

            if (tl.kiemTraTrungTheLoai(txtTenTheLoai.Text) == true && txtTenTheLoai.Text != "")
            {
                tl.TenTheLoai = txtTenTheLoai.Text;
                tl.MaTheLoai  = tl.tangMaTheLoai();
                tl.themTheLoai(tl);
                MetroMessageBox.Show(Owner, "Thêm Thành Công.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information, 100);
            }
            else if (txtTenTheLoai.Text == "")
            {
                MetroMessageBox.Show(Owner, "Bạn Chưa Thêm Tên Thể Loại.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information, 100);
            }
            else
            {
                MetroMessageBox.Show(Owner, "Trùng Thể Loại.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error, 100);
            }
            gridDanhSachTheLoai.DataSource = tl.layTheLoai();
        }
示例#6
0
        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;
        }
示例#7
0
        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            TheLoai tl = new TheLoai();

            try
            {
                String maTheLoai = gridDanhSachTheLoai.CurrentRow.Cells[0].Value.ToString();
            }
            catch (Exception)
            {
            }

            if (txtTenTheLoai.Text != null && gridDanhSachTheLoai.CurrentRow.Cells[0].Value.ToString() != "")
            {
                tl.MaTheLoai  = gridDanhSachTheLoai.CurrentRow.Cells[0].Value.ToString();
                tl.TenTheLoai = txtTenTheLoai.Text;
                tl.capNhat(tl);
                gridDanhSachTheLoai.DataSource = tl.layTheLoai();
            }


            MetroMessageBox.Show(Owner, "Cập Nhật Thành Công.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information, 100);
        }
 partial void DeleteTheLoai(TheLoai instance);
 partial void UpdateTheLoai(TheLoai instance);
 partial void InsertTheLoai(TheLoai instance);
示例#11
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;
        }
示例#12
0
        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)
            {
            }
        }