public void InsertSurveyResponse(Entities.SurveyReply c1, Entities.Survey c2) { using (WSqlCommand s1 = new WSqlCommand(dbconstring, "[dbo].[spInsertSurveyResponse]")) { s1.AddParameter("@surveyId", System.Data.SqlDbType.Int, c1.surveyId); s1.AddParameter("@repliedBy", System.Data.SqlDbType.NVarChar, c1.repliedBy); s1.AddParameter("@replyDate", System.Data.SqlDbType.Date, c2.surveyDate); s1.Execute(); } }
public void SurveyReply(Entities.SurveyReply c1) { using (WSqlCommand s1 = new WSqlCommand(dbconstring, "[dbo].[spSurveyReply]")) { s1.AddParameter("@survey", System.Data.SqlDbType.Int, c1.surveyId); s1.AddParameter("@questionId", System.Data.SqlDbType.Int, c1.questionId); s1.AddParameter("@answer", System.Data.SqlDbType.Int, c1.answer); s1.AddParameter("@repliedBy", System.Data.SqlDbType.NVarChar, c1.repliedBy); s1.Execute(); } }
protected void SubmitSurvey(object sender, EventArgs e) { if (Panel3.Visible == true) { foreach (GridViewRow row in GridView3.Rows) { if (row.RowType == DataControlRowType.DataRow) { int questionid = int.Parse((row.FindControl("Label1") as Label).Text); DropDownList ddl = row.FindControl("DropDownList4") as DropDownList; int answer = ddl.SelectedIndex; DBHandler.DBHandler db = new DBHandler.DBHandler(con); Entities.SurveyReply s1 = new Entities.SurveyReply() { surveyId = s, questionId = questionid, answer = answer, repliedBy = Session["School"].ToString(), }; db.SurveyReply(s1); } } DBHandler.DBHandler db1 = new DBHandler.DBHandler(con); Entities.SurveyReply s2 = new Entities.SurveyReply() { surveyId = s, repliedBy = Session["School"].ToString(), }; Entities.Survey s3 = new Entities.Survey() { surveyDate = DateTime.Now.ToShortDateString(), }; db1.InsertSurveyResponse(s2, s3); Page.ClientScript.RegisterStartupScript(GetType(), "id", "toggle_forms('ShowSurvey')", true); } else if (Panel4.Visible == true) { foreach (GridViewRow row in GridView1.Rows) { if (row.RowType == DataControlRowType.DataRow) { int questionid = int.Parse((row.FindControl("Label1") as Label).Text); CheckBox ddl = row.FindControl("CheckBox1") as CheckBox; int answer = ddl.Checked ? 6 : 7; DBHandler.DBHandler db = new DBHandler.DBHandler(con); Entities.SurveyReply s1 = new Entities.SurveyReply() { surveyId = s, questionId = questionid, answer = answer, repliedBy = Session["School"].ToString(), }; db.SurveyReply(s1); } } DBHandler.DBHandler db1 = new DBHandler.DBHandler(con); Entities.SurveyReply s2 = new Entities.SurveyReply() { surveyId = s, repliedBy = Session["School"].ToString(), }; Entities.Survey s3 = new Entities.Survey() { surveyDate = DateTime.Now.ToShortDateString(), }; db1.InsertSurveyResponse(s2, s3); Page.ClientScript.RegisterStartupScript(GetType(), "id", "toggle_forms('ShowSurvey')", true); } }