public static int Insert(som_solicitacaomotorista som) { int retorno = 0; try { //Correto IDbConnection objConexao; //Abrir a conexão IDbCommand objCommand; // Criar e executar os comandos string sql = "insert into som_solicitacao_motorista "; sql += "(sol_id, mot_id, som_proposta)"; sql += "values "; sql += "(?sol_id, ?mot_id, ?som_proposta)"; objConexao = Mapped.Connection(); objCommand = Mapped.Command(sql, objConexao); objCommand.Parameters.Add(Mapped.Parameter("?sol_id", som.Sol_id.Sol_id)); objCommand.Parameters.Add(Mapped.Parameter("?mot_id", som.Mot_id.Mot_id)); objCommand.Parameters.Add(Mapped.Parameter("?som_proposta", som.Som_proposta)); objCommand.ExecuteNonQuery(); objConexao.Close(); objConexao.Dispose(); objCommand.Dispose(); } catch (Exception) { //erro retorno = -2; } return(retorno); }
protected void btnCadastrar_Click(object sender, EventArgs e) { hdf.Value = Session["value"].ToString(); DataSet codigo = new DataSet(); codigo = mot_motoristaDB.SelectID(Convert.ToInt32(hdf.Value)); // Label1.Text = par; int c = Convert.ToInt32(codigo.Tables[0].Rows[0][0]); sol_solicitacao sol = new sol_solicitacao(); sol.Sol_id = Convert.ToInt32(Label1.Text); mot_motorista mot = new mot_motorista(); mot.Mot_id = c; som_solicitacaomotorista som = new som_solicitacaomotorista(); som.Sol_id = sol; som.Mot_id = mot; som.Som_proposta = Convert.ToDouble(txtProposta.Text); switch (som_solicitacaomotoristaDB.Insert(som)) { case 0: ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalS();", true); txtProposta.Text = null; break; case -2: ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModalE();", true); break; } }