Esempio n. 1
0
        public ActionResult DeleteConfirmed(
            Int32?BackupLogID
            )
        {
            BackupLog BackupLog = new BackupLog();

            BackupLog.BackupLogID = System.Convert.ToInt32(BackupLogID);
            BackupLog             = BackupLogData.Select_Record(BackupLog);

            bool bSucess = false;

            bSucess = BackupLogData.Delete(BackupLog);
            if (bSucess == true)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "Can Not Delete");
            }
            return(null);
        }
Esempio n. 2
0
        public ActionResult Create([Bind(Include =
                                             "BackupDate"
                                             + "," + "FilePath"
                                             + "," + "Remarks"
                                         )] BackupLog BackupLog)
        {
            if (ModelState.IsValid)
            {
                bool bSucess = false;
                bSucess = BackupLogData.Add(BackupLog);
                if (bSucess == true)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", "Can Not Insert");
                }
            }

            return(View(BackupLog));
        }
Esempio n. 3
0
        // GET: /BackupLog/Delete/<id>
        public ActionResult Delete(
            Int32?BackupLogID
            )
        {
            if (
                BackupLogID == null
                )
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }


            BackupLog BackupLog = new BackupLog();

            BackupLog.BackupLogID = System.Convert.ToInt32(BackupLogID);
            BackupLog             = BackupLogData.Select_Record(BackupLog);

            if (BackupLog == null)
            {
                return(HttpNotFound());
            }
            return(View(BackupLog));
        }
Esempio n. 4
0
        public ActionResult Edit(BackupLog BackupLog)
        {
            BackupLog oBackupLog = new BackupLog();

            oBackupLog.BackupLogID = System.Convert.ToInt32(BackupLog.BackupLogID);
            oBackupLog             = BackupLogData.Select_Record(BackupLog);

            if (ModelState.IsValid)
            {
                bool bSucess = false;
                bSucess = BackupLogData.Update(oBackupLog, BackupLog);
                if (bSucess == true)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", "Can Not Update");
                }
            }

            return(View(BackupLog));
        }
Esempio n. 5
0
        // GET: /BackupLog/
        public ActionResult Index(string sortOrder,
                                  String SearchField,
                                  String SearchCondition,
                                  String SearchText,
                                  String Export,
                                  int?PageSize,
                                  int?page,
                                  string command)
        {
            if (command == "Show All")
            {
                SearchField                = null;
                SearchCondition            = null;
                SearchText                 = null;
                Session["SearchField"]     = null;
                Session["SearchCondition"] = null;
                Session["SearchText"]      = null;
            }
            else if (command == "Add New Record")
            {
                return(RedirectToAction("Create"));
            }
            else if (command == "Export")
            {
                Session["Export"] = Export;
            }
            else if (command == "Search" | command == "Page Size")
            {
                if (!string.IsNullOrEmpty(SearchText))
                {
                    Session["SearchField"]     = SearchField;
                    Session["SearchCondition"] = SearchCondition;
                    Session["SearchText"]      = SearchText;
                }
            }
            if (command == "Page Size")
            {
                Session["PageSize"] = PageSize;
            }

            ViewData["SearchFields"]     = GetFields((Session["SearchField"] == null ? "Backup Log I D" : Convert.ToString(Session["SearchField"])));
            ViewData["SearchConditions"] = Library.GetConditions((Session["SearchCondition"] == null ? "Contains" : Convert.ToString(Session["SearchCondition"])));
            ViewData["SearchText"]       = Session["SearchText"];
            ViewData["Exports"]          = Library.GetExports((Session["Export"] == null ? "Pdf" : Convert.ToString(Session["Export"])));
            ViewData["PageSizes"]        = Library.GetPageSizes();

            ViewData["CurrentSort"]         = sortOrder;
            ViewData["BackupLogIDSortParm"] = sortOrder == "BackupLogID_asc" ? "BackupLogID_desc" : "BackupLogID_asc";
            ViewData["BackupDateSortParm"]  = sortOrder == "BackupDate_asc" ? "BackupDate_desc" : "BackupDate_asc";
            ViewData["FilePathSortParm"]    = sortOrder == "FilePath_asc" ? "FilePath_desc" : "FilePath_asc";
            ViewData["RemarksSortParm"]     = sortOrder == "Remarks_asc" ? "Remarks_desc" : "Remarks_asc";

            dtBackupLog = BackupLogData.SelectAll();

            try
            {
                if (!string.IsNullOrEmpty(Convert.ToString(Session["SearchField"])) & !string.IsNullOrEmpty(Convert.ToString(Session["SearchCondition"])) & !string.IsNullOrEmpty(Convert.ToString(Session["SearchText"])))
                {
                    dtBackupLog = BackupLogData.Search(Convert.ToString(Session["SearchField"]), Convert.ToString(Session["SearchCondition"]), Convert.ToString(Session["SearchText"]));
                }
            }
            catch { }

            var Query = from rowBackupLog in dtBackupLog.AsEnumerable()
                        select new BackupLog()
            {
                BackupLogID  = rowBackupLog.Field <Int32>("BackupLogID")
                , BackupDate = rowBackupLog.Field <DateTime>("BackupDate")
                , FilePath   = rowBackupLog.Field <String>("FilePath")
                , Remarks    = rowBackupLog.Field <String>("Remarks")
            };

            switch (sortOrder)
            {
            case "BackupLogID_desc":
                Query = Query.OrderByDescending(s => s.BackupLogID);
                break;

            case "BackupLogID_asc":
                Query = Query.OrderBy(s => s.BackupLogID);
                break;

            case "BackupDate_desc":
                Query = Query.OrderByDescending(s => s.BackupDate);
                break;

            case "BackupDate_asc":
                Query = Query.OrderBy(s => s.BackupDate);
                break;

            case "FilePath_desc":
                Query = Query.OrderByDescending(s => s.FilePath);
                break;

            case "FilePath_asc":
                Query = Query.OrderBy(s => s.FilePath);
                break;

            case "Remarks_desc":
                Query = Query.OrderByDescending(s => s.Remarks);
                break;

            case "Remarks_asc":
                Query = Query.OrderBy(s => s.Remarks);
                break;

            default:      // Name ascending
                Query = Query.OrderBy(s => s.BackupLogID);
                break;
            }

            if (command == "Export")
            {
                GridView  gv = new GridView();
                DataTable dt = new DataTable();
                dt.Columns.Add("Backup Log I D", typeof(string));
                dt.Columns.Add("Backup Date", typeof(string));
                dt.Columns.Add("File Path", typeof(string));
                dt.Columns.Add("Remarks", typeof(string));
                foreach (var item in Query)
                {
                    dt.Rows.Add(
                        item.BackupLogID
                        , item.BackupDate
                        , item.FilePath
                        , item.Remarks
                        );
                }
                gv.DataSource = dt;
                gv.DataBind();
                ExportData(Export, gv, dt);
            }

            int pageNumber = (page ?? 1);
            int?pageSZ     = (Convert.ToInt32(Session["PageSize"]) == 0 ? 5 : Convert.ToInt32(Session["PageSize"]));

            return(View(Query.ToPagedList(pageNumber, (pageSZ ?? 5))));
        }