Exemple #1
0
        private void btnCheckTL_Click(object sender, EventArgs e)
        {
            try
            {
                TaiLieu taiLieu = TaiLieu.GetTaiLieuTheoMa(txtMaTaiLieu.Text);
                if (taiLieu == null)
                {
                    throw new Exception("Không tìm thấy tài liệu với mã tương ứng");
                }

                txtIDTL.Text       = taiLieu.IDTaiLieu.ToString();
                txtNhanDe.Text     = taiLieu.NhanDe.ToString();
                txtSoLuong.Text    = taiLieu.SoLuong.ToString();
                txtSLCoSan.Text    = TaiLieu.SoLuongCoSan(taiLieu.IDTaiLieu).ToString();
                txtLanXuatBan.Text = taiLieu.LanXuatBan.ToString();
                txtSoTrang.Text    = taiLieu.SoTrang.ToString();

                NhaXuatBan nxb = NhaXuatBan.TimNXBTheoID(taiLieu.IDNXB);
                txtNXB.Text = nxb.TenNhaXuatBan;
                NgonNgu nn = NgonNgu.LayDSNgonNgu().Find(c => c.IDNgonNgu == taiLieu.IDNgonNgu);
                txtNgonNgu.Text    = nn.TenNgonNgu;
                txtNamXuatBan.Text = taiLieu.NamXuatBan.ToString();
                TacGia tg = TacGia.LayDSTacGia().Find(c => c.IDTacGia == taiLieu.IDTacGia);
                txtTacGia.Text = tg.TenTacGia;
                TheLoai theLoai = TheLoai.GetDanhSachTheLoai().Find(c => c.IDTheLoai == taiLieu.IDTheLoai);
                txtTheLoai.Text = theLoai.TenTheLoai;
                GiaXep gx = GiaXep.GetDSGiaXep().Find(c => c.IDGiaXep == taiLieu.IDGiaXep);
                txtGiaXep.Text = gx.MaGiaXep;
                Kho kho = Kho.GetDanhSachKho().Find(c => c.IDKho == gx.IDKho);
                txtKho.Text        = kho.MaKho;
                txtNamXuatBan.Text = taiLieu.NamXuatBan.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                txtMaTaiLieu.Focus();
            }
        }
Exemple #2
0
        void Set_CbLoaiTimTheo(string loai = "TacGia")
        {
            switch (loai)
            {
            case "NgonNgu":
            {
                lbTimTheo.Visible           = cbLoaiTimTheo.Visible = true;
                lbTimTheo.Text              = "Chọn ngôn ngữ";
                cbLoaiTimTheo.DataSource    = NgonNgu.LayDSNgonNgu();
                cbLoaiTimTheo.ValueMember   = "IDNgonNgu";
                cbLoaiTimTheo.DisplayMember = "TenNgonNgu";
                break;
            }

            case "NhaXuatBan":
            {
                lbTimTheo.Visible           = cbLoaiTimTheo.Visible = true;
                lbTimTheo.Text              = "Chọn NXB";
                cbLoaiTimTheo.DataSource    = NhaXuatBan.LayDSNhaXuatBan();
                cbLoaiTimTheo.ValueMember   = "IDNhaXuatBan";
                cbLoaiTimTheo.DisplayMember = "TenNhaXuatBan";
                break;
            }

            case "GiaXep":
            {
                lbTimTheo.Visible           = cbLoaiTimTheo.Visible = true;
                lbTimTheo.Text              = "Chọn giá xếp";
                cbLoaiTimTheo.DataSource    = GiaXep.GetDSGiaXep();
                cbLoaiTimTheo.ValueMember   = "IDGiaXep";
                cbLoaiTimTheo.DisplayMember = "MaGiaXep";
                break;
            }

            case "TheLoai":
            {
                lbTimTheo.Visible           = cbLoaiTimTheo.Visible = true;
                lbTimTheo.Text              = "Chọn thể loại";
                cbLoaiTimTheo.DataSource    = TheLoai.GetDanhSachTheLoai();
                cbLoaiTimTheo.ValueMember   = "IDTheLoai";
                cbLoaiTimTheo.DisplayMember = "TenTheLoai";
                break;
            }

            case "TacGia":
            {
                lbTimTheo.Visible           = cbLoaiTimTheo.Visible = true;
                lbTimTheo.Text              = "Chọn tác giả";
                cbLoaiTimTheo.DataSource    = TacGia.LayDSTacGia();
                cbLoaiTimTheo.ValueMember   = "IDTacGia";
                cbLoaiTimTheo.DisplayMember = "TenTacGia";
                break;
            }

            default:
            {
                lbTimTheo.Visible        = cbLoaiTimTheo.Visible = false;
                lbTimTheo.Text           = "TatCa";
                cbLoaiTimTheo.DataSource = new int[] { 0 };
                break;
            }
            }
        }