protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args) { PerformanceAnalyzerDataContext dbcontext = new PerformanceAnalyzerDataContext(); int val = dbcontext.validateUserName(args.Value); if (val == 1) { args.IsValid = true; } else { args.IsValid = false; } }
protected void Button2_Click(object sender, EventArgs e) { string password = TextBox2.Text; MD5 md5Hash = MD5.Create(); string hash = GetMd5Hash(md5Hash, password); hash = hash.Substring(3, 12); PerformanceAnalyzerDataContext dataContext = new PerformanceAnalyzerDataContext(); // course = dataContext.spLoginFinal(TextBox1.Text, hash); spLoginNew_Result course = dataContext.spLoginNew(TextBox1.Text, hash).FirstOrDefault(); // spLogin3_Result obj = course.ToList<spLogin3_Result>().FirstOrDefault(); // spLoginNew_Result obj = course.ToList<spLoginNew_Result>().FirstOrDefault(); spLoginNew_Result obj = course; if (obj.Column1 != 0) { if (obj.Column3.Equals("Student")) { Session["userID"] = obj.Column1; Session["userName"] = obj.Column2; Session["role"] = obj.Column3; Session["imageURL"] = obj.Column4; Session["courseID"] = obj.Column5; Response.Redirect("~/PresentationLayer/Student/Home.aspx"); } else if (obj.Column3.Equals("CourseAdmin")) { Session["userID"] = obj.Column1; Session["userName"] = obj.Column2; Session["role"] = obj.Column3; Session["imageURL"] = obj.Column4; Response.Redirect("~/PresentationLayer/Admin/Home.aspx"); } else if (obj.Column3.Equals("Lecturer")) { Session["userID"] = obj.Column1; Session["userName"] = obj.Column2; Session["role"] = obj.Column3; Session["imageURL"] = obj.Column4; Response.Redirect("~/PresentationLayer/Lecturer/Home.aspx"); } else if (obj.Column3.Equals("IndustryProfessional")) { Session["userID"] = obj.Column1; Session["userName"] = obj.Column2; Session["role"] = obj.Column3; Session["imageURL"] = obj.Column4; Response.Redirect("~/PresentationLayer/IndustryProfessional/Home.aspx"); } } else { ClientScript.RegisterStartupScript(GetType(), "hwaa", "alert('Either username or password incorrect');", true); TextBox1.Text = ""; TextBox2.Text = ""; } }
protected void Button5_Click(object sender, EventArgs e) { string imageURL = ""; if (FileUpload1.HasFile) { imageURL = "~/Images/" + FileUpload1.FileName; Session["imageURL"] = imageURL; } else { imageURL = "~/Images/" + "Default.jpg"; Session["imageURL"] = imageURL; } int i = RadioButtonList1.SelectedIndex; string userType = ""; if (i == 0) { userType = "CourseAdmin"; } else if (i == 1) { userType = "Lecturer"; } else if (i == 2) { userType = "IndustryProfessional"; } string password = TextBox7.Text; MD5 md5Hash = MD5.Create(); string hash = GetMd5Hash(md5Hash, password); hash = hash.Substring(3, 12); PerformanceAnalyzerDataContext dbcontext = new PerformanceAnalyzerDataContext(); // int val= dbcontext.spCreateUser(TextBox3.Text, userType, TextBox4.Text, TextBox5.Text, imageURL, TextBox7.Text); int val = dbcontext.spCreateUserNew3(TextBox3.Text, userType, TextBox4.Text, TextBox5.Text, imageURL, hash).FirstOrDefault() ?? -1; if (val > 0) { Session["userID"] = val; if (i == 0) { Session["userName"] = TextBox3.Text; Session["role"] = "CourseAdmin"; Session["imageURL"] = imageURL; Response.Redirect("~/PresentationLayer/Admin/Home.aspx"); } else if (i == 1) { Session["userName"] = TextBox3.Text; Session["role"] = "Lecturer"; Session["imageURL"] = imageURL; Response.Redirect("~/PresentationLayer/Lecturer/Home.aspx"); } else if (i == 2) { Session["userName"] = TextBox3.Text; Session["role"] = "IndustryProfessional"; Session["imageURL"] = imageURL; Response.Redirect("~/PresentationLayer/IndustryProfessional/Home.aspx"); } } else { Response.Redirect("~/Loogin.aspx"); } }
protected void Button5_Click(object sender, EventArgs e) { string imageURL=""; if (FileUpload1.HasFile) { imageURL = "~/Images/"+FileUpload1.FileName; Session["imageURL"]=imageURL; } else{ imageURL = "~/Images/"+"Default.jpg"; Session["imageURL"]=imageURL; } int i=RadioButtonList1.SelectedIndex; string userType=""; if(i==0){userType="CourseAdmin";} else if(i==1){userType="Lecturer";} else if(i==2){userType="IndustryProfessional";} string password = TextBox7.Text; MD5 md5Hash = MD5.Create(); string hash = GetMd5Hash(md5Hash, password); hash = hash.Substring(3, 12); PerformanceAnalyzerDataContext dbcontext = new PerformanceAnalyzerDataContext(); // int val= dbcontext.spCreateUser(TextBox3.Text, userType, TextBox4.Text, TextBox5.Text, imageURL, TextBox7.Text); int val = dbcontext.spCreateUserNew3(TextBox3.Text, userType, TextBox4.Text, TextBox5.Text, imageURL,hash ).FirstOrDefault()??-1; if (val > 0) { Session["userID"] = val; if (i == 0) { Session["userName"] = TextBox3.Text; Session["role"] = "CourseAdmin"; Session["imageURL"] =imageURL; Response.Redirect("~/PresentationLayer/Admin/Home.aspx"); } else if (i == 1) { Session["userName"] = TextBox3.Text; Session["role"] = "Lecturer"; Session["imageURL"] = imageURL; Response.Redirect("~/PresentationLayer/Lecturer/Home.aspx"); } else if (i == 2) { Session["userName"] = TextBox3.Text; Session["role"] = "IndustryProfessional"; Session["imageURL"] = imageURL; Response.Redirect("~/PresentationLayer/IndustryProfessional/Home.aspx"); } } else{ Response.Redirect("~/Loogin.aspx"); } }
public void testAdminUserNameForUserID() { PerformanceAnalyzerDataContext dbcontext = new PerformanceAnalyzerDataContext(); // spGetAdminData_Result admininfo = new spGetAdminData_Result(); var rdr = dbcontext.spGetAdminData(1); // spResultByUser_Result obj1 = rdr.ToList<spResultByUser_Result>().FirstOrDefault(); spGetAdminData_Result admininfo = rdr.ToList<spGetAdminData_Result>().FirstOrDefault(); // Assert.AreEqual("wad Kanchana", admininfo.userName); // bool equility = ("wad Kanchana" == admininfo.userName); Assert.AreEqual("wad Kanchana" , admininfo.userName); }