protected void btnRegister_Click(object sender, EventArgs e) { if (Page.IsValid) { string conn = ConfigurationManager.ConnectionStrings["Connection"].ConnectionString; DAL myDal = new DAL(conn); DataSet dsRegister = new DataSet(); myDal.AddParam("@FullName", txtFullName.Text); myDal.AddParam("@Email", txtEmail.Text); myDal.AddParam("@Password", txtPassword.Text); dsRegister = myDal.ExecuteProcedure("spCreateUser"); if (dsRegister.Tables[0].Rows[0]["Message"].ToString() == "Error") { lblMessage.Text = "Error account has already been created"; lblMessage.ForeColor = System.Drawing.Color.Red; } else { lblMessage.Text = "User Created, Please go to Log In to continue"; //ConfirmationEmail(); //lblEmail.Text = "A confirmation email has been sent to your email address"; } } }
protected void BtnACtive_Click(object sender, EventArgs e) { DAL mydal = new DAL(conn); DataSet ds = new DataSet(); DateTime start = Convert.ToDateTime(txtStartDate.Text); DateTime end = Convert.ToDateTime(txtEndDate.Text); // DateTime starttime = Convert.ToDateTime(txtStartTime.Text); //// BASED ON txtStartTime.Text somehow int hours = Int32.Parse(dd1startH.SelectedValue); int minutes = Int32.Parse(dd1startM.SelectedValue); start = start.AddHours(hours).AddMinutes(minutes); int Ehours = Int32.Parse(dd2EndH.SelectedValue); int Eminutes = Int32.Parse(dd2EndM.SelectedValue); end = end.AddHours(Ehours).AddMinutes(Eminutes); mydal.AddParam("@StartTime", start); mydal.AddParam("@EndTime", end); mydal.AddParam("@QuizId", ddQuiz.SelectedValue); mydal.AddParam("@SessionId", ddSession.SelectedValue); ds = mydal.ExecuteProcedure("spActiveExam"); string result = ds.Tables[0].Rows[0]["Result"].ToString(); if (result == "Success") { lblMsg.Text = "Exam Actived"; } else { lblMsg.Text = "something Wrong .Try Later!!"; } }
protected void BtnSubmit_Click(object sender, EventArgs e) { try { string clientID = (string)Session["ClientID"]; foreach (ItemSales item in listOfSales.Sales) { DAL_Project.DAL d = new DAL_Project.DAL(@"Data Source=localhost;Initial Catalog=dbDeidreFinalAssign;Integrated Security=SSPI"); d.AddParam("@ClientID", clientID); d.AddParam("@Item", item.item); d.AddParam("@TotalSale", item.SubTotalPrice.ToString()); d.AddParam("@Quantity", item.Quantity.ToString()); d.ExecuteProcedure("spItemSalesOrder"); } } catch (Exception ex) { lblError.Text = "Opps, Something went wrong. Please try again later! " + ex.Message; } pnlCheckOut.Visible = false; btnFinalCheckOut.Visible = false; pnlSuccess.Visible = true; SendEmailMessage(); }
public Security(string Email, String Password) { DataSet ds = new DataSet(); DAL myDal = new DAL(ConfigurationManager.ConnectionStrings["Exam"].ConnectionString); myDal.ClearParams(); myDal.AddParam("@Email", Email + ConfigurationManager.AppSettings["EmailDomainName"]); myDal.AddParam("@Password", Password); ds = myDal.ExecuteProcedure("UserspLogin"); if (ds.Tables[0].Rows.Count == 0) { SecurityLevel = 0; Firstname = "Invalid Login"; Userid = -1; } else { SecurityLevel = Convert.ToInt32(ds.Tables[0].Rows[0]["SecurityLevel"].ToString()); Firstname = "Welcome " + ds.Tables[0].Rows[0]["FirstName"].ToString() + "!"; Userid = Convert.ToInt32(ds.Tables[0].Rows[0]["Userid"].ToString()); } HttpContext.Current.Session["Firstname"] = Firstname; HttpContext.Current.Session["SecurityLevel"] = SecurityLevel; HttpContext.Current.Session["Userid"] = Userid; }
public void SaveToDatabase(string clientId, string Item, string SubTotalPrice, string Quantity) { DAL_Project.DAL dal = new DAL_Project.DAL("Data Source=localhost;Initial Catalog=dbDeidreFinalAssign;Integrated Security=SSPI"); dal.AddParam("@ClientID", clientId); dal.AddParam("@Item", Item); dal.AddParam("@TotalSale", SubTotalPrice); dal.AddParam("@Quantity", Quantity); dal.ExecuteProcedure("spItemSalesOrder"); }
public string insertQuizInformation() { Security S = new Security(); DAL mydal = new DAL(conn); mydal.AddParam("@UserId", S.Userid); mydal.AddParam("@QuizId", (int)Session["QuizId"]); DataSet ds= mydal.ExecuteProcedure("spInsertQuizInformation"); return ds.Tables[0].Rows[0]["newQuizResponseId"].ToString(); }
protected void btnSave_Click(object sender, EventArgs e) { DAL mydal = new DAL(conn); mydal.AddParam("@GUID", Request["uid"]); mydal.AddParam("@Password", txtPassword.Text); mydal.ExecuteProcedure("spChangePassword"); lblMessage.Text = "New password saved"; Response.Redirect("Home.aspx"); }
private DataSet SendToDatabase() { DAL d = new DAL("Data Source=localhost;Initial Catalog=dbSD13GroupProject;Integrated Security=True"); d.AddParam("@TopicId", TopicId); d.AddParam("@ThreadTitle", ThreadSubject); d.AddParam("@UserId", PostedByUserId); d.AddParam("@CurrentTime", DatePosted); d.AddParam("@MessageBody", MessageBody); return d.ExecuteProcedure("spNewThread"); }
protected void btnUpdate_Click(object sender, EventArgs e) { DAL myDal = new DAL(); myDal.AddParam("UserName", txtUsername.Text); string sProc; sProc = "spUpdateUser"; myDal.AddParam("UserID", txtUserID.Text); myDal.ExecuteProcedure(sProc); LoadUsers(); }
//Edits a currently existing message in the database, given that messages ID public int EditMessage(int messageId, string messageBody) { int threadId; this.MessageBody = messageBody; DAL d = new DAL("Data Source=localhost;Initial Catalog=dbSD13GroupProject;Integrated Security=True"); d.AddParam("@MessageId", messageId); d.AddParam("@NewMessageBody", messageBody); d.ExecuteProcedure("spEditCurrentMessage"); return threadId; }
protected void btnSubmit_Click(object sender, EventArgs e) { if (Page.IsValid) { if (ddTypeofQuestions.SelectedItem.Text == "Multiple Questions/Fill the Blanks") { DAL mydal = new DAL(conn); mydal.AddParam("@QuizTitle", TxtQuizTitle.Text); mydal.AddParam("@ProgramId", ddProgram.SelectedValue); mydal.AddParam("@DifficultyId", ddDifficulty.SelectedValue); mydal.AddParam("@TimeInMinute", Convert.ToDateTime(txtTimeinMinutes.Text)); mydal.AddParam("@TypeOfQuestionsId", ddTypeofQuestions.SelectedValue); mydal.AddParam("@Question", txtQuestion.Text); mydal.AddParam("@CorrectAnswer", txtCorrectAnswer.Text); mydal.AddParam("@Marks", txtMarks.Text); mydal.AddParam("@Answer0", txtAns1.Text); mydal.AddParam("@Answer1", txtAns2.Text); mydal.AddParam("@Answer2", txtAns3.Text); mydal.AddParam("@Answer3", txtAns4.Text); mydal.ExecuteProcedure("spInsertQuestionMultiChoice"); } else { if (RdoAnswer.SelectedItem != null) { DAL mydal = new DAL(conn); mydal.AddParam("@QuizTitle", TxtQuizTitle.Text); mydal.AddParam("@ProgramId", ddProgram.SelectedValue); mydal.AddParam("@DifficultyId", ddDifficulty.SelectedValue); mydal.AddParam("@TimeInMinute", Convert.ToDateTime(txtTimeinMinutes.Text)); mydal.AddParam("@TypeOfQuestionsId", ddTypeofQuestions.SelectedValue); mydal.AddParam("@Question", txtQuestion.Text); // mydal.AddParam("@CorrectAnswer", txtCorrectAnswer.Text); mydal.AddParam("@Mark", txtMarks.Text); mydal.AddParam("@CorrectAnswer", RdoAnswer.SelectedIndex); // mydal.AddParam("@Answer2", RdoAnswer.); mydal.ExecuteProcedure("spInsertQuestionTrueFalse"); } else { } } } }
protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { DAL myDal = new DAL(conn); DataSet dsAdd = new DataSet(); myDal.AddParam("@FullName", txtFullName.Text); myDal.AddParam("@Email", txtEmail.Text); myDal.AddParam("@Password", txtPassword.Text); myDal.AddParam("@SecurityLevel", int.Parse(ddlSecurityLevel.SelectedValue)); dsAdd = myDal.ExecuteProcedure("spAdminCreateUser"); LoadUsers(); pnlRight.Visible = false; } }
protected void btnSignIn_Click(object sender, EventArgs e) { Session["SignedIn"] = "User"; DataSet ds = new DataSet(); DAL_Project.DAL d = new DAL_Project.DAL(@"Data Source=localhost;Initial Catalog=dbDeidreFinalAssign;Integrated Security=SSPI"); d.AddParam("@UserName", txtUserName.Text);//@UserName will compare value txtUserName.Text d.AddParam("@Password", txtPassword.Text);//@Password will compare value txtPassword.Text ds = d.ExecuteProcedure("spSignIn"); lbnStore.Visible = true; lbnMembers.Visible = true; if (ds.Tables[0].Rows.Count > 0) { Session["ClientID"] = ds.Tables[0].Rows[0]["ClientID"].ToString(); Session["SecurityLevel"] = ds.Tables[0].Rows[0]["SecurityLevel"].ToString(); Session["UserName"] = ds.Tables[0].Rows[0]["UserName"].ToString(); Session["Password"] = ds.Tables[0].Rows[0]["UserPassword"].ToString(); if (Session["SecurityLevel"].ToString() == "2") { lbnAdmin.Visible = true; ancorLogin.Visible = false; lbnStore.Visible = false; lbnMembers.Visible = false; } if (chxStaySignedIn.Checked) { HttpCookie myCookieAdm = new HttpCookie("StaySignedInClientID"); myCookieAdm.Value = Session["ClientID"].ToString(); myCookieAdm.Expires = DateTime.Now.AddDays(2); Response.Cookies.Add(myCookieAdm); HttpCookie myCookieReg = new HttpCookie("StaySignedInSecurityLevel"); myCookieReg.Value = Session["SecurityLevel"].ToString(); myCookieReg.Expires = DateTime.Now.AddDays(2); Response.Cookies.Add(myCookieReg); } } else { lblErrorSignIn.Text = "INCORRECT USERNAME AND PASSWORD!"; } lblYouAre.Text = "Welcome " + txtUserName.Text; pnlSignedOut.Visible = true; }
public void loadgvUserBookedRooms() { DAL d = new DAL(conn); d.AddParam("@UserID", mySecurity.UserID); gvUserBookedRooms.DataSource = d.ExecuteProcedure("spGetBookingsForUser"); gvUserBookedRooms.DataBind(); }
protected void ddtest_SelectedIndexChanged(object sender, EventArgs e) { DAL myDal = new DAL(conn); myDal.AddParam("@QuizId",ddtest.SelectedValue); GVQuizResponseByUser.DataSource = myDal.ExecuteProcedure("spGetAllQuizReponsesByQuizId"); GVQuizResponseByUser.DataBind(); }
protected void btnadd_Click1(object sender, EventArgs e) { if (Page.IsValid) { DAL mydal = new DAL(conn); if (txtRoomID.Text != "new") { mydal.AddParam("RoomID", txtRoomID.Text); } mydal.AddParam("RoomName", txtRoomName.Text); mydal.AddParam("@NumberOfChairs", DDLCap.SelectedValue.ToString()); mydal.AddParam("FloorID", DDLFloor.SelectedValue.ToString()); mydal.ExecuteProcedure("spInsertRooms"); loadRooms(); PanRoom.Visible = false; } }
protected void btnadd_Click(object sender, EventArgs e) { if (Page.IsValid) { // Adding a new Booking // PanAddRoom.Visible = false; DAL mydal = new DAL(conn); DateTime StartTime = DateTime.Parse(txtDate.Text + " " + txtStartTime.Text); DateTime EndTime = DateTime.Parse(txtDate.Text + " " + txtEndTime.Text); mydal.AddParam("StartTime", StartTime); mydal.AddParam("EndTime", EndTime); mydal.AddParam("RoomID", DDLRoom.SelectedValue); mydal.AddParam("UserID", DDLUsers.SelectedValue); mydal.ExecuteProcedure("spBookRoom"); loadBookings(); PanAddRoom.Visible = false; } }
public bool Login(string FullName, string Password) { DAL myDal = new DAL(conn); DataSet dsLogin = new DataSet(); myDal.AddParam("@FullName", FullName); myDal.AddParam("@Password", Password); dsLogin = myDal.ExecuteProcedure("spLogin"); if (dsLogin.Tables[0].Rows.Count == 0) { return false; } HttpContext.Current.Session["UserID"] = int.Parse(dsLogin.Tables[0].Rows[0]["UserID"].ToString()); HttpContext.Current.Session["FullName"] = dsLogin.Tables[0].Rows[0]["FullName"].ToString(); HttpContext.Current.Session["SecurityLevel"] =int.Parse(dsLogin.Tables[0].Rows[0]["SecurityLevel"].ToString()); return true; }
protected void btnSave_Click(object sender, EventArgs e) { string filename = FileUploadServerFolder.FileName; string databasePath = "/Images/" + filename;// this path will save the file in the folder where the program will always look up to TextBox usernameTextbox = (TextBox)CreateUserWizard1.FindControl("UserName"); TextBox passwordTextbox = (TextBox)CreateUserWizard1.FindControl("Password"); TextBox emailTextbox = (TextBox)CreateUserWizard1.FindControl("Email"); MembershipUser createdUser = Membership.CreateUser(usernameTextbox.Text, passwordTextbox.Text, emailTextbox.Text); Guid currentUserId = new Guid(); if(createdUser != null) { currentUserId = (Guid)createdUser.ProviderUserKey; } else { return; } if (filename != "") { string serverPath = Server.MapPath(".") + "\\Images\\";// this code looks for the filename in this path FileUploadServerFolder.PostedFile.SaveAs(serverPath + filename); } DAL d = new DAL(conn); d.AddParam("@UserID", currentUserId); d.AddParam("@FirstName", txtFName.Text); d.AddParam("@LastName", txtLName.Text); d.AddParam("@Birthday", txtBirthday.Text); d.AddParam("@ImagePath", databasePath); d.AddParam("@Phone", txtPhone.Text); d.AddParam("@Address", txtAddress.Text); d.AddParam("@Postal", txtPostal.Text); d.AddParam("@City", txtCity.Text); d.AddParam("@Province", txtProvince.Text); d.AddParam("@Country", txtCountry.Text); d.ExecuteProcedure("spAddPersonalInfo"); Response.Redirect("Default.aspx"); }
public void LoadAvailableExamforlogedInUser() { Security s = new Security(); DAL mydal = new DAL(conn); mydal.AddParam("@UserId",s.Userid); DataSet ds = mydal.ExecuteProcedure("spGetActiveQuizByUser"); string QuizName = ds.Tables[0].Rows[0]["QuizTitle"].ToString(); lblShowQuiz.Text = QuizName; Session["QuizName"] = QuizName; }
private void LoadNumberOfStudentByProgram(string SortColumn) { DAL myDal = new DAL(conn); myDal.AddParam("@Direction", GetDirection()); GvNumberOfStudentByProgram.DataSource = myDal.ExecuteProcedure("spGetNumberOfStudentByProgram"); GvNumberOfStudentByProgram.DataBind(); }
protected void btnRecoverPassword_Click(object sender, EventArgs e) { DAL mydal = new DAL(conn); mydal.AddParam("Email", txtEmail.Text + emailDomain); DataSet ds = new DataSet(); ds = mydal.ExecuteProcedure("spResetPassword"); string theEmail = ds.Tables[0].Rows[0]["Email"].ToString(); string id = ds.Tables[0].Rows[0]["Uniqueid"].ToString(); string Email = txtEmail.Text; sendpasswordEmail(theEmail, id); }
protected void BtnACtive_Click(object sender, EventArgs e) { DAL mydal = new DAL(conn); DataSet ds = new DataSet(); DateTime start = Convert.ToDateTime(txtStartDate.Text); DateTime end = Convert.ToDateTime(txtEndDate.Text); // DateTime starttime = Convert.ToDateTime(txtStartTime.Text); //// BASED ON txtStartTime.Text somehow int hours = Int32.Parse(dd1startH.SelectedValue); int minutes = Int32.Parse(dd1startM.SelectedValue); start = start.AddHours(hours).AddMinutes(minutes); int Ehours = Int32.Parse(dd2EndH.SelectedValue); int Eminutes = Int32.Parse(dd2EndM.SelectedValue); end = end.AddHours(Ehours).AddMinutes(Eminutes); mydal.AddParam("@StartTime",start); mydal.AddParam("@EndTime",end); mydal.AddParam("@QuizId",ddQuiz.SelectedValue); mydal.AddParam("@SessionId",ddSession.SelectedValue); ds = mydal.ExecuteProcedure("spActiveExam"); }
protected void Page_Load(object sender, EventArgs e) { string productId = Request.QueryString["productId"]; if (!IsPostBack) { DAL d = new DAL("Data Source=localhost;Initial Catalog=dbSD13GroupProject;Integrated Security=True"); d.AddParam("@ProductId", productId); rptMessageBoard.DataSource = d.ExecuteProcedure("spGetTopicsByProductId"); rptMessageBoard.DataBind(); } }
public void loadQuestions() { if (rowindex != -1) { DAL mydal = new DAL(conn); mydal.AddParam("@QuizId", Session["QuizId"].ToString()); DataSet ds = mydal.ExecuteProcedure("spQuestionsbyQuizId"); dt = ds.Tables[0]; string CorrectAnswer = dt.Rows[rowindex]["CorrectAnswer"].ToString(); ViewState["CorrectAnswer"] = CorrectAnswer; if (dt.Rows.Count < 1) { lblQuestion.Text = "ERROR, QUIZ RETURNED WITH 0 ROWS!"; } } }
protected void Page_Load(object sender, EventArgs e) { Panel pnlLogin = (Panel)Master.FindControl("pnlLogin"); pnlLogin.Visible = false; if (!string.IsNullOrEmpty(Request["uid"])) { DAL mydal = new DAL(conn); mydal.AddParam("@GUID", Request["uid"]); DataSet ds = mydal.ExecuteProcedure("spIsPasswordResetLinkValid"); string isValid = ds.Tables[0].Rows[0]["IsvalidPasswordResetLink"].ToString(); if (isValid == "0") { lblMessage.Text = "Error"; } } }
protected void btnfinish_Click1(object sender, EventArgs e) { Security s=new Security(); DAL mydal = new DAL(conn); // mydal.AddParam("@QuizResponseId",); for (int i=0;i<(int)Session["NumberofQuestion"];i++) { mydal.ClearParams(); mydal.AddParam("@UserId",s.Userid); mydal.AddParam("@QuizId", (int)Session["QuizId"]); mydal.AddParam("@QuestionId",(i+1).ToString()); mydal.AddParam("@Response",Responses[i]); mydal.ExecuteProcedure("spInsertQuestionResponse"); } }
private void CountNumberOfQuestions() { DAL mydal = new DAL(conn); mydal.AddParam("QuizId", (int)Session["QuizId"]); DataSet ds = mydal.ExecuteProcedure("spCountNumberOfQuestions"); counter = int.Parse(ds.Tables[0].Rows[0]["numberofquestions"].ToString()); Session["NumberofQuestion"] = counter; }
protected void gvActiveExam_RowCommand(object sender, GridViewCommandEventArgs e) { gvActiveExam.SelectedIndex = Convert.ToInt32(e.CommandArgument); switch(e.CommandName) { case "act": UpdatePanelActive.Visible = true; break; case "del": DAL mydal = new DAL(conn); DataSet ds = new DataSet(); mydal.AddParam("QuizId", gvActiveExam.SelectedDataKey.Value.ToString()); ds = mydal.ExecuteProcedure("spDeleteQuiz"); string Result = ""; Result = ds.Tables[0].Rows[0]["Result"].ToString(); if (Result == "Success") { lblError.Text = "DELETED SUCCESSFULLY!"; } else if (Result == "Failed") { lblError.Text = "YOU CANNOT DELETE IT IS ALREADY IN USE!"; } loadAvailableExam(); break; default: break; } }
protected void btnRegister_Click(object sender, EventArgs e) { try { DAL_Project.DAL dal = new DAL_Project.DAL(@"Data Source=localhost;Initial Catalog=dbDeidreFinalAssign;Integrated Security=SSPI"); dal.AddParam("@fName", txtfName.Text); dal.AddParam("@lName", txtlName.Text); dal.AddParam("@Address", txtAddress.Text); dal.AddParam("@City", txtCity.Text); dal.AddParam("@PostCode", txtPostCode.Text); dal.AddParam("@Province", ddProvince.Text); dal.AddParam("@Phone", txtPhone.Text); dal.AddParam("@UserName", txtUserName.Text); dal.AddParam("@UserPassword", txtPassword.Text); dal.AddParam("@Email", txtEmail.Text); dal.AddParam("@SecQuest", ddSecurity.Text); dal.AddParam("@SecAns", txtSecurityAnswer.Text); dal.ExecuteProcedure("spRegisterClientUser"); /// <summary> /// Shows a Message saying that they are registered, /// that they will receive an e-mail and they will be redirected to the Sign In page /// </summary> if (cbxConfirm.Checked) { SendEmailMessage(); } } catch (Exception ex) { lblStatus.Text = "Send Email Failed. " + ex.Message; } finally { pnlRegTitle.Visible = false; pnlClientUserReg.Visible = false; pnlRegConfirm.Visible = true; } }