protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e) { int index = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0]); AuditDAO deleteDAO = new AuditDAO(); deleteDAO.delete(index); Response.Redirect("AuditingAndLog.aspx"); }
protected void setAudit(User u, string functionModified, string operation, string id_of_function, string remarks) { //set audit Audit a = new Audit(); AuditDAO aDAO = new AuditDAO(); a.userID = u.getUserID(); a.functionModified = functionModified; a.operation = operation; a.id_of_function = id_of_function; a.dateModified = DateTime.Now; a.remarks = remarks; aDAO.createAudit(a); }
protected void OnRowCommand(Object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Unban") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = GridView1.Rows[index]; //Response.Redirect("AddNewAccount.aspx?id=" + row.Cells[0].Text); string AdminNo = row.Cells[4].Text; string StaffID = row.Cells[3].Text; AuditDAO updateDAO = new AuditDAO(); updateDAO.updateAudit(AdminNo, StaffID); Response.Redirect("AuditingAndLog.aspx"); /* * GridViewRow gvr = (GridViewRow)(((Button)e.CommandSource).NamingContainer); * int RowIndex = gvr.RowIndex; * int index = Convert.ToInt32(GridView1.DataKeys[RowIndex].Values[0]); * AuditDAO updateDAO = new AuditDAO(); * updateDAO.updateAudit(index); * Response.Redirect("AuditingAndLog.aspx");*/ } }
protected void btnConfirmSubmit_Click(object sender, EventArgs e) { //to do validation Course_elearnCategoryDAO cecDAO = new Course_elearnCategoryDAO(); CourseCategory cc = new CourseCategory(); cc.category = txtCategory.Text; cc.status = "active"; int createdCourseCattID = cecDAO.createCategory(cc); //set audit User currentUser = (User)Session["currentUser"]; Audit a = new Audit(); AuditDAO aDAO = new AuditDAO(); a.userID = currentUser.getUserID(); a.functionModified = "course category"; a.operation = "create"; a.id_of_function = createdCourseCattID.ToString(); a.dateModified = DateTime.Now; a.remarks = "category name: " + txtCategory.Text; aDAO.createAudit(a); }
protected void btnDownload_Click(object sender, EventArgs e) { Page.Validate("ValidateForm"); if (!Page.IsValid) { } else { string function = ddlFunction.SelectedValue.ToLower(); string operation = ddlOperation.SelectedValue.ToLower(); string date_from1 = fromDateInput.Text; string date_to1 = toDateInput.Text; string fromDate = fromDateInput.Text.Substring(3, 2) + "/" + fromDateInput.Text.Substring(0, 2) + "/" + fromDateInput.Text.Substring(6, 4); string toDate = toDateInput.Text.Substring(3, 2) + "/" + toDateInput.Text.Substring(0, 2) + "/" + toDateInput.Text.Substring(6, 4); string date_from = fromDate + " 00:00:00"; string date_to = toDate + " 23:59:59"; AuditDAO adao = new AuditDAO(); ArrayList arr = new ArrayList(); if (function.Equals("all") && operation.Equals("all")) { arr = adao.getAllAudit_All(DateTime.ParseExact(date_from, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture), DateTime.ParseExact(date_to, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture)); } else { if (operation.Equals("all")) { arr = adao.getAllAudit_function(function, DateTime.ParseExact(date_from, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture), DateTime.ParseExact(date_to, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture)); } else if (function.Equals("all")) { arr = adao.getAllAudit_operation(operation, DateTime.ParseExact(date_from, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture), DateTime.ParseExact(date_to, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture)); } else { arr = adao.getAllAudit(operation, function, DateTime.ParseExact(date_from, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture), DateTime.ParseExact(date_to, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture)); } } var myExport = new CsvExport(); foreach (Audit a in arr) { myExport.AddRow(); myExport["UserID"] = a.userID; myExport["Function Modified"] = a.functionModified; myExport["Operation"] = a.operation; myExport["ID Of Function"] = a.id_of_function; myExport["Date Modified"] = a.dateModified; myExport["Remarks"] = a.remarks; } date_from1 = date_from1.Replace("/", "_"); string date = DateTime.Now.ToShortDateString(); string time = DateTime.Now.ToShortTimeString(); date = date.Replace("/", "_"); time = time.Replace(":", "_"); string filename = "[" + date_from1 + "]" + date + "_" + time + "_" + function + "_" + operation; string path = Server.MapPath("Audit/" + filename + ".csv"); FileStream stream = File.Create(path); stream.Dispose(); ///ASP.NET MVC action example myExport.ExportToFile(path); FileInfo fileInfo = new FileInfo(path); Response.Clear(); Response.AddHeader("Content-Disposition", "attachment;filename=" + fileInfo.Name); Response.AddHeader("Content-Length", fileInfo.Length.ToString()); Response.ContentType = "text/csv"; Response.Flush(); Response.WriteFile(fileInfo.FullName); Response.End(); } }
/// <summary> Retrieves Entity rows in a datatable which match the specified filter. It will always create a new connection to the database.</summary> /// <param name="selectFilter">A predicate or predicate expression which should be used as filter for the entities to retrieve.</param> /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query.</param> /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param> /// <param name="relations">The set of relations to walk to construct to total query.</param> /// <param name="pageNumber">The page number to retrieve.</param> /// <param name="pageSize">The page size of the page to retrieve.</param> /// <returns>DataTable with the rows requested.</returns> public static DataTable GetMultiAsDataTable(IPredicate selectFilter, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, int pageNumber, int pageSize) { AuditDAO dao = DAOFactory.CreateAuditDAO(); return(dao.GetMultiAsDataTable(maxNumberOfItemsToReturn, sortClauses, selectFilter, relations, pageNumber, pageSize)); }