//Refresh datagridview in monitor tab private void refreshDataViewHeathNote() { try { // Get heath note's datatable DataTable heathNoteTable = HeathMonitoringNote.GetListHN(); // Add Vietnamese column's name heathNoteTable.Columns.Add("Mã phiếu theo dõi", typeof(string), "[HNID]"); heathNoteTable.Columns.Add("Mã bệnh nhân", typeof(string), "[PATIENTID]"); heathNoteTable.Columns.Add("Mã nhân viên", typeof(string), "[STAFFID]"); heathNoteTable.Columns.Add("Ngày lập", typeof(DateTime), "[DATE]"); heathNoteTable.Columns.Add("Cân nặng", typeof(string), "[WEIGHT]"); heathNoteTable.Columns.Add("Huyết áp", typeof(string), "[BLOODPRESSURE]"); heathNoteTable.Columns.Add("Tình trạng bệnh nhân", typeof(string), "[PATIENTSTATE]"); // Set data source to dataview for searching dataViewHeathNote.DataSource = heathNoteTable.DefaultView; // Hide English columns'name for (int i = 0; i < 7; i++) { dataViewHeathNote.Columns[i].Visible = false; } } catch { MessageBox.Show("Lỗi dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonOk_Click(object sender, System.EventArgs e) { if (!superValidator1.Validate()) { return; } if (Patient.IsPatientExist(int.Parse(textBoxPatientID.Text))) { try { if (UserAction == "edit") { HeathMonitoringNote newHN = new HeathMonitoringNote(); newHN.HNID = int.Parse(textBoxHNID.Text); newHN.PatientID = int.Parse(textBoxPatientID.Text); newHN.StaffID = int.Parse(textBoxStaffID.Text); newHN.PatientState = textBoxPatientState.Text; newHN.Weight = textBoxWeight.Text; newHN.BloodPressure = textBoxBloodPressure.Text; newHN.Date = dateCreate.Value; DialogResult dialogResult = MessageBox.Show("Xác nhận cập nhập thông tin phiếu theo dõi sức khỏe", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { if (HeathMonitoringNote.UpdateHN(newHN) > 0) { MessageBox.Show("Cập nhập thông tin phiếu theo dõi sức khỏe thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { HeathMonitoringNote newHN = new HeathMonitoringNote(); newHN.HNID = 0; newHN.PatientID = int.Parse(textBoxPatientID.Text); newHN.StaffID = int.Parse(textBoxStaffID.Text); newHN.PatientState = textBoxPatientState.Text; newHN.Weight = textBoxWeight.Text; newHN.BloodPressure = textBoxBloodPressure.Text; newHN.Date = dateCreate.Value; if (HeathMonitoringNote.InsertHN(newHN) > 0) { MessageBox.Show("Thêm phiếu theo dõi sức khỏe thành công thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch { MessageBox.Show("Lỗi dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Close(); } else { MessageBox.Show("Thiếu thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void buttonMonitorEdit_Click(object sender, EventArgs e) { if (dataViewHeathNote.SelectedRows.Count > 0) { int heathNoteID = Convert.ToInt32(dataViewHeathNote.SelectedRows[0].Cells[0].Value); FormHNDetail formHNDetail = new FormHNDetail(HeathMonitoringNote.GetHN(heathNoteID), "edit"); formHNDetail.ShowDialog(); refreshDataViewHeathNote(); } }
//This constructor for update in Heath Note Management public FormHNDetail(HeathMonitoringNote hnDetail, String userAction) { InitializeComponent(); this.UserAction = userAction; textBoxHNID.Text = hnDetail.HNID.ToString(); textBoxPatientID.Text = hnDetail.PatientID.ToString(); textBoxStaffID.Text = hnDetail.StaffID.ToString(); dateCreate.Value = hnDetail.Date; textBoxPatientState.Text = hnDetail.PatientState; textBoxBloodPressure.Text = hnDetail.BloodPressure; textBoxWeight.Text = hnDetail.Weight; }
private void buttonMonitorDelete_Click(object sender, EventArgs e) { if (dataViewHeathNote.SelectedRows.Count > 0) { int heathNoteID = Convert.ToInt32(dataViewHeathNote.SelectedRows[0].Cells[0].Value); DialogResult dialogResult = MessageBox.Show("Xác nhận xóa phiếu theo dõi", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { try { if (HeathMonitoringNote.DeleteHN(heathNoteID) > 0) { MessageBox.Show("Xóa phiếu theo dõi thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { MessageBox.Show("Không xóa phiếu theo dõi này", "Lỗi dữ liệu", MessageBoxButtons.OK, MessageBoxIcon.Error); } } refreshDataViewHeathNote(); } }