Пример #1
0
 public CureClass(CureClass cureClass)
 {
     Name = cureClass.Name;
     DefaultPerDayCount     = cureClass.DefaultPerDayCount;
     DefaultReceivingMethod = cureClass.DefaultReceivingMethod;
     DefaultDuration        = cureClass.DefaultDuration;
 }
Пример #2
0
        /// <summary>
        /// Сохранение изменений
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonOk_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxCureName.Text))
            {
                MessageBox.Show("Поля, отмеченные звёздочкой, обязательны для заполнения", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            try
            {
                var cureInfo = new CureClass();
                cureInfo.Name = textBoxCureName.Text;
                cureInfo.DefaultPerDayCount     = comboBoxPerDayCnt.Text;
                cureInfo.DefaultReceivingMethod = comboBoxReceivingMethod.Text;
                cureInfo.DefaultDuration        = comboBoxDuration.Text;

                if (string.IsNullOrEmpty(_cureSaveName))
                {
                    if (_dbEngine.GetCureByName(cureInfo.Name) != null)
                    {
                        MessageBox.Show("Лекарство с таким именем уже существует. Используйте другое имя.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    if (textBoxCureName.Text.Contains("&") || comboBoxPerDayCnt.Text.Contains("&") || comboBoxReceivingMethod.Text.Contains("&") || comboBoxDuration.Text.Contains("&"))
                    {
                        MessageBox.Show("Использование символа '&' в полях запрещено т.к. может привести к внутренней ошибке программы. Используйте другой символ.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    _dbEngine.AddCure(cureInfo);
                }
                else
                {
                    if (_cureSaveName != cureInfo.Name && _dbEngine.GetCureByName(cureInfo.Name) != null)
                    {
                        MessageBox.Show("Лекарство с таким именем уже существует. Используйте другое имя.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    if (textBoxCureName.Text.Contains("&") || comboBoxPerDayCnt.Text.Contains("&") || comboBoxReceivingMethod.Text.Contains("&") || comboBoxDuration.Text.Contains("&"))
                    {
                        MessageBox.Show("Использование символа '&' в полях запрещено т.к. может привести к внутренней ошибке программы. Используйте другой символ.", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    _dbEngine.UpdateCure(_cureSaveName, cureInfo);
                }

                _isFormClosingByButton = true;
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #3
0
        public CureViewForm(DbEngine dbEngine, CureClass cureInfo)
        {
            InitializeComponent();

            _dbEngine = dbEngine;

            if (cureInfo == null)
            {
                Text          = "Добавление нового лекарства";
                _cureSaveName = null;
            }
            else
            {
                Text                         = "Редактирование лекарства";
                _cureSaveName                = cureInfo.Name;
                textBoxCureName.Text         = cureInfo.Name;
                comboBoxPerDayCnt.Text       = cureInfo.DefaultPerDayCount;
                comboBoxReceivingMethod.Text = cureInfo.DefaultReceivingMethod;
                comboBoxDuration.Text        = cureInfo.DefaultDuration;
            }
        }
Пример #4
0
        /// <summary>
        /// Показать список лекарств
        /// </summary>
        private void ShowCures()
        {
            int listCnt    = 0;
            int therapyCnt = 0;

            while (listCnt < CureList.Rows.Count && therapyCnt < _dbEngine.CureList.Count)
            {
                CureClass cureInfo = _dbEngine.CureList[therapyCnt];

                CureList.Rows[listCnt].Cells[0].Value = false;
                CureList.Rows[listCnt].Cells[1].Value = cureInfo.Name;
                CureList.Rows[listCnt].Cells[2].Value = cureInfo.DefaultPerDayCount;
                CureList.Rows[listCnt].Cells[3].Value = cureInfo.DefaultReceivingMethod;
                CureList.Rows[listCnt].Cells[4].Value = cureInfo.DefaultDuration;
                listCnt++;
                therapyCnt++;
            }

            if (therapyCnt == _dbEngine.CureList.Count)
            {
                while (listCnt < CureList.Rows.Count)
                {
                    CureList.Rows.RemoveAt(listCnt);
                }
            }
            else
            {
                while (therapyCnt < _dbEngine.CureList.Count)
                {
                    CureClass cureInfo = _dbEngine.CureList[therapyCnt];

                    CureList.Rows.Add(new object[] { false, cureInfo.Name, cureInfo.DefaultPerDayCount, cureInfo.DefaultReceivingMethod, cureInfo.DefaultDuration });
                    therapyCnt++;
                }
            }
        }
Пример #5
0
 public static int Compare(CureClass cureInfo1, CureClass cureInfo2)
 {
     return(string.Compare(cureInfo1.Name, cureInfo2.Name));
 }