Esempio n. 1
0
        /// <summary>
        /// Проверка на открытые окна
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            menuItemFilePatientList_Click(null, null);

            bool isLockedPatientsExists = false;

            _dbEngine.GeneratePatientList();
            foreach (PatientClass pc in _dbEngine.PatientList)
            {
                if (pc.OpenedPatientViewForm != null && !pc.OpenedPatientViewForm.IsDisposed)
                {
                    isLockedPatientsExists = true;
                    break;
                }
            }

            if (isLockedPatientsExists &&
                DialogResult.No == MessageBox.Show("Вы уверены, что хотите закрыть программу? Все несохранённые данные будут утеряны.", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                e.Cancel = true;
                return;
            }

            e.Cancel = false;
        }
Esempio n. 2
0
        /// <summary>
        /// Отобразить список пациентов в таблице
        /// </summary>
        public void ShowPatients()
        {
            try
            {
                int listCnt    = 0;
                int patientCnt = 0;
                _dbEngine.GeneratePatientList();
                while (listCnt < PatientList.Rows.Count && patientCnt < _dbEngine.PatientList.Length)
                {
                    if (IsThisPatientSatisfyFilterOptions(_dbEngine.PatientList[patientCnt]))
                    {
                        PatientList.Rows[listCnt].Cells[0].Value = _dbEngine.PatientList[patientCnt].Id.ToString();
                        PatientList.Rows[listCnt].Cells[1].Value = (listCnt + 1).ToString();
                        PatientList.Rows[listCnt].Cells[2].Value = _dbEngine.PatientList[patientCnt].GetFullName();
                        PatientList.Rows[listCnt].Cells[3].Value = ConvertEngine.GetRightDateString(_dbEngine.PatientList[patientCnt].DeliveryDate, true);

                        PatientList.Rows[listCnt].Cells[4].Value = _dbEngine.PatientList[patientCnt].ReleaseDate.HasValue
                            ? ConvertEngine.GetRightDateString(_dbEngine.PatientList[patientCnt].ReleaseDate.Value)
                            : string.Empty;

                        int opeartionCount = _dbEngine.PatientList[patientCnt].Operations.Count;

                        PatientList.Rows[listCnt].Cells[5].Value = opeartionCount > 0
                            ? ConvertEngine.GetRightDateString(_dbEngine.PatientList[patientCnt].Operations[opeartionCount - 1].DataOfOperation)
                            : string.Empty;

                        PatientList.Rows[listCnt].Cells[6].Value  = _dbEngine.PatientList[patientCnt].Nosology;
                        PatientList.Rows[listCnt].Cells[7].Value  = _dbEngine.PatientList[patientCnt].Diagnose.Replace("\r\n", " ");
                        PatientList.Rows[listCnt].Cells[8].Value  = opeartionCount.ToString();
                        PatientList.Rows[listCnt].Cells[9].Value  = _dbEngine.PatientList[patientCnt].GetDN();
                        PatientList.Rows[listCnt].Cells[10].Value = _dbEngine.PatientList[patientCnt].GetKD();
                        PatientList.Rows[listCnt].Cells[11].Value = _dbEngine.PatientList[patientCnt].DoctorInChargeOfTheCase;
                        listCnt++;
                    }

                    patientCnt++;
                }

                if (patientCnt == _dbEngine.PatientList.Length)
                {
                    while (listCnt < PatientList.Rows.Count)
                    {
                        PatientList.Rows.RemoveAt(listCnt);
                    }
                }
                else
                {
                    while (patientCnt < _dbEngine.PatientList.Length)
                    {
                        if (IsThisPatientSatisfyFilterOptions(_dbEngine.PatientList[patientCnt]))
                        {
                            string releaseDateStr = string.Empty;
                            if (_dbEngine.PatientList[patientCnt].ReleaseDate.HasValue)
                            {
                                releaseDateStr = ConvertEngine.GetRightDateString(_dbEngine.PatientList[patientCnt].ReleaseDate.Value);
                            }

                            int    opeartionCount   = _dbEngine.PatientList[patientCnt].Operations.Count;
                            string operationDateStr = string.Empty;
                            if (opeartionCount > 0)
                            {
                                operationDateStr = ConvertEngine.GetRightDateString(_dbEngine.PatientList[patientCnt].Operations[opeartionCount - 1].DataOfOperation);
                            }

                            var param = new[]
                            {
                                _dbEngine.PatientList[patientCnt].Id.ToString(),
                                (PatientList.Rows.Count + 1).ToString(),
                                _dbEngine.PatientList[patientCnt].GetFullName(),
                                ConvertEngine.GetRightDateString(_dbEngine.PatientList[patientCnt].DeliveryDate, true),
                                releaseDateStr,
                                operationDateStr,
                                _dbEngine.PatientList[patientCnt].Nosology,
                                _dbEngine.PatientList[patientCnt].Diagnose.Replace("\r\n", " "),
                                opeartionCount.ToString(),
                                _dbEngine.PatientList[patientCnt].GetDN(),
                                _dbEngine.PatientList[patientCnt].GetKD(),
                                _dbEngine.PatientList[patientCnt].DoctorInChargeOfTheCase
                            };
                            PatientList.Rows.Add(param);
                        }

                        patientCnt++;
                    }
                }

                Color lightColor       = Color.FromArgb(255, 230, 230, 230);
                Color releaseDateColor = Color.FromArgb(255, 180, 255, 50);
                Color noColor          = Color.FromArgb(255, 255, 255, 255);
                for (int i = 0; i < PatientList.Rows.Count; i++)
                {
                    PatientClass patientInfo = _dbEngine.GetPatientById(Convert.ToInt32(PatientList.Rows[i].Cells[0].Value));
                    if (!patientInfo.ReleaseDate.HasValue ||
                        ConvertEngine.CompareDateTimes(patientInfo.ReleaseDate.Value, DateTime.Now, false) > 0)
                    {
                        PatientList.Rows[i].DefaultCellStyle.BackColor = lightColor;
                    }
                    else if (ConvertEngine.CompareDateTimes(patientInfo.ReleaseDate.Value, DateTime.Now, false) == 0)
                    {
                        PatientList.Rows[i].DefaultCellStyle.BackColor = releaseDateColor;
                    }
                    else
                    {
                        PatientList.Rows[i].DefaultCellStyle.BackColor = noColor;
                    }
                }

                int   patientsWithLineOfCommunication = 0;
                Color lineOfCommunicationColor        = Color.FromArgb(255, 255, 180, 180);
                for (int i = 0; i < PatientList.Rows.Count; i++)
                {
                    if (PatientList.Rows[i].DefaultCellStyle.BackColor == lightColor)
                    {
                        PatientClass patientInfo = _dbEngine.GetPatientById(Convert.ToInt32(PatientList.Rows[i].Cells[0].Value));

                        DateTime tempDate = DateTime.Now.AddDays(-14);

                        while (ConvertEngine.CompareDateTimes(tempDate, patientInfo.DeliveryDate, false) > 0)
                        {
                            tempDate = tempDate.AddDays(-14);
                        }

                        if (ConvertEngine.CompareDateTimes(tempDate, patientInfo.DeliveryDate, false) == 0)
                        {
                            PatientList.Rows[i].DefaultCellStyle.BackColor = lineOfCommunicationColor;
                            patientsWithLineOfCommunication++;
                        }
                    }
                }

                if (patientsWithLineOfCommunication > 0)
                {
                    pictureBoxInfo.Visible = true;
                    _pictureBoxInfoMessage = patientsWithLineOfCommunication == 1
                        ? "Обратите внимание! Есть один пациент, которому необходимо написать ЭТАПНЫЙ ЭПИКРИЗ"
                        : "Обратите внимание! Есть несколько пациентов, которым необходимо написать ЭТАПНЫЙ ЭПИКРИЗ";
                }
                else
                {
                    pictureBoxInfo.Visible = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }