Ejemplo n.º 1
0
        void ShowPL()
        {
            PhanLoaiDAO p = new PhanLoaiDAO();

            tlList.DataSource = p.GetListPhanLoai();
            dgvTL.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGray;
        }
Ejemplo n.º 2
0
        void LoadCbPhanLoai()
        {
            PhanLoaiDAO phanloai = new PhanLoaiDAO();

            cbTheLoai.DataSource    = phanloai.GetListPhanLoai();
            cbTheLoai.DisplayMember = "TenLoai";
        }
Ejemplo n.º 3
0
        private void txtSearchTLorNN_TextChanged(object sender, EventArgs e)
        {
            string key = txtSearchTLorNN.Text;

            if (radMaTL.Checked == true)
            {
                PhanLoaiDAO pl = new PhanLoaiDAO();
                tlList.DataSource = pl.SearchPhanLoai(key);
            }
            if (radMaNN.Checked == true)
            {
                NgonNguDAO nn = new NgonNguDAO();
                nnList.DataSource = nn.searchNgonNgu(key);
            }
        }
Ejemplo n.º 4
0
        private void btnDeleteTL_Click(object sender, EventArgs e)
        {
            string      matl  = txtMaTL.Text;
            string      tentl = txtTenTL.Text;
            PhanLoaiDAO pl    = new PhanLoaiDAO();

            if (pl.DeleteNgonNgu(matl))
            {
                MessageBox.Show("Xóa Thể loại thành công");
                ShowPL();
            }
            else
            {
                MessageBox.Show("Có lỗi");
            }
        }
Ejemplo n.º 5
0
        private void btnAddTL_Click(object sender, EventArgs e)
        {
            string matl  = TaoMaPL();
            string tentl = txtTenTL.Text;


            PhanLoaiDAO pl = new PhanLoaiDAO();

            if (pl.InsertNgonNgu(matl, tentl))
            {
                MessageBox.Show("Thêm Thể loại thành công");
                ShowPL();
            }
            else
            {
                MessageBox.Show("Có lỗi");
            }
        }
Ejemplo n.º 6
0
        private void txtMaSach_TextChanged(object sender, EventArgs e)
        {
            try
            {
                string      MaSach   = dgvBook.SelectedCells[0].OwningRow.Cells["MaSach"].Value.ToString();
                PhanLoaiDAO phanloai = new PhanLoaiDAO();
                PhanLoai    pl       = phanloai.GetListPhanLoaiByMaSach(txtMaSach.Text);
                int         index    = -1;
                int         i        = 0;
                foreach (PhanLoai item in cbTheLoai.Items)
                {
                    if (item.MaLoai == pl.MaLoai)
                    {
                        index = i;
                        break;
                    }
                    i++;
                }
                cbTheLoai.SelectedIndex = index;

                NgonNguDAO nn      = new NgonNguDAO();
                NgonNgu    ngonNgu = nn.GetListNgonNguByMaSach(txtMaSach.Text);
                int        index1  = -1;
                int        j       = 0;
                foreach (NgonNgu item in cbNgonNgu.Items)
                {
                    if (item.MaNgonNgu == ngonNgu.MaNgonNgu)
                    {
                        index1 = j;
                        break;
                    }
                    j++;
                }
                cbNgonNgu.SelectedIndex = index1;
            }
            catch
            {
            }
        }
Ejemplo n.º 7
0
        string TaoMaPL()
        {
            PhanLoaiDAO nv  = new PhanLoaiDAO();
            string      old = nv.GetMaxMaPL();

            old = old.TrimStart('L');

            int newCode = int.Parse(old);

            newCode += 1;
            string code = "L";

            if (newCode < 10)
            {
                code = code + "0" + newCode;
            }
            else
            {
                code = code + newCode;
            }
            return(code);
        }