private void OnSaveInfo() { try { this.Invoke(new MethodInvoker(delegate() { _nhanXetKhamLamSang.Loai = cboCoQuan.SelectedIndex; _nhanXetKhamLamSang.NhanXet = txtNhanXet.Text; })); _nhanXetKhamLamSang.Status = (byte)Status.Actived; if (_isNew) { _nhanXetKhamLamSang.CreatedDate = DateTime.Now; _nhanXetKhamLamSang.CreatedBy = Guid.Parse(Global.UserGUID); } else { _nhanXetKhamLamSang.UpdatedDate = DateTime.Now; _nhanXetKhamLamSang.UpdatedBy = Guid.Parse(Global.UserGUID); } Result result = NhanXetKhamLamSangBus.InsertNhanXetKhamLamSang(_nhanXetKhamLamSang); if (!result.IsOK) { MsgBox.Show(this.Text, result.GetErrorAsString("NhanXetKhamLamSangBus.InsertNhanXetKhamLamSang"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("NhanXetKhamLamSangBus.InsertNhanXetKhamLamSang")); this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } } catch (Exception e) { MsgBox.Show(this.Text, e.Message, IconType.Error); Utility.WriteToTraceLog(e.Message); } }
private bool InsertNhanXetKhamLamSang(string nhanXet, int loai) { if (nhanXet.Trim() == string.Empty) { return(true); } Result result = NhanXetKhamLamSangBus.CheckNhanXetExist(null, loai, nhanXet); if (result.Error.Code == ErrorCode.EXIST || result.Error.Code == ErrorCode.NOT_EXIST) { if (result.Error.Code == ErrorCode.NOT_EXIST) { NhanXetKhamLamSang nhanXetKhamLamSang = new NhanXetKhamLamSang(); nhanXetKhamLamSang.Status = (byte)Status.Actived; nhanXetKhamLamSang.CreatedDate = DateTime.Now; nhanXetKhamLamSang.CreatedBy = Guid.Parse(Global.UserGUID); nhanXetKhamLamSang.NhanXet = nhanXet; nhanXetKhamLamSang.Loai = loai; result = NhanXetKhamLamSangBus.InsertNhanXetKhamLamSang(nhanXetKhamLamSang); if (!result.IsOK) { MsgBox.Show(this.Text, result.GetErrorAsString("NhanXetKhamLamSangBus.InsertNhanXetKhamLamSang"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("NhanXetKhamLamSangBus.InsertNhanXetKhamLamSang")); return(false); } } } else { MsgBox.Show(this.Text, result.GetErrorAsString("NhanXetKhamLamSangBus.CheckNhanXetExist"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("NhanXetKhamLamSangBus.CheckNhanXetExist")); return(false); } return(true); }