protected void Button1_Click(object sender, EventArgs e) { ApplicationFormEntity entity = new ApplicationFormEntity(); entity.APPTEACHERID = int.Parse(TextBox1.Text); entity.APPCOURSEID = int.Parse(DropDownList1.SelectedValue.ToString()); CourseBusiness.AddRequestBusiness(entity); }
public static int AddRequestBusiness(ApplicationFormEntity entity) { if (entity.APPTEACHERID != null && entity.APPCOURSEID != null) { return(CourseDAL.AddRequest(entity)); } return(-1); }
public static int AddRequest(ApplicationFormEntity entity) { SqlCommand command = new SqlCommand("insert into APPLICATIONFORM(STDID,COURSEID) values (@P1,@P2)", Connection.con); command.Parameters.AddWithValue("@P1", entity.APPTEACHERID); command.Parameters.AddWithValue("@P2", entity.APPCOURSEID); if (command.Connection.State != ConnectionState.Open) { command.Connection.Open(); } return(command.ExecuteNonQuery()); }