public ActionResult Create(DatabaseConnectionModel model) { string message; if (!DBHelper.TryConnect(out message, model.ConnectionString)) { ViewBag.Message = message; return View(model); } var databaseid = _databaseRepository.CreateDatabase(model.InitialCatalog); if (Request["IsInit"] == "on") _databaseRepository.InitialDatabase(databaseid, model.ConnectionString, true); return Redirect("/Database/List"); }
public ActionResult InitDatabase(int id, DatabaseConnectionModel model) { var database = _databaseRepository.GetDatabaseById(id); if (database == null) { ViewBag.Message = "找不到指定ID的数据库,Database ID:" + id; return View(model); } string message; if (!DBHelper.TryConnect(out message, model.ConnectionString)) { ViewBag.Message = message; return View(model); } _databaseRepository.InitialDatabase(id, model.ConnectionString, true); return Redirect("/Database/TableList/" + id); }
public ActionResult InitTable(int id, DatabaseConnectionModel model) { var tableinfo = _databaseRepository.GetTableById(id); if (tableinfo == null) { ViewBag.Message = "找不到指定ID的表信息,ID:" + id; return View(model); } ViewBag.DatabaseInfoID = tableinfo.DatabaseInfoID; string message; if (!DBHelper.TryConnect(out message, model.ConnectionString)) { ViewBag.Message = message; return View(model); } _databaseRepository.InitialTable(id, model.ConnectionString); return Redirect("/Database/ColumnList/" + id); }
public ActionResult InitDatabase(int id) { DatabaseConnectionModel model = new DatabaseConnectionModel(); var database = _databaseRepository.GetDatabaseById(id); if (database == null) { ViewBag.Message = "找不到指定ID的数据库,Database ID:" + id; return View(model); } model.InitialCatalog = database.Name; return View(model); }