public void SaveTest() { var obj = new Supplier { nama_supplier = "Pixel Computer", alamat = "Solo", kontak = "Yusuf", telepon = "08138383838" }; var validationError = new ValidationError(); var result = _bll.Save(obj, ref validationError); Console.WriteLine("Error : " + validationError.Message); Assert.IsTrue(result != 0); var newObj = _bll.GetByID(obj.supplier_id); Assert.IsNotNull(newObj); Assert.AreEqual(obj.supplier_id, newObj.supplier_id); Assert.AreEqual(obj.nama_supplier, newObj.nama_supplier); Assert.AreEqual(obj.alamat, newObj.alamat); Assert.AreEqual(obj.kontak, newObj.kontak); Assert.AreEqual(obj.telepon, newObj.telepon); }
protected override void Simpan() { if (_isNewData) { _supplier = new Supplier(); } _supplier.nama_supplier = txtSupplier.Text; _supplier.alamat = txtAlamat.Text; _supplier.kontak = txtKontak.Text; _supplier.telepon = txtTelepon.Text; var result = 0; var validationError = new ValidationError(); using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0))) { if (_isNewData) { result = _bll.Save(_supplier, ref validationError); } else { result = _bll.Update(_supplier, ref validationError); } if (result > 0) { Listener.Ok(this, _isNewData, _supplier); if (_isNewData) { base.ResetForm(this); txtSupplier.Focus(); } else { this.Close(); } } else { if (validationError.Message.NullToString().Length > 0) { MsgHelper.MsgWarning(validationError.Message); base.SetFocusObject(validationError.PropertyName, this); } else { MsgHelper.MsgUpdateError(); } } } }