//public NpgsqlConnection Connection = new NpgsqlConnection(@"Data Source=LAPTOP-CNDERC7H\SQLEXPRESS;Initial Catalog=RemoteSystem;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"); protected void Page_Load(object sender, EventArgs e) { GenerateQuery QueryObj = new GenerateQuery(); string UserId = Request.QueryString["UserId"]; if (UserId != "" && UserId != null) { string Query = QueryObj.GetQueryViaFileAndTagName("LogIn.xml", "RemoteControlList"); DataTable DataTable = new DataTable("DataTable"); Connection.Open(); NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(Query, Connection); DataSet dataSetObj = new DataSet(); adapter.Fill(dataSetObj); GridView1.DataSource = dataSetObj; GridView1.DataBind(); } else { string message4 = "You do not have rights of this page. Please Contact Admin."; System.Text.StringBuilder sb3 = new System.Text.StringBuilder(); sb3.Append("<script type = 'text/javascript'>"); sb3.Append("window.onload=function(){"); sb3.Append("alert('"); sb3.Append(message4); sb3.Append("')};"); sb3.Append("</script>"); ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb3.ToString()); } }
protected void LoginUser_Click(object sender, EventArgs e) { Registrations registrationObj = new Registrations(); string Pass = registrationObj.encryptpass(Password.Text); GenerateQuery QueryObj = new GenerateQuery(); string[,] ReplaceValues = new string[2, 2]; ReplaceValues[0, 0] = "_UserName_"; ReplaceValues[0, 1] = UserName.Text; ReplaceValues[1, 0] = "_Password_"; ReplaceValues[1, 1] = Password.Text; long UserId = 0; string User = ""; Registration registration = null; string Query = QueryObj.GetQueryViaFileAndTagName("LogIn.xml", "ValidUserOrNot"); Query = Query.Replace("_UserName_", UserName.Text.ToString()); Query = Query.Replace("_Password_", Password.Text.ToString()); if (Query != "") { UserId = QueryObj.GetSingleNumericValueViaQuery(Query, ReplaceValues, Connection); User = QueryObj.GetSingleStringValueViaQuery(Query, ReplaceValues, Connection); if (UserId > 0) { Response.Redirect("ListPage.aspx?UserId=" + UserId); } else { UserName.Text = ""; Password.Text = ""; Label1.Text = "Enter User Name And Password is incurrect please try again."; } } if (Query != "") { registration = QueryObj.GetCollectionOfDataViaQuery(Query); DataTable DataTableObj = new DataTable("DataTable"); DataTableObj = QueryObj.GetCollectionOfDataSetViaQuery(Query); if (DataTableObj != null) { //Data Set havinf data now retrive it to its sutiable properties } } if (Query != "") { registration = QueryObj.GetCollectionSearchDataViaQuery(Query, ReplaceValues, null, null, "", registration); } }
protected void Page_Load(object sender, EventArgs e) { Registration registration = null; string Query = QueryObj.GetQueryViaFileAndTagName("LogIn.xml", "GetUserTypeList"); //Query = Query.Replace("_TypeName_", "UserType"); registration = QueryObj.GetCollectionOfDataViaQuery(Query); DataTable DataTableObj = new DataTable("DataTable"); DataTableObj = QueryObj.GetCollectionOfDataSetViaQuery(Query); if (DataTableObj != null) { for (int i = 0; i < DataTableObj.Rows.Count; i++) { long TypeId = Convert.ToInt64(DataTableObj.Rows[i].ItemArray[0]); string theValue = DataTableObj.Rows[i].ItemArray[1].ToString(); UserType.DataValueField = DataTableObj.Rows[i].ItemArray[0].ToString(); UserType.DataTextField = DataTableObj.Rows[i].ItemArray[1].ToString(); UserType.Items.Add(theValue); } } }
protected void Page_Load(object sender, EventArgs e) { try { if (Connection == null) { Connection.Open(); } rprt.Load(Server.MapPath("~\\Crystal Reports\\UserReport.rpt")); string Query = QueryObj.GetQueryViaFileAndTagName("LogIn.xml", "UserReport"); Connection.Open(); NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(Query, Connection); DataSet dataSetObj = new DataSet(); adapter.Fill(dataSetObj); if (dataSetObj != null) { ExportFormatType formatType = ExportFormatType.NoFormat; switch (rbFormat.SelectedItem.Value = "PDF") { case "Word": formatType = ExportFormatType.WordForWindows; break; case "PDF": formatType = ExportFormatType.PortableDocFormat; break; case "Excel": formatType = ExportFormatType.Excel; break; case "CSV": formatType = ExportFormatType.CharacterSeparatedValues; break; } adapter.Fill(dataSetObj, "User"); rprt.SetDataSource(dataSetObj.Tables[0]); UserReportId.ReportSource = rprt; rprt.ExportToHttpResponse(formatType, Response, false, "UserReport"); } } catch (Exception ex) { string msg = ex.Message; } finally { Connection.Close(); } }
protected void Button1_Click(object sender, EventArgs e) { try { if (Connection == null) { Connection.Open(); } Connection.Open(); string Query = QueryObj.GetQueryViaFileAndTagName("LogIn.xml", "GetUserTypeId"); Query = Query.Replace("_TypeName_", "Admin"); long UserTypeId = QueryObj.GetSingleNumericValueViaQuery(Query, null, Connection); string Pass = encryptpass(Password.Text); using (var cmd = Connection.CreateCommand()) { cmd.CommandText = "SP_UserLogin_SAVE"; cmd.CommandType = CommandType.StoredProcedure; long UserId = 0; cmd.Parameters.AddWithValue("@UserId", UserId); cmd.Parameters.AddWithValue("@UserName", UserName.Text); cmd.Parameters.AddWithValue("@FirstName", FirstName.Text); cmd.Parameters.AddWithValue("@LastName", LastName.Text); cmd.Parameters.AddWithValue("@Email", Email.Text); cmd.Parameters.AddWithValue("@Password", Pass); cmd.Parameters.AddWithValue("@CreatedBy", 1); cmd.Parameters.AddWithValue("@CreatedDate", DateTime.Now); cmd.Parameters.AddWithValue("@LastModifyBy", 1); cmd.Parameters.AddWithValue("@LastModifyDate", DateTime.Now); cmd.Parameters.AddWithValue("@UserTypeId", UserTypeId); cmd.ExecuteNonQuery(); } } catch (Exception ex) { string msg = ex.Message; } finally { Connection.Close(); Response.Redirect("Login.aspx"); } }
// public string Email { set; get; } protected void Page_Load(object sender, EventArgs e) { if (Connection == null) { Connection.Open(); } TableItemStyle tableStyle = new TableItemStyle(); tableStyle.HorizontalAlign = HorizontalAlign.Center; tableStyle.VerticalAlign = VerticalAlign.Middle; tableStyle.Width = Unit.Pixel(100); string UserId = Request.QueryString["UserId"]; Registration registration = null; GenerateQuery QueryObj = new GenerateQuery(); long rowNum = 0; string Query = QueryObj.GetQueryViaFileAndTagName("LogIn.xml", "RemoteControlData"); registration = QueryObj.GetCollectionOfDataViaQuery(Query); DataTable DataTableObj = new DataTable("DataTable"); DataTableObj = QueryObj.GetCollectionOfDataSetViaQuery(Query); TableRow tempRow1 = new TableRow(); TableRow tempRow2 = new TableRow(); TableRow tempRow3 = new TableRow(); SqlDataAdapter adapter = new SqlDataAdapter(Query, Connection); DataSet dataSetObj = new DataSet(); adapter.Fill(dataSetObj); StringBuilder html = new StringBuilder(); html.Append("<table border = '1'>"); html.Append("<tr>"); foreach (DataColumn column in DataTableObj.Columns) { if (column.ColumnName != "UserId" && column.ColumnName != "RemoteControlSessionId") { html.Append("<th>"); html.Append(column.ColumnName); html.Append("</th>"); } } html.Append("</tr>"); foreach (DataRow row in DataTableObj.Rows) { html.Append("<tr>"); foreach (DataColumn column in DataTableObj.Columns) { if (column.ColumnName != "UserId" && column.ColumnName != "RemoteControlSessionId") { html.Append("<td>"); html.Append(row[column.ColumnName]); html.Append("</td>"); } } html.Append("</tr>"); } html.Append("</table>"); PlaceHolder1.Controls.Add(new Literal { Text = html.ToString() }); if (DataTableObj != null) { int DataSetRowCount = DataTableObj.Rows.Count; foreach (DataRow dr in DataTableObj.Rows) { TableCell tempCell1 = new TableCell(); TableCell tempCell2 = new TableCell(); TableCell tempCell3 = new TableCell(); for (int cellNum = 0; cellNum < 1; cellNum++) { tempCell1.Text = Convert.ToString(dr["RemoteControlSessionId"]); tempCell2.Text = Convert.ToString(dr["Name"]); tempCell3.Text = Convert.ToString(dr["Email"]); DataSetRowCount = DataSetRowCount - 1; } tempRow1.Cells.AddAt(Convert.ToInt32(rowNum), tempCell1); tempRow2.Cells.AddAt(Convert.ToInt32(rowNum), tempCell2); tempRow3.Cells.AddAt(Convert.ToInt32(rowNum), tempCell3); //Table1.Rows.Add(tempRow1); //Table1.Rows.Add(tempRow2); //Table1.Rows.Add(tempRow3); SessionAddress.InnerText = Convert.ToString(dr["Email"]); rowNum = rowNum + 1; } Table1.Rows.Add(tempRow1); } foreach (TableRow rw in Table1.Rows) { foreach (TableCell cel in rw.Cells) { cel.ApplyStyle(tableStyle); } } TableHeaderCell header1 = new TableHeaderCell(); header1.RowSpan = 1; header1.ColumnSpan = 5; header1.Text = "Remote Control Accept Reject List"; header1.Font.Bold = true; header1.BackColor = Color.Gray; header1.HorizontalAlign = HorizontalAlign.Center; header1.VerticalAlign = VerticalAlign.Middle; TableRow headerRow1 = new TableRow(); headerRow1.Cells.Add(header1); Table1.Rows.AddAt(0, headerRow1); }
protected void ApproveReject_RowCommand(object sender, GridViewCommandEventArgs e) { string Message = ""; try { if (Connection == null) { Connection.Open(); } int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = GridView1.Rows[index]; long RemoteControlSessionId = Convert.ToInt64(row.Cells[0].Text); string AlredyApproved = Convert.ToString(row.Cells[3].Text).ToString(); GenerateQuery QueryObj = new GenerateQuery(); string Query = QueryObj.GetQueryViaFileAndTagName("LogIn.xml", "GetUserId"); Query = Query.Replace("_RemoteControlSessionId_", RemoteControlSessionId.ToString()); long UserId = QueryObj.GetSingleNumericValueViaQuery(Query, null, Connection); if (e.CommandName == "Reject") { Connection.Open(); using (var cmd = Connection.CreateCommand()) { cmd.CommandText = "SP_RemoteControlSession_Delete"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@RemoteControlSessionId", RemoteControlSessionId); cmd.ExecuteNonQuery(); Message = "Selected User Request Rejected."; } } if (e.CommandName == "Approved" && AlredyApproved == "N") { Connection.Open(); using (var cmd = Connection.CreateCommand()) { cmd.CommandText = "SP_RemoteControlSession_SAVE"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@RemoteControlSessionId", RemoteControlSessionId); cmd.Parameters.AddWithValue("@UserId", UserId); cmd.Parameters.AddWithValue("@Reject", 'N'); cmd.Parameters.AddWithValue("@Approved", 'Y'); cmd.Parameters.AddWithValue("@CreatedBy", UserId); cmd.Parameters.AddWithValue("@CreatedDate", DateTime.Now); cmd.Parameters.AddWithValue("@LastModifyBy", UserId); cmd.Parameters.AddWithValue("@LastModifyDate", DateTime.Now); cmd.ExecuteNonQuery(); Message = "Selected User Request Get Approved."; } } else { Message = "Selected User are alredy Approved."; } } catch (Exception ex) { Message = ex.Message; } finally { Connection.Close(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script type = 'text/javascript'>"); sb.Append("window.onload=function(){"); sb.Append("alert('"); sb.Append(Message); sb.Append("')};"); sb.Append("</script>"); ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString()); Page_Load(sender, e); } }