コード例 #1
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            try
            {
                var number = Convert.ToInt32(txtNumber.Text);
                PictureBoxImageLoader p = new PictureBoxImageLoader();

                var party = new Party(txtName.Text, number, p.ConvertPictureBoxImageToByteArray(pictureBox));

                var partyDAO = new PartyDAO();
                partyDAO.Add(party);
            }
            catch (Exception ex)
            {
                lblError.Visible = true;
                lblError.Text    = ex.Message;
            }
        }
コード例 #2
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            try
            {
                Party party = new Party();
                party = GetParty();

                var sex = Convert.ToChar(cmbSex.SelectedItem);
                PictureBoxImageLoader p = new PictureBoxImageLoader();

                var candidate = new Candidate(txtName.Text, txtStudentNumber.Text
                                              , txtStudentClass.Text, sex, p.ConvertPictureBoxImageToByteArray(pictureBox), party.Id);

                var candidateDAO = new CandidateDAO();
                candidateDAO.Add(candidate);

                MessageBox.Show("Candidate Registered");
            }
            catch (Exception ex)
            {
                lblError.Visible = true;
                lblError.Text    = ex.Message;
            }
        }