Example #1
0
 public frmDisciplinasConsultar()
 {
     InitializeComponent();
     API = new API.Client.DisciplinaAPI();
     dgvDisciplinas.AutoGenerateColumns = false;
     dgvDisciplinas.DataSource          = API.ListarTudo();
 }
Example #2
0
        public void Carregarlbx()
        {
            if (lbxDisciplinasDisponiveis.DataSource == null && lbxDisciplinasDoProfessor.DataSource == null)
            {
                string a = string.Empty;

                API.Client.DisciplinaAPI          db    = new API.Client.DisciplinaAPI();
                List <Model.Model.DiciplinaModel> lista = db.ListarDisciplina(a);
                lbxDisciplinasDisponiveis.DisplayMember = nameof(Model.Model.DiciplinaModel.NmDisciplina);
                lbxDisciplinasDisponiveis.DataSource    = lista;
            }
        }
Example #3
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                DiciplinaModel model = new DiciplinaModel();

                if (DiciplinaModel.IdDisciplina == 0)
                {
                    model.NmDisciplina = txtDisciplina.Text;
                    model.DsSigla      = txtSigla.Text;
                    model.BtAtivo      = Convert.ToUInt64(chkAtivo.Checked);
                    model.DtInclusao   = DateTime.Now;

                    API.Client.DisciplinaAPI api = new API.Client.DisciplinaAPI();
                    DiciplinaModel = api.Inserir(model);
                    lblId.Text     = DiciplinaModel.IdDisciplina.ToString();

                    MessageBox.Show("Diciplina inserida com sucesso!", "NSF", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    model.IdDisciplina      = DiciplinaModel.IdDisciplina;
                    model.NmDisciplina      = txtDisciplina.Text;
                    model.DsSigla           = txtSigla.Text;
                    model.BtAtivo           = Convert.ToUInt64(chkAtivo.Checked);
                    model.DtUltimaAlteracao = DateTime.Now;

                    API.Client.DisciplinaAPI API = new API.Client.DisciplinaAPI();
                    API.Alterar(model);

                    MessageBox.Show("Diciplina alterada com sucesso!", "NSF", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (Exception)
            {
                MessageBox.Show("Ocorreu um erro. Entre em contato com o administrador.", "NSF", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }