コード例 #1
0
        private void btnsuahp_Click(object sender, EventArgs e)
        {
            //Nếu k có dòng nào trong gridview được chọn
            if (gridviewhp.SelectedCells.Count <= 0)
            {
                return;
            }

            if (!DuLieuHopLe())
            {
                return;
            }

            string  mahp   = gridviewhp.SelectedCells[0].OwningRow.Cells[0].Value.ToString();
            string  tenhp  = txttenhp.Text;
            int     stc    = string.IsNullOrEmpty(txtstchp.Text) ? 0 : int.Parse(txtstchp.Text);
            string  loaihp = cbbLoaiHocPhan.Text;
            decimal tsdqt  = decimal.Parse(txtTrongSoDQT.Text);
            decimal tsdt   = decimal.Parse(txtTrongSoDThi.Text);

            MonHoc monhoc = new MonHoc(mahp, tenhp, stc, loaihp, tsdqt, tsdt);

            if (monhocBUS.Sua(monhoc))
            {
                MessageBox.Show("Thành công !");

                bs.DataSource = monhocBUS.DanhSach();
            }
            else
            {
                MessageBox.Show("Lỗi !", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            txtmahp.Focus();
        }