private void fill_drpdwn() { try { SqlConnection con = new SqlConnection(constr.getconstr()); SqlCommand cmd = new SqlCommand("Get_Departments", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@User_ID", Session["User_ID"].ToString()); SqlDataAdapter ad = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); ad.Fill(ds); Drp_Dept.DataSource = ds.Tables[0]; Drp_Dept.DataValueField = "Dept_Name"; Drp_Dept.DataBind(); con.Close(); Drp_Dept.Items.Insert(0, new ListItem("--Select Department--", "0")); Drp_User_Group.Items.Insert(0, new ListItem("--Select User Group--", "0")); Drp_User.Items.Insert(0, new ListItem("--Select User--", "0")); } catch (Exception ex) { lblErrorMsg.Text = ""; lblErrorMsg.Text = ex.Message; } }
private void fill_drpdwn() { using (SqlConnection con = new SqlConnection(constr.getconstr())) { using (SqlCommand cmd = new SqlCommand("SELECT Country_Name FROM Country_Details")) { cmd.CommandType = CommandType.Text; cmd.Connection = con; con.Open(); Drp_Country.DataSource = cmd.ExecuteReader(); Drp_Country.DataValueField = "Country_Name"; Drp_Country.DataBind(); con.Close(); } } Drp_Country.Items.Insert(0, new ListItem("--Select Country--", "0")); }
protected void Btn_Update_Click(object sender, EventArgs e) { try { SqlConnection con = new SqlConnection(constr.getconstr()); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "Update_Pwd"; cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@User_ID", Session ["User_ID"].ToString()); cmd.Parameters.AddWithValue("@Pwd", txt_New_Pwd.Text); cmd.Parameters.AddWithValue("@OldPwd", txt_Old_Pwd.Text); cmd.Parameters.AddWithValue("@EnteredBy", Session["User_ID"].ToString()); var returnParam1 = new SqlParameter { ParameterName = "@Result", Direction = ParameterDirection.Output, Size = 1 }; cmd.Parameters.Add(returnParam1); cmd.ExecuteNonQuery(); string retunvalue = (string)cmd.Parameters["@Result"].Value; con.Close(); if (retunvalue == "3") { throw new Exception("Password Length must be atleaset 8 chracters"); } else if (retunvalue == "2") { throw new Exception("Password must be combination of alpha, numeric and symbolic chracters"); } else if (retunvalue == "5") { throw new Exception("This password has already been used"); } else if (retunvalue == "4") { throw new Exception("The Old Password Entered does not match with existing password"); } else if (retunvalue == "0") { //Session["User_ID"] = null; Response.Write("<script> alert('Password Updated');window.location='Auth.aspx'; </script>"); } } catch (Exception ex) { lblErrorMsg.Text = ""; lblErrorMsg.Text = ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { try { lblErrorMsg.Text = ""; SqlConnection con = new SqlConnection(constr.getconstr()); SqlCommand cmd = new SqlCommand("Get_User_Result"); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = con; cmd.Parameters.AddWithValue("@User_Name", Session["U_Name"].ToString()); cmd.Parameters.AddWithValue("@DOC_ID", Session["Doc_ID"].ToString()); cmd.Parameters.AddWithValue("@Version_ID", Session["Version_ID"].ToString()); cmd.Parameters.AddWithValue("@Attempt_ID", Session["Attempt"].ToString()); string result = ""; con.Open(); using (SqlDataReader sdr = cmd.ExecuteReader()) { sdr.Read(); result = sdr["Results"].ToString(); lblTotQuestions.Text = sdr["Tot_Question"].ToString(); lblCorrectAns.Text = sdr["Tot_Pass_Ans"].ToString(); lblWrngAns.Text = sdr["Tot_Fail_Ans"].ToString(); lblYetTBAnalysed.Text = sdr["TotYetAnalyzed"].ToString(); lbl_Tot_Per.Text = sdr["Passing_Per"].ToString(); lbl_User_Per.Text = sdr["Per_Scored"].ToString(); } con.Close(); Session["U_Name"] = ""; Session["Doc_ID"] = ""; Session["Version_ID"] = ""; Session["Attempt"] = ""; if (result == "1") { lbldisplaymsg.Text = "Assessment Complete!!! Congratulations!!! you have Passed the Assessment Test!!!"; } if (result == "2") { lbldisplaymsg.Text = "Assessment Complete!!! Sorry!!! you have Failed the Assessment Test!!!"; } if (result == "0") { lbldisplaymsg.Text = "Assessment Complete!!! Result still pending, will be updated once Analyzed!!! "; } } catch (Exception ex) { lblErrorMsg.Text = ""; lblErrorMsg.Text = ex.Message; } }
private void fill_Dept_Grid() { try { SqlConnection con = new SqlConnection(constr.getconstr()); SqlCommand cmd = new SqlCommand("Get_Departments", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@User_ID", Session["User_ID"].ToString()); SqlDataAdapter ad = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); ad.Fill(ds); Grd_Get_Dept_List.DataSource = ds.Tables[0]; Grd_Get_Dept_List.DataBind(); } catch (Exception ex) { lblErrorMsg.Text = ""; lblErrorMsg.Text = ex.Message; } }
void fillDataRepeater() { try { SqlConnection con = new SqlConnection(constr.getconstr()); SqlCommand cmd = new SqlCommand("Get_Country_Name", con); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter ad = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); ad.Fill(ds); Repeater1.DataSource = ds.Tables[0]; Repeater1.DataBind(); } catch (Exception ex) { lblErrorMsg.Text = ""; lblErrorMsg.Text = ex.Message; } }
private void fill_Doc_Type_drpdwn() { try { SqlConnection con = new SqlConnection(constr.getconstr()); SqlCommand cmd = new SqlCommand("Get_Doc_Type", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Action", "View"); cmd.Parameters.AddWithValue("@Dept_Name", Drp_Dept.SelectedValue); SqlDataAdapter ad = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); ad.Fill(ds); Drp_Doc_Type.DataSource = ds.Tables[0]; Drp_Doc_Type.DataValueField = "Doc_Type"; Drp_Doc_Type.DataBind(); con.Close(); Drp_Doc_Type.Items.Insert(0, new ListItem("All", "99")); } catch (Exception ex) { lblErrorMsg.Text = ""; lblErrorMsg.Text = ex.Message; } }
protected void Btn_Login_Click(object sender, EventArgs e) { try { //if (Request.Browser.Browser != "IE" || Request.Browser.Browser != "Firefox") //{ // throw new Exception("Please use Browser: 'Internet Explorer' to Start the Assessment!!!"); //} string Host_IP = Request.UserHostAddress.ToString(); SqlConnection con = new SqlConnection(constr.getconstr()); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "User_Auth"; cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UserID", this.txt_UserName.Text); cmd.Parameters.AddWithValue("@Pwd", this.txt_Pwd.Text); cmd.Parameters.AddWithValue("@Host_IP", Host_IP); var returnParam1 = new SqlParameter { ParameterName = "@Result", Direction = ParameterDirection.Output, Size = 1 }; cmd.Parameters.Add(returnParam1); cmd.ExecuteNonQuery(); string retunvalue = (string)cmd.Parameters["@Result"].Value; con.Close(); if (retunvalue == "1") { throw new Exception("Invalid Credentials"); } else if (retunvalue == "2") { throw new Exception("User Account has been Locked."); } else if (retunvalue == "3") { Session["User_ID"] = this.txt_UserName.Text; Response.Redirect("Change_Password.aspx"); } else if (retunvalue == "4") { Session["User_ID"] = this.txt_UserName.Text; Response.Redirect("Change_Password.aspx"); } else if (retunvalue == "5") { throw new Exception("Invalid Credentials"); } else if (retunvalue == "6") { throw new Exception("User Has Already been Logged IN"); } else if (retunvalue == "0") { Session["User_ID"] = this.txt_UserName.Text; SqlCommand cmd3 = new SqlCommand(); cmd3.CommandType = CommandType.StoredProcedure; cmd3.Connection = con; cmd3.CommandText = "Update_Alrdy_Log_IN"; con.Open(); cmd3.Parameters.AddWithValue("@Action", "LogIn"); cmd3.Parameters.AddWithValue("@User_ID", Session["User_ID"].ToString()); cmd3.ExecuteNonQuery(); con.Close(); con.Open(); SqlCommand cmd1 = new SqlCommand(); cmd1.CommandText = "Approval_Doc_Count"; cmd1.Connection = con; cmd1.CommandType = CommandType.StoredProcedure; cmd1.Parameters.AddWithValue("@User_ID", this.txt_UserName.Text); SqlDataReader myReader; myReader = cmd1.ExecuteReader(); while (myReader.Read()) { Session["CountAppDoc"] = myReader["DOC_ID"].ToString(); } con.Close(); con.Open(); SqlCommand cmd2 = new SqlCommand(); cmd2.CommandText = "PWD_EXP_Reminder"; cmd2.Connection = con; cmd2.CommandType = CommandType.StoredProcedure; cmd2.Parameters.AddWithValue("@User_ID", this.txt_UserName.Text); SqlDataReader myReader1; myReader1 = cmd2.ExecuteReader(); while (myReader1.Read()) { Session["PWDExpire"] = myReader1["Result"].ToString(); Session["NoofDays"] = myReader1["NoofDays"].ToString(); } con.Close(); Response.Redirect("HomePage.aspx"); } } catch (Exception ex) { lblErrorMsg.Text = ""; lblErrorMsg.Text = ex.Message; } }
protected void DownloadFile(object sender, EventArgs e) { try { if (Session["User_ID"] == null) { Response.Redirect("SessionExpired.aspx", false); } else { int id = int.Parse((sender as LinkButton).CommandArgument); id = id - 1; byte[] bytes; string fileName, contentType; SqlConnection con = new SqlConnection(constr.getconstr()); con.Open(); using (SqlCommand cmd1 = new SqlCommand("Sp_Doc_Open_log")) { cmd1.CommandType = CommandType.StoredProcedure; TextBox Doc_ID; Doc_ID = (TextBox)Grd_Get_SOP_List.Rows[id].FindControl("txt_Doc_ID"); TextBox Version_ID; Version_ID = (TextBox)Grd_Get_SOP_List.Rows[id].FindControl("txt_Ver_ID"); cmd1.Connection = con; cmd1.Parameters.AddWithValue("@Doc_ID", Doc_ID.Text); cmd1.Parameters.AddWithValue("@Version_ID", Version_ID.Text); cmd1.Parameters.AddWithValue("@Opened_By", Session["User_ID"].ToString()); cmd1.ExecuteNonQuery(); } using (SqlCommand cmd = new SqlCommand("Download_Doc")) { cmd.CommandType = CommandType.StoredProcedure; TextBox Doc_ID; Doc_ID = (TextBox)Grd_Get_SOP_List.Rows[id].FindControl("txt_Doc_ID"); TextBox Version_ID; Version_ID = (TextBox)Grd_Get_SOP_List.Rows[id].FindControl("txt_Ver_ID"); cmd.Connection = con; //con.Open(); cmd.Parameters.AddWithValue("@Doc_ID", Doc_ID.Text); cmd.Parameters.AddWithValue("@Version_ID", Version_ID.Text); using (SqlDataReader sdr = cmd.ExecuteReader()) { sdr.Read(); bytes = (byte[])sdr["Data"]; contentType = sdr["ContentType"].ToString(); fileName = sdr["Name"].ToString(); } con.Close(); } Response.Clear(); Response.Buffer = true; Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = contentType; Response.AppendHeader("Content-Disposition", "Inline; filename=" + fileName); Response.BinaryWrite(bytes); Response.Flush(); Response.End(); } } catch (Exception ex) { lblErrorMsg.Text = ""; lblErrorMsg.Text = ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { try { byte[] bytes; string fileName, contentType; MyCon constr = new MyCon(); SqlConnection con = new SqlConnection(constr.getconstr()); //Get Doc Information using (SqlCommand cmd = new SqlCommand("Download_Doc")) { con.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = con; //con.Open(); cmd.Parameters.AddWithValue("@Doc_ID", Session["Doc_ID"].ToString()); cmd.Parameters.AddWithValue("@Version_ID", Session["Version_ID"].ToString()); using (SqlDataReader sdr = cmd.ExecuteReader()) { sdr.Read(); bytes = (byte[])sdr["Data"]; contentType = sdr["ContentType"].ToString(); fileName = sdr["Name"].ToString(); } con.Close(); } // Creating Log of Doc Opened by user using (SqlCommand cmd1 = new SqlCommand("Sp_Doc_Open_log")) { con.Open(); cmd1.CommandType = CommandType.StoredProcedure; cmd1.Connection = con; cmd1.Parameters.AddWithValue("@Doc_ID", Session["Doc_ID"].ToString()); cmd1.Parameters.AddWithValue("@Version_ID", Session["Version_ID"].ToString()); cmd1.Parameters.AddWithValue("@Opened_By", Session["User_ID"].ToString()); cmd1.ExecuteNonQuery(); con.Close(); } // Opening DOC Response.Clear(); Response.Buffer = true; Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = contentType; Response.AppendHeader("Content-Disposition", "Inline; filename=" + fileName); Response.BinaryWrite(bytes); Response.Flush(); Response.End(); //string embed = "<object data=\"{0}\" type=\"application/pdf\" width=\"500px\" height=\"300px\">"; //embed += "If you are unable to view file, you can download from <a href = \"{0}\">here</a>"; //embed += " or download <a target = \"_blank\" href = \"http://get.adobe.com/reader/\">Adobe PDF Reader</a> to view the file."; //embed += "</object>"; //ltEmbed.Text = string.Format(embed, ResolveUrl("~/Document/Report1.pdf")); } catch (Exception ex) { lblErrorMsg.Text = ""; lblErrorMsg.Text = ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { try { if (!this.IsPostBack) { SqlConnection con = new SqlConnection(constr.getconstr()); con.Open(); SqlCommand cmd = new SqlCommand("Get_Assess_Questions"); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = con; cmd.Parameters.AddWithValue("@User_Name", Session["U_Name"].ToString()); cmd.Parameters.AddWithValue("@DOC_ID", Session["Doc_ID"].ToString()); cmd.Parameters.AddWithValue("@Version_ID", Session["Version_ID"].ToString()); using (SqlDataReader sdr = cmd.ExecuteReader()) { sdr.Read(); txt_DOC_ID.Text = sdr["Doc_ID"].ToString(); txt_Ver_ID.Text = sdr["Version_ID"].ToString(); txt_DOC_Title.Text = sdr["DOC_Title"].ToString(); txt_Questions.Text = sdr["Questions"].ToString(); txt_CA_ID.Text = sdr["CA_ID"].ToString(); txt_Quest_ID.Text = sdr["QuesID"].ToString(); txt_Act_Ans.Text = sdr["Answer"].ToString(); txt_Attempt.Text = sdr["Attempt"].ToString(); Session["Attempt"] = sdr["Attempt"].ToString(); txt_SelectAnyOne.Text = sdr["Sel_Any_One"].ToString(); } con.Close(); if (txt_SelectAnyOne.Text == "True") { fill_Sel_Anyone_Grid(); txt_Answer.Visible = false; } else { txt_Answer.Visible = true; } } } catch (Exception ex) { lblErrorMsg.Text = ""; SqlConnection con = new SqlConnection(constr.getconstr()); SqlCommand cmd = new SqlCommand("Get_User_Result"); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = con; cmd.Parameters.AddWithValue("@User_Name", Session["U_Name"].ToString()); cmd.Parameters.AddWithValue("@DOC_ID", Session["Doc_ID"].ToString()); cmd.Parameters.AddWithValue("@Version_ID", Session["Version_ID"].ToString()); cmd.Parameters.AddWithValue("@Attempt_ID", Session["Attempt"].ToString()); string result = ""; con.Open(); using (SqlDataReader sdr = cmd.ExecuteReader()) { sdr.Read(); result = sdr["Results"].ToString(); } con.Close(); Session["U_Name"] = ""; Session["Doc_ID"] = ""; Session["Version_ID"] = ""; Session["Attempt"] = ""; if (result == "1") { lbldisplaymsg.Text = "Assessment Complete!!! Congratulations!!! you have Passed the Assessment Test!!!"; } if (result == "2") { lbldisplaymsg.Text = "Assessment Complete!!! Sorry!!! you have Failed the Assessment Test!!!"; } if (result == "0") { lbldisplaymsg.Text = "Assessment Complete!!! Result still pending, will be updated once Analyzed!!! "; } } }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["User_ID"] == null) { Response.Redirect("SessionExpired.aspx", false); } else { if (!this.IsPostBack) { if (Session["Question"].ToString() == "1") { return; } SqlConnection con = new SqlConnection(constr.getconstr()); con.Open(); SqlCommand cmd = new SqlCommand("Get_Assess_Questions"); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = con; cmd.Parameters.AddWithValue("@User_Name", Session["U_Name"].ToString()); cmd.Parameters.AddWithValue("@DOC_ID", Session["Doc_ID"].ToString()); cmd.Parameters.AddWithValue("@Version_ID", Session["Version_ID"].ToString()); using (SqlDataReader sdr = cmd.ExecuteReader()) { sdr.Read(); txt_DOC_ID.Text = sdr["Doc_ID"].ToString(); txt_Ver_ID.Text = sdr["Version_ID"].ToString(); txt_DOC_Title.Text = sdr["DOC_Title"].ToString(); txt_Questions.Text = sdr["Questions"].ToString(); txt_CA_ID.Text = sdr["CA_ID"].ToString(); txt_Quest_ID.Text = sdr["QuesID"].ToString(); txt_Act_Ans.Text = sdr["Answer"].ToString(); txt_Attempt.Text = sdr["Attempt"].ToString(); Session["Attempt"] = sdr["Attempt"].ToString(); txt_SelectAnyOne.Text = sdr["Sel_Any_One"].ToString(); } con.Close(); if (txt_SelectAnyOne.Text == "True") { fill_Sel_Anyone_Grid(); txt_Answer.Visible = false; } else { txt_Answer.Visible = true; } } } } catch (Exception ex) { //mp2.Hide(); //string _script = string.Empty; //_script = "Assesment_Result.aspx"; //Response.Write("<script>javascript:window.open('" + _script + "','','ModalPopUp,fullscreen=yes,toolbar=no,menubar=no,resizable=0,controlbox=no,scrollbars=yes,status=no,statusbar=no,height=400,width=500');</script>"); //ClientScript.RegisterStartupScript(typeof(Page), "Assess_Question.aspx", "window.close();", true); DivQuestion.Visible = false; DivResult.Visible = true; lblErrorMsg.Text = ""; SqlConnection con = new SqlConnection(constr.getconstr()); SqlCommand cmd = new SqlCommand("Get_User_Result"); cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = con; cmd.Parameters.AddWithValue("@User_Name", Session["U_Name"].ToString()); cmd.Parameters.AddWithValue("@DOC_ID", Session["Doc_ID"].ToString()); cmd.Parameters.AddWithValue("@Version_ID", Session["Version_ID"].ToString()); cmd.Parameters.AddWithValue("@Attempt_ID", Session["Attempt"].ToString()); string result = ""; con.Open(); using (SqlDataReader sdr = cmd.ExecuteReader()) { sdr.Read(); result = sdr["Results"].ToString(); lblTotQuestions.Text = sdr["Tot_Question"].ToString(); lblCorrectAns.Text = sdr["Tot_Pass_Ans"].ToString(); lblWrngAns.Text = sdr["Tot_Fail_Ans"].ToString(); lblYetTBAnalysed.Text = sdr["TotYetAnalyzed"].ToString(); lbl_Tot_Per.Text = sdr["Passing_Per"].ToString(); lbl_User_Per.Text = sdr["Per_Scored"].ToString(); } con.Close(); Session["U_Name"] = ""; Session["Doc_ID"] = ""; Session["Version_ID"] = ""; Session["Attempt"] = ""; if (result == "1") { lbldisplaymsg.Text = "Assessment Complete!!! Congratulations!!! you have Passed the Assessment Test!!!"; } if (result == "2") { lbldisplaymsg.Text = "Assessment Complete!!! Sorry!!! you have Failed the Assessment Test!!!"; } if (result == "0") { lbldisplaymsg.Text = "Assessment Complete!!! Result still pending, will be updated once Analyzed!!! "; } } }