private void btnXoa_Click(object sender, EventArgs e) { try { if (listKhachHang.SelectedRows.Count == 1) { int rowSelected = listKhachHang.SelectedRows[0].Index; String selectedId = listKhachHang.Rows[rowSelected].Cells["ID"].Value.ToString(); DialogResult result = MessageBox.Show("Bạn có chắc muốn xóa?", "Confirmation", MessageBoxButtons.YesNoCancel); if (result == DialogResult.Yes) { FormSearchCustomerObj obj = new FormSearchCustomerObj(); obj.idKhachHang = selectedId; LogicResult logicRS = new CustomerLogic().deleteCustomerLogic(obj); FormSearchCustomerObj frmObj = tranfersInput(); CustomerLogic logic = new CustomerLogic(); LogicResult searchResult = logic.searchCustomerLogic(frmObj); outputObj = (FormSearchCustomerObj)searchResult.obj; this.listKhachHang.DataSource = outputObj.listKhachHangs; MessageBox.Show("SUCCESS: " + logicRS.msg); } } } catch (Exception ex) { MessageBox.Show("ERROR: " + ex.Message); } }
private FormSearchCustomerObj tranfersInput() { FormSearchCustomerObj obj = new FormSearchCustomerObj(); obj.idKhachHang = StringUtils.Trim(this.idKhachHang.Text); obj.tenKhachHang = StringUtils.Trim(this.tenKhachHang.Text); //obj.trangThaiNo = this.trangthaiNo; return(obj); }
private void search_Click(object sender, EventArgs e) { try { FormSearchCustomerObj frmObj = tranfersInput(); CustomerLogic logic = new CustomerLogic(); LogicResult result = logic.searchCustomerLogic(frmObj); outputObj = (FormSearchCustomerObj)result.obj; this.listKhachHang.DataSource = outputObj.listKhachHangs; } catch (Exception ex) { MessageBox.Show("ERROR: " + ex.Message); } }