Beispiel #1
1
 public frmTermoNovo(Usuario user, String terId)
 {
     InitializeComponent();
     ter = new Termo();
     util = new Utils();
     this.user = user;
     lblUserOn.Text = user.Login;
     alu = new Aluno();
     if (terId != "") //atualizar
     {
         lblUltimaAlter.Visible = true;
         lblUltimaAlter1.Visible = true;
         ter.TerId = terId;
         ter = ter.getTermoById();
         userTermo = new Usuario();
         userTermo.Id = Convert.ToInt32(ter.TerQuemCadastrou);
         userTermo = userTermo.getUserById();
         lblUltimaAlter.Text = userTermo.Login;
         btnSelecionar.Visible = false;
         alu.TerId = terId;
         ttbAluno.Text = alu.getAlunoByTermo();
         pictureBox1.ImageLocation = fotoPath + "" + ter.TerId + ".jpg";
     }
     else
     {
         lblUltimaAlter.Visible = false;
         lblUltimaAlter1.Visible = false;
     }
 }
Beispiel #2
0
 public frmTermoControlar(Usuario user)
 {
     InitializeComponent();
     this.user = user;
     ter = new Termo();
     atualizaDtgv();
 }
Beispiel #3
0
 public bool atualiza(Termo ter)
 {
     sql = "UPDATE termo SET ter_quemcadastrou='@1' "+
         "WHERE ter_id = @2";
     sql = sql.Replace("@1", ter.TerQuemCadastrou);
     sql = sql.Replace("@2", ter.TerId);
     bco.conecta();
     result = bco.executeNonQuery(sql);
     bco.desconecta();
     return result;
 }
Beispiel #4
0
 public Termo getTermoById(String id)
 {
     Termo ter = null;
     sql = "SELECT * FROM termo WHERE ter_id = @1";
     sql = sql.Replace("@1", id);
     bco.conecta();
     bco.executeQuery(sql, out dt);
     bco.desconecta();
     if (dt.Rows.Count > 0)
     {
         ter = new Termo();
         ter.TerId = id;
         ter.TerQuemCadastrou = dt.Rows[0]["ter_quemcadastrou"].ToString();
     }
     return ter;
 }
Beispiel #5
0
 public bool excluir(Termo ter)
 {
     sql = "UPDATE aluno SET ter_id = null WHERE ter_id = @1";
     sql = sql.Replace("@1", ter.TerId);
     bco.conecta();
     result = bco.executeNonQuery(sql);
     bco.desconecta();
     if (result)
     {
         sql = "DELETE FROM termo WHERE ter_id = @1";
         sql = sql.Replace("@1", ter.TerId);
         bco.conecta();
         result = bco.executeNonQuery(sql);
         bco.desconecta();
     }
     return result;
 }
Beispiel #6
0
 private void btnGravar_Click(object sender, EventArgs e)
 {
     if (ttbAluno.Text == "")
         ttbAluno.BackColor = Color.Red;
     else
         if (pictureBox1.Image == null)
             MessageBox.Show("Selecione uma imagem!", "Sem imagem!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         else
         {
             if (ter.TerId != "") //atualiza
             {
                 ter = ter.getTermoById();
                 ter.TerQuemCadastrou =""+user.Id;
                 if (ter.atualiza())
                 {
                     util.gravarFoto(fotoPath + "" + ter.TerId + ".jpg", pictureBox1.Image);
                     MessageBox.Show("Termo alterado com sucesso!", "Sucesso!", MessageBoxButtons.OK,
                         MessageBoxIcon.Information);
                     this.Close();
                 }
                 else
                     MessageBox.Show("Ocorreu um erro ao atualizar o termo!", "Erro!", MessageBoxButtons.OK,
                         MessageBoxIcon.Exclamation);
             }
             else
             {
                 ter.AluId = alu.Id + "";
                 ter.TerQuemCadastrou = user.Id + "";
                 if (ter.novo())
                 {
                     ter.TerId = ter.getUltimoId();
                     util.gravarFoto(fotoPath + "" + ter.TerId + ".jpg", pictureBox1.Image);
                     MessageBox.Show("Termo cadastrado com sucesso!", "Sucesso!", MessageBoxButtons.OK,
                         MessageBoxIcon.Information);
                     this.Close();
                 }
                 else
                     MessageBox.Show("Ocorreu um erro ao cadastrar o termo!", "Erro!", MessageBoxButtons.OK,
                         MessageBoxIcon.Exclamation);
             }
         }
 }
Beispiel #7
0
 public bool novo(Termo ter)
 {
     sql = "INSERT INTO termo(ter_quemcadastrou) "
     +"VALUES (@1)";
     sql = sql.Replace("@1", ter.TerQuemCadastrou);
     bco.conecta();
     result = bco.executeNonQuery(sql);
     bco.desconecta();
     if (result)
     {
         Aluno alu = new Aluno();
         alu.Id = Convert.ToInt32(ter.AluId);
         alu.TerId = ter.getUltimoId();
         result = alu.addTermo();
     }
     return result;
 }