protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { this.BindGrid(); } string docId = Request.QueryString["Id"]; if (docId != null) { dbConnection.Open(); int DID = Convert.ToInt32(docId); string query = "SELECT DocumentFile FROM [dbo].[OMSheet] WHERE Id=" + DID; SqlCommand cmd = new SqlCommand(query, dbConnection); string fileName = cmd.ExecuteScalar().ToString(); userActivityLog.UserActivityLogs("O&M Sheets", "Download Sheet ID: " + DID); Response.ContentType = "Application/pdf"; Response.AppendHeader("Content-Disposition", "attachment; filename=~/Uploads/OMSheet/" + fileName); Response.TransmitFile(Server.MapPath(@"~/Uploads/OMSheet/" + fileName)); Response.End(); dbConnection.Close(); } }
protected void btnCreate_Click(object sender, EventArgs e) { try { dbConnection.Open(); string query = "INSERT INTO [dbo].[Project] ([ProjectName],[Details],[Status]) VALUES (@ProjectName,@Details,@Status)"; SqlCommand cmd = new SqlCommand(query, dbConnection); cmd.Parameters.AddWithValue("@ProjectName", txtProjectName.Text); cmd.Parameters.AddWithValue("@Details", txtDetails.Text); cmd.Parameters.AddWithValue("@Status", txtStatus.Text); cmd.ExecuteNonQuery(); userActivityLog.UserActivityLogs("Project", "Create project " + txtProjectName.Text); Response.Redirect("~/Project/CreateProject.aspx"); } catch (Exception ex) { Response.Write("error" + ex.ToString()); } finally { dbConnection.Close(); } }
protected void Page_Load(object sender, EventArgs e) { string reqProject = Request.QueryString["view"]; if (reqProject != null) { userActivityLog.UserActivityLogs("Projects", "Select default project"); Session["defaultProject"] = Convert.ToInt32(reqProject).ToString(); Response.Redirect(webPath + "Default.aspx"); } }