private void bt_xoa_Click(object sender, EventArgs e) { int currentRowIndex = data_tiencong.CurrentCellAddress.Y;// 'current row selected //'Verify that indexing OK if (-1 < currentRowIndex && currentRowIndex < data_tiencong.RowCount) { TienCongDTO tc = new TienCongDTO(); tc.Maloaitiencong = int.Parse(tb_matiencong.Text); //2. Kiểm tra data hợp lệ or not //3. Thêm vào DB bool kq = tcBus.xoa(tc); if (kq == false) { MessageBox.Show("Xóa tiền công thất bại. Vui lòng kiểm tra lại dũ liệu"); } else { MessageBox.Show("Xóa tiền công thành công"); this.loadData_Vao_GridView(); tb_matiencong.Clear(); tb_tenloaitc.Clear(); tb_tiencong.Clear(); } } CurrencyManager myCurrencyManager = (CurrencyManager)this.BindingContext[data_tiencong.DataSource]; myCurrencyManager.Refresh(); }
private void button_xoa_Click(object sender, EventArgs e) { DialogResult = MessageBox.Show("Bạn có chắc chắn muốn xóa ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (DialogResult == DialogResult.Yes) { TienCongDTO tc = new TienCongDTO(); tc.Matiencong = int.Parse(txttmtc.Text); bool kq = tcBus.xoa(tc); if (kq == false) { MessageBox.Show("Xóa thông tin thất bại. Vui lòng kiểm tra lại dữ liệu"); } else { MessageBox.Show("Xóa thông tin thành công"); } this.loadData_Vao_GridView(); txttmtc.Text = ""; txttdv.Text = ""; txttc.Text = ""; } }