protected void BtnVincular_Click(object sender, EventArgs e) { MODProjetoPesquisa_Colaborador projetoColaborador = new MODProjetoPesquisa_Colaborador(); MODDocente docente = new MODDocente(); foreach (RepeaterItem dli in RptColaborador.Items) { if (dli.ItemType == ListItemType.Item || dli.ItemType == ListItemType.AlternatingItem) { DropDownList ddl = (DropDownList)dli.FindControl("DdlAddColaborador"); if (ddl.Text == "Sim") { Label lbl = (Label)dli.FindControl("TxtNomeColaborador"); string titulo = lbl.Text; docente.Nome = titulo; docente = BLLDocente.PesquisarDocente(docente, "nome"); projetoColaborador.FkDocente = docente.IdDocente; projetoColaborador.FkProjeto = idProjeto; BLLDocente.InserirColaboradorProjeto(projetoColaborador); LblResposta.Text = "Colaborador(es) vinculados com sucesso!"; } } } }
public static void InserirColaboradorProjeto(MODProjetoPesquisa_Colaborador projetoColaborador) { Conexao.Abrir(); MySqlCommand comando = new MySqlCommand(); comando.Connection = Conexao.conexao; comando.CommandText = "INSERT INTO TBLPROJETO_COLABORADOR (fk_docente, fk_projeto) " + "VALUES (@fk_docente, @fk_projeto)"; comando.Parameters.AddWithValue("@fk_docente", projetoColaborador.FkDocente); comando.Parameters.AddWithValue("@fk_projeto", projetoColaborador.FkProjeto); comando.ExecuteNonQuery(); Conexao.Fechar(); }
public static void InserirColaboradorProjeto(MODProjetoPesquisa_Colaborador projetoColaborador) { DALDocente.InserirColaboradorProjeto(projetoColaborador); }