private void OnSaveInfo() { try { _nhomThuoc.MaNhomThuoc = txtMaNhomThuoc.Text; _nhomThuoc.TenNhomThuoc = txtTenNhomThuoc.Text; _nhomThuoc.Note = txtGhiChu.Text; _nhomThuoc.Status = (byte)Status.Actived; if (_isNew) { _nhomThuoc.CreatedDate = DateTime.Now; _nhomThuoc.CreatedBy = Guid.Parse(Global.UserGUID); } else { _nhomThuoc.UpdatedDate = DateTime.Now; _nhomThuoc.UpdatedBy = Guid.Parse(Global.UserGUID); } Result result = NhomThuocBus.InsertNhomThuoc(_nhomThuoc, _addedThuocs, _deletedThuocs); if (!result.IsOK) { MsgBox.Show(this.Text, result.GetErrorAsString("NhomThuocBus.InsertNhomThuoc"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("NhomThuocBus.InsertNhomThuoc")); this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } } catch (Exception e) { MsgBox.Show(this.Text, e.Message, IconType.Error); Utility.WriteToTraceLog(e.Message); } }
private void OnDisplayThuocList(string nhomThuocGUID) { Result result = NhomThuocBus.GetThuocListByNhom(nhomThuocGUID); if (result.IsOK) { MethodInvoker method = delegate { dgThuoc.DataSource = result.QueryResult; }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } else { MsgBox.Show(this.Text, result.GetErrorAsString("NhomThuocBus.GetThuocListByNhom"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("NhomThuocBus.GetThuocListByNhom")); } }
private void OnDisplayNhomThuocList() { Result result = NhomThuocBus.GetNhomThuocList(); if (result.IsOK) { MethodInvoker method = delegate { ClearData(); dgNhomThuoc.DataSource = result.QueryResult; }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("NhomThuocBus.GetNhomThuocList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("NhomThuocBus.GetNhomThuocList")); } }
private void DisplayThuocList() { Cursor.Current = Cursors.WaitCursor; Result result = NhomThuocBus.GetThuocThayTheList(_thuocGUID); if (result.IsOK) { dgThuoc.DataSource = result.QueryResult; } else { MsgBox.Show(this.Text, result.GetErrorAsString("NhomThuocBus.GetThuocThayTheList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("NhomThuocBus.GetThuocThayTheList")); } }
private void GenerateCode() { Cursor.Current = Cursors.WaitCursor; Result result = NhomThuocBus.GetNhomThuocCount(); if (result.IsOK) { int count = Convert.ToInt32(result.QueryResult); txtMaNhomThuoc.Text = Utility.GetCode("NH", count + 1, 5); } else { MsgBox.Show(this.Text, result.GetErrorAsString("NhomThuocBus.GetNhomThuocCount"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("NhomThuocBus.GetNhomThuocCount")); } }
private bool CheckInfo() { if (txtMaNhomThuoc.Text.Trim() == string.Empty) { MsgBox.Show(this.Text, "Vui lòng nhập mã nhóm thuốc.", IconType.Information); txtMaNhomThuoc.Focus(); return(false); } if (txtTenNhomThuoc.Text.Trim() == string.Empty) { MsgBox.Show(this.Text, "Vui lòng nhập tên nhóm thuốc.", IconType.Information); txtTenNhomThuoc.Focus(); return(false); } string nhomThuocGUID = _isNew ? string.Empty : _nhomThuoc.NhomThuocGUID.ToString(); Result result = NhomThuocBus.CheckNhomThuocExistCode(nhomThuocGUID, txtMaNhomThuoc.Text); if (result.Error.Code == ErrorCode.EXIST || result.Error.Code == ErrorCode.NOT_EXIST) { if (result.Error.Code == ErrorCode.EXIST) { MsgBox.Show(this.Text, "Mã nhóm thuốc này đã tồn tại rồi. Vui lòng nhập mã khác.", IconType.Information); txtMaNhomThuoc.Focus(); return(false); } } else { MsgBox.Show(this.Text, result.GetErrorAsString("NhomThuocBus.CheckNhomThuocExistCode"), IconType.Error); return(false); } if (dgThuoc.RowCount <= 0) { MsgBox.Show(this.Text, "Vui lòng nhập danh sách thuốc.", IconType.Information); tabNhomThuoc.SelectedTabIndex = 1; return(false); } return(true); }
private void OnDeleteNhomThuoc() { List <string> deletedNhomThuocList = new List <string>(); List <DataRow> deletedRows = new List <DataRow>(); DataTable dt = dgNhomThuoc.DataSource as DataTable; foreach (DataRow row in dt.Rows) { if (Boolean.Parse(row["Checked"].ToString())) { deletedNhomThuocList.Add(row["NhomThuocGUID"].ToString()); deletedRows.Add(row); } } if (deletedNhomThuocList.Count > 0) { if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những nhóm thuốc mà bạn đã đánh dấu ?") == DialogResult.Yes) { Result result = NhomThuocBus.DeleteNhomThuoc(deletedNhomThuocList); if (result.IsOK) { foreach (DataRow row in deletedRows) { dt.Rows.Remove(row); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("NhomThuocBus.DeleteNhomThuoc"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("NhomThuocBus.DeleteNhomThuoc")); } } } else { MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những nhóm thuốc cần xóa.", IconType.Information); } }