private void SaveSalesman() { if (txtSalesmanName.Text == "") { MessageBox.Show("Nama harus diisi", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); txtSalesmanName.Focus(); } else if (formMode == FormMode.Add && salesmanRepository.IsSalesmanNameExisted(txtSalesmanName.Text)) { MessageBox.Show("Salesman : " + txtSalesmanName.Text + "\n\n" + "sudah ada ", "Perhatian", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtPhone1.Text == "") { MessageBox.Show("Telepon 1 harus diisi", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); txtPhone1.Focus(); } else { Salesman salesman = new Salesman(); salesman.Name = txtSalesmanName.Text; salesman.Phone1 = txtPhone1.Text; salesman.Phone2 = txtPhone2.Text; salesman.Address = txtAddress.Text; salesman.Notes = txtNotes.Text; salesman.IsActive = chkIsActive.Checked; if (formMode == FormMode.Add) { salesmanRepository.Save(salesman); GetLastSalesman(); } else if (formMode == FormMode.Edit) { salesman.ID = new Guid(txtID.Text); salesmanRepository.Update(salesman); } LoadSalesmen(); DisableForm(); formMode = FormMode.View; this.Text = "Salesman"; } }
public void AddTest() { var salesman = new Salesman { slsmCode = "20180001", slsmName = "Mamet", slsmAddress = "Perum Telaga Murni No.22", slsmIdNumber = 31274000, slsmSupv = "Munadi", slsmPhoto = "Pgoto", slsmTelp = "0882332323" }; var result = salesmanRepo.Save(salesman); Assert.IsTrue(result != 0); }