Exemple #1
0
        private void PopulateFieldsKnowLeddge(RegistrationFormEntity entityReg)
        {
            var knowEntity = (from v in new ViewKnowledgeBUS().GetAll()
                              where v.IdRegistrationForm == entityReg.Id
                              select v).FirstOrDefault();

            this.txtPesquisaOutro.Text = knowEntity.OtherObservation;
            foreach (Control x in gbKnowLedge.Controls)
            {
                if (x is RadioButton)
                {
                    RadioButton rb = (RadioButton)x;
                    if (rb.Text == knowEntity.Type)
                    {
                        rb.Checked = true;
                    }
                }
            }
        }
Exemple #2
0
        private void SaveStudents()
        {
            try
            {
                string validPeao     = ValidatePartialPeao();
                string validPrenda   = ValidatePartialPrenda();
                string validRestForm = ValidateRestForm();

                if (string.IsNullOrEmpty(validPeao) && string.IsNullOrEmpty(validPrenda) && string.IsNullOrEmpty(validRestForm))
                {
                    var entityPeao   = GetDataPeao();
                    var entityPrenda = GetDataPrenda();

                    if (entityPeao.Id <= 0 && entityPrenda.Id <= 0)
                    {
                        //add new students
                        var idStudentPeao   = new StudentBUS().Add(entityPeao);
                        var idStudentPrenda = new StudentBUS().Add(entityPrenda);

                        //entity registration form to data Peão
                        var entityRegFormPeao = new RegistrationFormEntity()
                        {
                            CreateDate  = DateTime.Now,
                            IdClass     = Convert.ToInt32(this.txtCodeClass.Text),
                            IdStudent   = idStudentPeao,
                            Observation = this.txtObservation.Text.Trim(),
                            Payment     = this.chbPayment.Checked
                        };

                        //entity registration form to data Prenda
                        var entityRegFormPrenda = new RegistrationFormEntity()
                        {
                            CreateDate  = DateTime.Now,
                            IdClass     = Convert.ToInt32(this.txtCodeClass.Text),
                            IdStudent   = idStudentPrenda,
                            Observation = this.txtObservation.Text.Trim(),
                            Payment     = this.chbPayment.Checked
                        };

                        //registration
                        var idReg = new RegistrationFormBUS().Add(entityRegFormPeao, 0);
                        new RegistrationFormBUS().Add(entityRegFormPrenda, idReg);

                        new ViewKnowledgeBUS().Add(new ViewKnowledgeEntity()
                        {
                            IdRegistrationForm = idReg,
                            OtherObservation   = this.txtObservation.Text.Trim(),
                            Type = GetValueKnowledge()
                        });

                        if (this.chbPayment.Checked)
                        {
                            if (MessageBox.Show("Deseja imprimir o comprovante da inscrição realizada", "Nova Inscrição", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                //TODO create method for print
                            }
                        }

                        MessageBox.Show("Inscrição realizada com sucesso", "Nova Inscrição", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        //update students
                    }
                }
                else
                {
                    MessageBox.Show(validPeao + "\n" + validPrenda + "\n" + validRestForm, "Nova Inscrição", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Ocorreu um erro ao tentar efetuar a inscrição", "Nova Inscrição", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }