public void RemoveTest() { var salesman = new Salesman { slsmCode = "20180001" }; var result = salesmanRepo.Delete(salesman); Assert.IsTrue(result != 0); }
private void tsbDelete_Click(object sender, EventArgs e) { var userAccess = userAccessRepository.GetAll(); bool isAllowed = userAccess.Exists(u => u.FullName == Store.ActiveUser && u.ObjectName == "Salesman" && u.IsDelete); if (isAllowed == false && Store.IsAdministrator == false) { MessageBox.Show("Anda tidak dapat menghapus", "Perhatian", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (salesmanRepository.IsSalesmanUsedBySales(new Guid(txtID.Text))) { MessageBox.Show("Tidak bisa menghapus " + "\n\n" + "Salesman : " + txtSalesmanName.Text + "\n\n" + "dipakai di Transaksi Penjualan ", "Perhatian", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (salesmanRepository.IsSalesmanUsedByPayableBalance(new Guid(txtID.Text))) { MessageBox.Show("Tidak bisa menghapus " + "\n\n" + "Salesman : " + txtSalesmanName.Text + "\n\n" + "sudah dipakai di Saldo Awal Piutang ", "Perhatian", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (salesmanRepository.IsSalesmanUsedBySalesmanFee(new Guid(txtID.Text))) { MessageBox.Show("Tidak bisa menghapus " + "\n\n" + "Salesman : " + txtSalesmanName.Text + "\n\n" + "sudah dipakai di Presentase Komisi Salesman ", "Perhatian", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (MessageBox.Show("Anda yakin ingin menghapus '" + txtSalesmanName.Text + "'", "Perhatian", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { salesmanRepository.Delete(new Guid(txtID.Text)); GetLastSalesman(); LoadSalesmen(); } if (lvwSalesman.Items.Count == 0) { tsbEdit.Enabled = false; tsbDelete.Enabled = false; tsbRefresh.Enabled = false; tsbMenuFilter.Enabled = false; txtSearch.Enabled = false; tsbFilter.Enabled = false; ClearForm(); } } } }