private void dvPhieunhap_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == dvPhieunhap.Columns["col_xoaPN"].Index) { // int pn = dvPhieunhap.datakeys Rows[e.RowIndex]; int pn = Int32.Parse(dvPhieunhap.Rows[e.RowIndex].Cells[0].Value.ToString()); if (DialogResult.Yes == MessageBox.Show("Bạn có muốn xóa không!", "Lưu ý", MessageBoxButtons.YesNo)) { try { svnh.XoaPN(pn); //pn.Delete(); dvPhieunhap.DataSource = null; dvPhieunhap.DataSource = svnh.All(); } catch (Exception ex) { MessageBox.Show("Không xóa được: " + ex.Message, "Loi"); } } } else if (e.ColumnIndex == dvPhieunhap.Columns["col_xemChiTiet"].Index) { int pn = Int32.Parse(dvPhieunhap.Rows[e.RowIndex].Cells[0].Value.ToString()); DateTime pn1 = DateTime.Parse(dvPhieunhap.Rows[e.RowIndex].Cells[1].Value.ToString()); _mapn = pn; _ngay = pn1; FormCTNhapHang frm = new FormCTNhapHang(); this.Close(); frm.Show(); } }
private void btnThemMoi_Click(object sender, EventArgs e) { this.Close(); _mapn = 0; FormCTNhapHang ctnh = new FormCTNhapHang(); ctnh.Show(); }