public void Delete() { bool result = false; BAudit bAudit = new BAudit(); List <EAudit> listAudit = new List <EAudit>(); BClient bClient = new BClient(); EClient eClient = new EClient(); TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew); eClient.CodeTypeDocumentIdentity = "0"; eClient.NumberIdentity = Aleatory.GetString(8); eClient.FirstName = Aleatory.GetString(8); eClient.SecondName = Aleatory.GetString(8); eClient.FatherLastName = Aleatory.GetString(8); eClient.MotherLastName = Aleatory.GetString(8); eClient.Audit.UserRegister = Aleatory.GetString(8); EClient insertedEClient = bClient.Insert(eClient); if (insertedEClient != null) { insertedEClient.Audit.UserRegister = Aleatory.GetString(8); bClient.Delete(insertedEClient); EClient deletedEClient = bClient.Select(eClient); listAudit = bAudit.Select(eClient.Audit); if (deletedEClient == null && listAudit.Count > 0 && listAudit.Exists( x => x.UserRegister == insertedEClient.Audit.UserRegister && x.Code == insertedEClient.CodeClient.ToString() && x.TypeEvent == "Delete")) { result = true; } } ts.Dispose(); Assert.IsTrue(result); }
private void btnDelete_Click(object sender, EventArgs e) { try { DialogResult option; option = MessageBox.Show("Do you really want to delete?", "SysBusiness", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (option == DialogResult.OK) { string Code; string resp = ""; foreach (DataGridViewRow row in dataList.Rows) { if (Convert.ToBoolean(row.Cells[0].Value)) { Code = Convert.ToString(row.Cells[1].Value); resp = BClient.Delete(Convert.ToInt32(Code)); if (resp.Equals("OK")) { this.MessageOk("Success deleted"); } else { this.MessageError(resp); } } } this.ShowValues(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }