Example #1
0
        void ThemThongTheLoai(string MaTheLoai, string TenTheLoai)
        {
            TheLoaiBLL cls = new TheLoaiBLL(MaTheLoai, TenTheLoai);

            int kq = cls.Them();

            switch (kq)
            {
            case 0:
            {
                MessageBox.Show("Thêm Thành Công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                HienThiThongTheLoai();
                break;
            }

            case 1:
            {
                MessageBox.Show("Thêm Thất Bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;
            }

            case 2:
            {
                MessageBox.Show("Mã thể loại đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMaTheLoai.Focus();
                break;
            }
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (typemodal.Value == "TG")
            {
                TacGia tg = new TacGia();
                tg.HoTenTacGia = txtTen.Text;
                tg.MoTa        = txtMoTa.Text;
                if (editType.Value == "add")
                {
                    tg.MaTacGia = Tool.SinhMa();
                    int t = tgbll.Them(tg);
                    LoadTG();
                    typemodal.Value = "hide";
                }
                else
                {
                    tg.MaTacGia = hdId.Value;
                    tgbll.Sua(tg);
                    LoadTG();
                    typemodal.Value = "hide";
                }
            }
            if (typemodal.Value == "TL")
            {
                TheLoai tl = new TheLoai();
                tl.TenTheLoai = txtTen.Text;
                tl.MoTa       = txtMoTa.Text;
                if (editType.Value == "add")
                {
                    tl.MaTheLoai = Tool.SinhMa();
                    int t = tlbll.Them(tl);
                    LoadTL();
                    typemodal.Value = "hide";
                }
                else
                {
                    tl.MaTheLoai = hdId.Value;
                    tlbll.Sua(tl);
                    LoadTL();
                    typemodal.Value = "hide";
                }
            }
            if (typemodal.Value == "LV")
            {
                LinhVuc lv = new LinhVuc();
                lv.TenLinhVuc = txtTen.Text;
                lv.GhiChu     = txtGhichu.Text;
                if (editType.Value == "add")
                {
                    lv.MaLinhVuc = Tool.SinhMa();
                    int t = lvbll.Them(lv);
                    LoadLV();
                    typemodal.Value = "hide";
                }
                else
                {
                    lv.MaLinhVuc = hdId.Value;
                    lvbll.Sua(lv);
                    LoadLV();
                    typemodal.Value = "hide";
                }
            }
            if (typemodal.Value == "NN")
            {
                NgonNgu ng = new NgonNgu();
                ng.TenNgonNgu = txtTen.Text;

                if (editType.Value == "add")
                {
                    ng.MaNgonNgu = Tool.SinhMa();
                    int t = ngbll.Them(ng);
                    LoadNN();
                    typemodal.Value = "hide";
                }
                else
                {
                    ng.MaNgonNgu = hdId.Value;
                    ngbll.Sua(ng);
                    LoadNN();
                    typemodal.Value = "hide";
                }
            }
            if (typemodal.Value == "NXB")
            {
                NhaXuatBan nxb = new NhaXuatBan();
                nxb.TenNXB = txtTen.Text;
                nxb.GhiChu = txtGhichu.Text;
                if (editType.Value == "add")
                {
                    nxb.MaNXB = Tool.SinhMa();
                    int t = nxbbll.Them(nxb);
                    LoadNXB();
                    typemodal.Value = "hide";
                    //nxb.UrlLogo = Up(fileAnh);
                }
                else
                {
                    nxb.MaNXB = hdId.Value;
                    nxbbll.Sua(nxb);
                    LoadNXB();
                    typemodal.Value = "hide";
                }
            }
        }