private void matudong()
        {
            string MaLoai = "TL001";
            int    dem    = 0;

            while (TheLoai_BUS.TimTL_TheoMa(MaLoai) != null)
            {
                dem += 1;
                if (dem < 10)
                {
                    MaLoai = "TL00" + dem.ToString();
                }
                else if (dem < 100)
                {
                    MaLoai = "TL0" + dem.ToString();
                }
                else if (dem < 1000)
                {
                    MaLoai = "TL" + dem.ToString();
                }
                else
                {
                    XtraMessageBox.Show("Không thể thêm nữa. Không đủ bộ nhớ!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            txtMaLoai.Text = MaLoai;
        }
        private void btnXoaTheLoai_Click(object sender, EventArgs e)
        {
            if (lvwTheLoai.SelectedItems.Count == 0)
            {
                return;
            }
            DialogResult drl = MessageBox.Show("Bạn thực sự muốn xóa Thể loại [" + lvwTheLoai.SelectedItems[0].SubItems[1].Text + "] và tất cả bài trong thể loại này không ?", "xóa album", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (drl == DialogResult.Cancel)
            {
                return;
            }

            string      matheloaiđangcchon = lvwTheLoai.SelectedItems[0].Tag.ToString();
            TheLoai_BUS a   = new TheLoai_BUS(matheloaiđangcchon);
            int         loi = a.xoaTheLoai();

            if (loi == 0)
            {
                MessageBox.Show("Đã xóa thành công mã thể loại [" + matheloaiđangcchon + "] ", "thành công hehe", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                MessageBox.Show("xóa thất bại mã thể loại [" + matheloaiđangcchon + "] ", "thất bại huhu", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            loadlai_listview();
        }
Exemple #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            List <Sach_DTO> lstSach = Sach_BUS.LayDSSach();

            dgvSach.DataSource                      = lstSach;
            cbonxb.DataSource                       = NhaXuatBan_BUS.LayDSTK();
            cbonxb.DisplayMember                    = "TenNXB";
            cbonxb.ValueMember                      = "MaNXB";
            cbotheloai.DataSource                   = TheLoai_BUS.LayDSTL();
            cbotheloai.DisplayMember                = "TenLoai";
            cbotheloai.ValueMember                  = "MaLoai";
            dgvSach.Columns["MaSach"].HeaderText    = "Mã sách";
            dgvSach.Columns["MaSach"].Width         = 80;
            dgvSach.Columns["TenSach"].HeaderText   = "Tên sách";
            dgvSach.Columns["TenSach"].Width        = 190;
            dgvSach.Columns["TheLoai"].HeaderText   = "Thể loại";
            dgvSach.Columns["TheLoai"].Width        = 130;
            dgvSach.Columns["TinhTrang"].HeaderText = "Tình trạng";
            dgvSach.Columns["NamXB"].HeaderText     = "Năm xuất bản";
            dgvSach.Columns["NamXB"].Width          = 110;
            dgvSach.Columns["SoLuong"].HeaderText   = "Số lượng";
            dgvSach.Columns["SoLuong"].Width        = 80;
            dgvSach.Columns["TacGia"].HeaderText    = "Tác giả";
            dgvSach.Columns["TacGia"].Width         = 160;
            dgvSach.Columns["NhaXB"].HeaderText     = "Nhà xuất bản";
            dgvSach.Columns["NhaXB"].Width          = 170;
            hienthi(true);
            txttracuu.Enabled = false;
        }
 private void btnXoa_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (TheLoai_BUS.TimTL_TheoMa(txtMaLoai.Text.Trim()) == null)
     {
         XtraMessageBox.Show("Bạn chưa chọn dòng cần xóa! ", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         DialogResult thongbao = XtraMessageBox.Show("Bạn có chắc muốn xóa thể loại này không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (thongbao == DialogResult.No)
         {
             XtraMessageBox.Show("Bạn đã hủy thao tác xóa ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else if (thongbao == DialogResult.Yes)
         {
             Theloai_DTO TL = new Theloai_DTO();
             TL.MaLoai = txtMaLoai.Text;
             if (TheLoai_BUS.XoaTL(txtMaLoai.Text.Trim()))
             {
                 frmTheLoai_Load(sender, e);
                 XtraMessageBox.Show("Bạn đã xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
 }
 // cập nhật lại danh sách thể loại
 void CapNhat()
 {
     if (txtTenTheLoai.Text == "")
     {
         MessageBox.Show("Không được bỏ trống tên thể loại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         txtTenTheLoai.Focus();
     }
     else
     {
         if (MessageBox.Show("Bạn thực sự muốn cập nhật thể loại này?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
         {
             TheLoai_DTO tl = new TheLoai_DTO();
             tl.TenTheLoai = txtTenTheLoai.Text;
             tl.MaTheLoai  = int.Parse(txtMaTheLoai.Text);
             string ketQua = TheLoai_BUS.SuaTheLoai(tl);
             if (ketQua != "Success")
             {
                 MessageBox.Show(ketQua, "Lỗi");
                 return;
             }
             MessageBox.Show("Cập nhật thành công");
             HienThiDanhSachTheLoai();
         }
     }
 }
        private void btnLuu_Click(object sender, EventArgs e)
        {
            try
            {
                if (!them && gvTheLoai.FocusedRowHandle == gvTheLoai.RowCount - 1)
                {
                    if (tbTenTL.Text != "")
                    {
                        //chuẩn hóa tên
                        string tenTL = ChuanHoa(tbTenTL.Text.ToLower());
                        TheLoai_BUS.themTL(tbMaTL.Text, tenTL);
                        MessageBox.Show("Thêm thành công");
                        // this.SinhVienbindingSource.EndEdit();
                        //thêm trực tiếp sinh viên vào gridview mà không load lại danh sách
                        gvTheLoai.SetFocusedRowCellValue(colTenTL, tenTL);
                        //load_DS();
                        //chuẩn hóa ở textbox
                        tbTenTL.Text = tenTL;
                        //
                        them = true;
                    }
                    else
                    {
                        MessageBox.Show("Nhập tên thể loại");
                    }
                }
                else
                {
                    if (MessageBox.Show("Bạn có chắc muốn sửa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        try
                        {
                            if (ChuanHoa(tbTenTL.Text.Trim().ToLower()) != gvTheLoai.GetFocusedRowCellValue(colTenTL).ToString().Trim())
                            {
                                string tenTL = ChuanHoa(tbTenTL.Text.ToLower());
                                TheLoai_BUS.suaTL(tbMaTL.Text.Trim(), tenTL);
                                gvTheLoai.SetFocusedRowCellValue(colTenTL, tenTL);
                                tbTenTL.Text = tenTL;
                            }

                            MessageBox.Show("Sửa thành công!");
                            sua = true;
                        }
                        catch
                        {
                            MessageBox.Show("Sửa không thành công");
                        }
                    }
                    else
                    {
                        tbTenTL.Text = gvTheLoai.GetFocusedRowCellValue(colTenTL).ToString();
                    }
                }
            }
            catch
            {
                MessageBox.Show("Lưu thất bại");
            }
        }
        public void HienThiDanhSachTheLoai()
        {
            Enable(false);
            btnThem.Enabled = true;
            btnSua.Enabled  = true;

            dgvTheLoai.DataSource = TheLoai_BUS.GetTheLoaiAll();
        }
 private void btnXoa_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         TheLoai_BUS.xoaTL(gvTheLoai.GetFocusedRowCellValue(colMaTL).ToString());
         TLbindingSource.RemoveAt(gvTheLoai.FocusedRowHandle);
         MessageBox.Show("Xóa thành công!");
     }
 }
 private void BtnLUU_Click(object sender, EventArgs e)
 {
     if (stt == 1)
     {
         if (txtTenTheLoai.Text.Trim() == "")
         {
             XtraMessageBox.Show("Bạn chưa nhập thể loại sách", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             Theloai_DTO TL = new Theloai_DTO();
             TL.MaLoai  = txtMaLoai.Text;
             TL.TenLoai = txtTenTheLoai.Text;
             if (TheLoai_BUS.TimTL_TheoMa(txtMaLoai.Text.Trim()) != null)
             {
                 XtraMessageBox.Show("Mã loại không được trùng ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else if (TheLoai_BUS.ThemTL(TL))
             {
                 frmTheLoai_Load(sender, e);
                 XtraMessageBox.Show("Bạn đã thêm thành công " + txtTenTheLoai.Text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
     }
     else if (stt == 2)
     {
         if (txtMaLoai.Text.Trim() == "")
         {
             XtraMessageBox.Show("Bạn chưa chọn dòng cần sửa", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else if (txtTenTheLoai.Text.Trim() == "")
         {
             XtraMessageBox.Show("Thể loại sách không được rỗng", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             Theloai_DTO TL = new Theloai_DTO();
             TL.MaLoai  = txtMaLoai.Text;
             TL.TenLoai = txtTenTheLoai.Text;
             if (TheLoai_BUS.TimTL_TheoMa(txtMaLoai.Text.Trim()) == null)
             {
                 XtraMessageBox.Show("Mã loại không được sửa ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             if (TheLoai_BUS.SuaTL(TL))
             {
                 frmTheLoai_Load(sender, e);
                 XtraMessageBox.Show("Bạn đã sửa thành công " + txtTenTheLoai.Text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 XtraMessageBox.Show("Không sửa được", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Exemple #10
0
 public frm_TheLoai(int _SoTheLoai)
 {
     InitializeComponent();
     soTheLoai      = _SoTheLoai;
     theLoaiBUS     = new TheLoai_BUS();
     theLoaiDTO     = new TheLoai_DTO();
     listTheLoai    = new List <string>();
     kiemtra        = true;
     xacNhanCapNhap = false;
 }
        private void frmBook_Add_Load(object sender, EventArgs e)
        {
            lblBook_ID.Text           = sach_BUS.PhatSinhMaSach();
            lblBook_SeriesOfBook.Text = dauSach_BUS.PhatSinhMaDauSach();

            TheLoai_BUS theLoai_BUS = new TheLoai_BUS();

            comBook_Category.DataSource    = theLoai_BUS.LayDSTheLoai();
            comBook_Category.DisplayMember = "TenTheLoai";
            comBook_Category.ValueMember   = "MaTheLoai";
        }
Exemple #12
0
 private void button2_Click(object sender, EventArgs e)
 {
     frmLapPhieuNhapSach.maSach = layMaSach;
     layTheLoai = TheLoai_BUS.LayTenTheLoai(int.Parse(layTheLoai));
     frmLapPhieuNhapSach.theloai = layTheLoai;
     frmLapPhieuNhapSach.tensach = layTenSach;
     frmHoaDonBanSach.maSach     = layMaSach;
     frmHoaDonBanSach.tenSach    = layTenSach;
     frmHoaDonBanSach.donGiaBan  = layDonGiaBan;
     this.Close();
 }
        private void frmDanhSachDauSach_Load(object sender, EventArgs e)
        {
            colTheLoai.ValueMember   = "MaTheLoai";
            colTheLoai.DisplayMember = "TenTheLoai";
            colTheLoai.DataSource    = TheLoai_BUS.GetTheLoaiAll();

            cboTimTheLoai.ValueMember   = "MaTheLoai";
            cboTimTheLoai.DisplayMember = "TenTheLoai";
            cboTimTheLoai.DataSource    = TheLoai_BUS.GetTheLoaiAll();

            HienThiDanhSachDauSach();
        }
Exemple #14
0
        private void frmQuanLySach_Load(object sender, EventArgs e)
        {
            colMaTheLoai.ValueMember   = "MaTheLoai";
            colMaTheLoai.DisplayMember = "TenTheLoai";
            colMaTheLoai.DataSource    = TheLoai_BUS.GetTheLoaiAll();

            colTenDauSach.ValueMember   = "MaDauSach";
            colTenDauSach.DisplayMember = "TenDauSach";
            colTenDauSach.DataSource    = DauSach_BUS.SelectDauSachAll();

            HienThiThongTinSach();
        }
        private void frmTheLoai_Load(object sender, EventArgs e)
        {
            List <Theloai_DTO> lstTL = TheLoai_BUS.LayDSTL();

            DgvTheLoai.DataSource = lstTL;
            DgvTheLoai.Columns["MaLoai"].HeaderText  = "Mã loại";
            DgvTheLoai.Columns["MaLoai"].Width       = 150;
            DgvTheLoai.Columns["TenLoai"].HeaderText = "Tên loại";
            DgvTheLoai.Columns["TenLoai"].Width      = 270;
            txttracuu.Enabled = false;
            HienThi(true);
        }
 private void Load()
 {
     try
     {
         TLbindingSource.DataSource = TheLoai_BUS.DanhSachTL();
         gcTheLoai.DataSource       = TLbindingSource;
     }
     catch
     {
         MessageBox.Show("Load bị lỗi!");
     }
 }
Exemple #17
0
        public void HienThiDanhSachSach()
        {
            colTheLoai.ValueMember   = "MaTheLoai";
            colTheLoai.DisplayMember = "TenTheLoai";
            colTheLoai.DataSource    = TheLoai_BUS.GetTheLoaiAll();

            cmbTheLoai.ValueMember   = "MaTheLoai";
            cmbTheLoai.DisplayMember = "TenTheLoai";
            cmbTheLoai.DataSource    = TheLoai_BUS.GetTheLoaiAll();

            cmbTheLoai.Text = "";
            HienThiThongTinSach();
        }
Exemple #18
0
        private void dgvDauSach_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            int dong = e.RowIndex;

            txtMaDauSach.Text        = dgvDauSach.Rows[dong].Cells[0].Value.ToString();
            txtMaSachCT.Text         = dgvDauSach.Rows[dong].Cells[0].Value.ToString();
            txtTenDauSach.Text       = dgvDauSach.Rows[dong].Cells[1].Value.ToString();
            cboTheLoai.SelectedValue = (int)(dgvDauSach.Rows[dong].Cells[2].Value);
            TheLoai_DTO tl = TheLoai_BUS.GetTheLoaiByMa((int)(dgvDauSach.Rows[dong].Cells[2].Value));

            cboTheLoai.Text         = tl.TenTheLoai;
            dgvCT_TacGia.DataSource = DauSach_BUS.SelectCTTacGiaByMa(int.Parse(dgvDauSach.Rows[dong].Cells[0].Value.ToString()));
        }
 private void txttracuu_TextChanged(object sender, EventArgs e)
 {
     if (txttracuu.Text.Trim() == "")
     {
         List <Theloai_DTO> lstTL = TheLoai_BUS.LayDSTL();
         DgvTheLoai.DataSource = lstTL;
     }
     else
     {
         List <Theloai_DTO> lstTimKiem = TheLoai_BUS.TimTL(dieukien, txttracuu.Text);
         DgvTheLoai.DataSource = lstTimKiem;
     }
 }
Exemple #20
0
        private void dgvSach_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            int dong = e.RowIndex;

            txtMaSach.Text           = dgvSach.Rows[dong].Cells[0].Value.ToString();
            txtTenSach.Text          = dgvSach.Rows[dong].Cells[1].Value.ToString();
            cmbTheLoai.SelectedValue = (int)(dgvSach.Rows[dong].Cells[2].Value);
            TheLoai_DTO tl = TheLoai_BUS.GetTheLoaiByMa((int)(dgvSach.Rows[dong].Cells[2].Value));

            cmbTheLoai.Text    = tl.TenTheLoai;
            txtTacGia.Text     = dgvSach.Rows[dong].Cells[3].Value.ToString();
            txtDonBanSach.Text = dgvSach.Rows[dong].Cells[4].Value.ToString();
            txtSoLuongTon.Text = dgvSach.Rows[dong].Cells[5].Value.ToString();
        }
Exemple #21
0
        private void frmQuanLyDauSach_Load(object sender, EventArgs e)
        {
            this.Size = new Size(750, 615);
            colMaTheLoai.ValueMember   = "MaTheLoai";
            colMaTheLoai.DisplayMember = "TenTheLoai";
            colMaTheLoai.DataSource    = TheLoai_BUS.GetTheLoaiAll();

            cboTheLoai.ValueMember   = "MaTheLoai";
            cboTheLoai.DisplayMember = "TenTheLoai";
            cboTheLoai.DataSource    = TheLoai_BUS.GetTheLoaiAll();

            HienThiDauSach();
            cboTheLoai.Text = "";
        }
Exemple #22
0
        private void btnDSDauSach_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Enable(true);
            Load();
            DataTable dtb = TheLoai_BUS.DStenTL();

            for (int i = 0; i < dtb.Rows.Count; i++)
            {
                // string name = dtb.Rows[i][0].ToString().ToUpper();

                string name = ChuanHoa(dtb.Rows[i][0].ToString().ToLower());
                cboTheLoai.Items.Add(name);
                repositoryItemComboBox1.Items.Add(name);
            }
        }
Exemple #23
0
        public frm_DauSach()
        {
            InitializeComponent();
            dausachBUS = new DauSach_BUS();
            dausachDTO = new DauSach_DTO();
            theLoai    = new TheLoai_BUS();
            qd2        = new QuyDinh2_BUS();
            KhoiTaoCmdLoai();
            KhoiTaoCmbTiemKiem();
            DataTable table = new DataTable();

            table = qd2.Select();
            var i = table.Rows[0].ItemArray;

            HanNhanSach = int.Parse(i[1].ToString());
        }
        private void frmBook_Update_Load(object sender, EventArgs e)
        {
            string   Ma_Sach  = DoAn.MANAGER.Book.frmBook.strMaSach;
            Sach_BUS sach_BUS = new Sach_BUS();
            Sach_DTO sach_DTO = sach_BUS.TimSachTheoMaSach(Ma_Sach);

            txtBookUpdate_TitleOfBook.Text = sach_DTO.TenSach;
            txtBookUpdate_Publisher.Text   = sach_DTO.TenNhaXuatBan;
            txtBookUpdate_Author.Text      = sach_DTO.TenTacGia;
            txtBookUpdate_PublicDate.Text  = sach_DTO.NamXuatBan.ToString();
            lblBookUpdate_ID.Text          = sach_DTO.MaSach;
            txtBookUpdate_Prices.Text      = sach_DTO.DonGia.ToString();

            TheLoai_BUS theLoai_BUS = new TheLoai_BUS();

            comBookUpdate_Category.DataSource    = theLoai_BUS.LayDSTheLoai();
            comBookUpdate_Category.DisplayMember = "TenTheLoai";
            comBookUpdate_Category.ValueMember   = "MaTheLoai";
        }
        private void lvwAlbum_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvwAlbum.SelectedItems.Count == 0)
            {
                return;
            }
            lvwBaiHat_Album.Items.Clear();
            DataTable dt = null;

            try
            {
                dt = new BaiHat_BUS().getBaiHat_by_album(lvwAlbum.SelectedItems[0].Tag.ToString());

                foreach (DataRow dr in dt.Rows)
                {
                    ListViewItem li = lvwBaiHat_Album.Items.Add("");
                    li.SubItems.Add(dr["tenbaihat"].ToString());
                    DataTable dt1      = new Casi_Baihat_BUS().getCasi_BaiHat_by_mabaihat(dr["mabaihat"].ToString());
                    string    cac_casi = "";
                    foreach (DataRow r in dt1.Rows)
                    {
                        DataTable dtcasi = new CaSi_BUS().getCasi_by_macasi(r["macasi"].ToString());
                        foreach (DataRow r1 in dtcasi.Rows)
                        {
                            cac_casi += r1["tencasi"].ToString() + ", ";
                        }
                    }
                    li.SubItems.Add(cac_casi + "...");
                    DataTable dtA = new TheLoai_BUS().getTheLoai_by_ma(dr["matheloai"].ToString());
                    DataRow   rr  = dtA.Rows[0];
                    li.SubItems.Add(rr["tentheloai"].ToString());
                    li.SubItems.Add(dr["loibaihat"].ToString());
                    li.Tag = dr["mabaihat"];
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Lỗi không xác định");
                return;
            }
            stt(lvwBaiHat_Album);
            lblBaiHatTrongAlbum.Text = "Danh sách các bài hát có trong Album: [" + lvwAlbum.SelectedItems[0].SubItems[1].Text + "]";
        }
 private void btnThem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (them)
     {
         tbTenTL.Clear();
         //mã thể loại tự tăng
         string maTL = nextMa(TheLoai_BUS.LastMaTL());
         them = false;
         TLbindingSource.AddNew();
         //GÁN vào textbox và gridview
         gvTheLoai.SetFocusedRowCellValue(colMaTL, maTL);
         tbMaTL.Text = maTL;
         //trỏ tới dòng cuối cùng trong gridview
         gvTheLoai.FocusedRowHandle = gvTheLoai.RowCount - 1;
         tbTenTL.Focus();
     }
     else
     {
         gvTheLoai.FocusedRowHandle = gvTheLoai.RowCount - 1;
         tbTenTL.Focus();
     }
 }
 // thêm vào danh sách thể loại
 void Them()
 {
     if (txtTenTheLoai.Text == "")
     {
         MessageBox.Show("Không được bỏ trống tên thể loại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtTenTheLoai.Focus();
     }
     else
     {
         if (MessageBox.Show("Bạn thực sự muốn thêm thể loại này?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
         {
             TheLoai_DTO tl = new TheLoai_DTO();
             tl.TenTheLoai = txtTenTheLoai.Text;
             string ketQua = TheLoai_BUS.ThemTheLoai(tl);
             if (ketQua != "Success")
             {
                 MessageBox.Show(ketQua, "Lỗi");
                 return;
             }
             MessageBox.Show("Thêm thể loại thành công");
             HienThiDanhSachTheLoai();
         }
     }
 }
Exemple #28
0
 private void cbotheloai_Click(object sender, EventArgs e)
 {
     cbotheloai.DataSource    = TheLoai_BUS.LayDSTL();
     cbotheloai.DisplayMember = "TenLoai";
     cbotheloai.ValueMember   = "MaLoai";
 }
 //khi sửa ở 1 dòng trên gridview và trỏ sang dòng khác thì có sự kiện
 private void gvTheLoai_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
 {
     if (!them)
     {
         if (gvTheLoai.FocusedRowHandle != gvTheLoai.RowCount - 1)
         {
         }
         else
         {
             if (MessageBox.Show("Bạn có chắc muốn lưu không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 try
                 {
                     if (gvTheLoai.GetFocusedRowCellValue(colTenTL).ToString() != "")
                     {
                         //chuẩn hóa tên
                         string tenTL = ChuanHoa(gvTheLoai.GetFocusedRowCellValue(colTenTL).ToString().ToLower());
                         string maTL  = gvTheLoai.GetFocusedRowCellValue(colMaTL).ToString().Trim();
                         TheLoai_BUS.themTL(maTL, tenTL);
                         MessageBox.Show("Thêm thành công");
                         // this.SinhVienbindingSource.EndEdit();
                         //chuẩn hóa trực tiếp sinh viên vào gridview mà không load lại danh sách
                         gvTheLoai.SetFocusedRowCellValue(colTenTL, tenTL);
                         //load_DS();
                         //chuẩn hóa ở textbox
                         tbTenTL.Text = tenTL;
                         //
                         them = true;
                     }
                     else
                     {
                         MessageBox.Show("Nhập tên thể loại");
                     }
                 }
                 catch
                 {
                     MessageBox.Show("Lưu không thành công!");
                 }
             }
             else
             {
                 them = true;
                 TLbindingSource.RemoveAt(gvTheLoai.RowCount - 1);
             }
         }
     }
     else if (daChuanhoa)
     {
         daChuanhoa = false;
     }
     else if (sua)
     {
         sua = false;
     }
     else
     {
         string tenTL = ChuanHoa(gvTheLoai.GetFocusedRowCellValue(colTenTL).ToString().ToLower());
         string maTL  = gvTheLoai.GetFocusedRowCellValue(colMaTL).ToString();
         //khi vừa mới thêm xong
         if (tbTenTL.Text == tenTL)
         {
         }
         else
         {
             if (MessageBox.Show("Bạn có chắc muốn sửa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 try
                 {
                     // string maLop = Lop_BUS.maLop(cboLop.Text);
                     //  sv = new SinhVien_DTO(tbHoSV.Text, tbTenSV.Text, cboGioiTinh.Text, dtpNgaySinh.Value, tbDiaChi.Text, tbNoiSinh.Text, maLop);
                     //   SinhVien_BUS.suaSV(sv);
                     TheLoai_BUS.suaTL(maTL, tenTL);
                     gvTheLoai.SetFocusedRowCellValue(colTenTL, tenTL);
                     tbTenTL.Text = tenTL;
                     MessageBox.Show("Sửa thành công!");
                 }
                 catch
                 {
                     MessageBox.Show("Sửa không thành công!");
                 }
             }
             else
             {
                 gvTheLoai.SetFocusedRowCellValue(colTenTL, tbTenTL.Text);
             }
         }
     }
 }
Exemple #30
0
 private void button2_Click(object sender, EventArgs e)
 {
     dataGridView4.DataSource = TheLoai_BUS.LoadDanhSachTheLoai();
 }