protected void btnsubmit_Click(object sender, EventArgs e) { var obj = ElearningHelper.Context.sp_tblQuestionNewInsertCommand(txtQuestion.Text, Convert.ToInt64(ddlCatagory.SelectedValue), 0); foreach (var item in obj) { DataTable dt = (DataTable)ViewState["Answers"]; int i = 1; foreach (DataRow gg in dt.Rows) { var ans = ElearningHelper.Context.sp_tblAnswersNewInsertCommand(gg["Answer"].ToString(), item.QuestionId, i); int an = Convert.ToInt32(txtAnswer.Text); if (i == an) { using (var context = new ELearningDataContext()) { foreach (var opt in ans) { var updat = context.tblQuestions.Single(a => a.QuestionId == item.QuestionId); updat.FK_Answer = opt.Id; context.SubmitChanges(); } } } i++; } dt.Clear(); BindGrid(dt); } lbregister.Text = "Question Posted"; emptyfield(); }
protected void Button1_Click(object sender, EventArgs e) { string[] pas = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; Random rd = new Random(); string password = string.Empty; for (int i = 0; i < 6; i++) { password += pas[rd.Next(10)]; } var st = ElearningHelper.Context.sp_tblLoginNewInsertCommand(txtRollNumber.Text, txtName.Text, password, DropDownList2.SelectedValue, txtDepartment.Text, txtEMailId.Text, DateTime.Now, DateTime.Now, Convert.ToInt64(ddlRoll.SelectedValue), txtAddress.Text, Convert.ToInt64(txtPostalCode.Text),Convert.ToInt64(DropDownList1.SelectedValue)); foreach (var item in st) { using (var obj = new ELearningDataContext()) { var aa = new tblStuCourse(); aa.FK_Course = Convert.ToInt64(DropDownList2.SelectedValue); aa.FK_StudentId = item.Id; aa.Year = Convert.ToInt32(DropDownList1.SelectedItem.Text); obj.tblStuCourses.InsertOnSubmit(aa); obj.SubmitChanges(); } } lblRegister.Text = "Registered Successfully"; emptyfield(); }
protected void Button1_Click(object sender, EventArgs e) { using (var obj = new ELearningDataContext()) { var aa = new tblCourse(); aa.CourseName = txtCourseName.Text; obj.tblCourses.InsertOnSubmit(aa); obj.SubmitChanges(); } BindGrid(); lblAdd.Text = "Category Added"; emptyfield(); }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Verify") { using (var Context = new ELearningDataContext()) { var dd = Context.tblAssignments.Single(a => a.Id == Convert.ToInt64(e.CommandArgument)); dd.Status = true; Context.SubmitChanges(); } BindGrid(); } if (e.CommandName == "View") { System.Diagnostics.Process.Start(Server.MapPath(ElearningHelper.Context.tblAssignments.Single(a => a.Id == Convert.ToInt64(e.CommandArgument)).FilePath)); } }