예제 #1
0
        private void AddClient_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                using (ClientForm cForm = new ClientForm(1, ClientFIOTB.Text))
                {
                    client      = new Classes.ClientClass();
                    cForm.Owner = this;
                    cForm.ShowDialog();
                }

                if (client.FIO != null)
                {
                    ClientFIOTB.Text         = client.FIO;
                    ClientBirthDate.Value    = client.birthDate;
                    cbClientSex.SelectedItem = client.sex;
                    ClientAddressTB.Text     = client.Address;
                }
                Cursor.Current = Cursors.Default;
            }
            catch (Exception ex)
            {
                Cursor.Current = Cursors.Default;
                logger.Error(ex, $"\r\n#---------#\r\n{ex.StackTrace}\r\n##---------##\r\n{ex.Message}\r\n###---------###\r\n{ex.Source}");
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        public static ClientClass LoadClientData(int client_id)
        {
            try
            {
                ClientClass client = new ClientClass();


                string query = $"select id," +
                               " FIO," +
                               " birthDate," +
                               " if(sex = 1, 'Мужской', if(sex = 2, 'Женский', 'Не указан')) sex," +
                               " Address" +
                               $" from client where deleted = 0 and id = {client_id}";

                using (MySqlConnection sqlConnection = ConnectionClass.GetStringConnection())
                {
                    sqlConnection.Open();

                    using (MySqlCommand sqlCommand = new MySqlCommand(query, sqlConnection))
                    {
                        using (MySqlDataReader sqlReader = sqlCommand.ExecuteReader())
                        {
                            if (sqlReader.HasRows)
                            {
                                while (sqlReader.Read())
                                {
                                    client.id        = sqlReader.GetInt32(0);
                                    client.FIO       = sqlReader.GetString(1);
                                    client.birthDate = sqlReader.GetDateTime(2);
                                    client.sex       = sqlReader.GetString(3);
                                    client.Address   = sqlReader.GetString(4);
                                }
                            }
                        }
                    }
                }

                return(client);
            }
            catch (Exception ex)
            {
                logger.Error(ex, $"\r\n#---------#\r\n{ex.StackTrace}\r\n##---------##\r\n{ex.Message}\r\n###---------###\r\n{ex.Source}");
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
        }
예제 #3
0
        private void EditData(int event_id)
        {
            editData = Classes.EventClass.EditEvent(event_id);
            client   = Classes.ClientClass.LoadClientData(int.Parse(editData.Rows[0][5].ToString()));

            if (client.FIO != null)
            {
                ClientFIOTB.Text         = client.FIO;
                ClientBirthDate.Value    = client.birthDate;
                cbClientSex.SelectedItem = client.sex;
                ClientAddressTB.Text     = client.Address;
            }

            cbArea.Text         = editData.Rows[0][1].ToString();
            cbMO.Text           = editData.Rows[0][2].ToString();
            EventDate.Value     = DateTime.Parse(editData.Rows[0][3].ToString());
            cbShortNameOrg.Text = editData.Rows[0][4].ToString();
            switch (editData.Rows[0][6].ToString())
            {
            case "2":
                ORGHimselfRelaxInfoRB.Checked = true;
                break;

            case "3":
                ORGMCRelaxInfoRB.Checked = true;
                break;

            case "5":
                NONORGHimselfRelaxInfoRB.Checked = true;
                break;

            case "6":
                NONORGWithParentRelaxInfoRB.Checked = true;
                break;
            }
            TreatmentDate.Value = DateTime.Parse(editData.Rows[0][7].ToString());

            switch (editData.Rows[0][8].ToString())
            {
            case "1":
                HelpRB_1.Checked = true;

                MKB10TB.Text = editData.Rows[0][10].ToString();
                DiagTB.Text  = editData.Rows[0][9].ToString();

                /*
                 * DiagTB.Enabled = true;
                 * MKB10TB.Enabled = true;
                 * SpecialityTB.Enabled = false;
                 * DepartmentTB.Enabled = false;
                 */
                break;

            case "2":
                HelpRB_2.Checked = true;

                MKB10TB.Text      = editData.Rows[0][10].ToString();
                DiagTB.Text       = editData.Rows[0][9].ToString();
                SpecialityTB.Text = editData.Rows[0][11].ToString();

                /*
                 * DiagTB.Enabled = true;
                 * MKB10TB.Enabled = true;
                 * SpecialityTB.Enabled = true;
                 * DepartmentTB.Enabled = false;
                 */
                break;

            case "3":
                HelpRB_3.Checked = true;

                MKB10TB.Text      = editData.Rows[0][10].ToString();
                DiagTB.Text       = editData.Rows[0][9].ToString();
                DepartmentTB.Text = editData.Rows[0][12].ToString();

                /*
                 * DiagTB.Enabled = true;
                 * MKB10TB.Enabled = true;
                 * SpecialityTB.Enabled = false;
                 * DepartmentTB.Enabled = true;
                 */
                break;
            }

            cbHealthStatus.Text = editData.Rows[0][15].ToString();

            if (editData.Rows[0][13].ToString() != "")
            {
                TransfertedCheck.Checked = true;
                TransferTB.Text          = editData.Rows[0][13].ToString();
                TransferDate.Value       = DateTime.Parse(editData.Rows[0][14].ToString());
            }
        }