public ActionResult Stat() { try { const string sql = @"SELECT '[' + SCHEMA_NAME(t.schema_id) + '].[' + t.name + ']' AS fullTableName, SCHEMA_NAME(t.schema_id) AS schemaName, t.name AS TableName, i.rows AS Rows, t.create_date AS Created, t.modify_date AS Modified FROM sys.tables AS t INNER JOIN sys.sysindexes AS i ON t.object_id = i.id AND i.indid < 2 WHERE SCHEMA_NAME(t.schema_id) != 'dbo' ORDER BY schemaName, fullTableName"; var counters = AdminDb.ExecuteQuery <StatCounter>(sql).ToList(); const string size = @"SELECT DatabaseName = DB_NAME(database_id), LogSize = CAST(SUM(CASE WHEN type_desc = 'LOG' THEN size END) * 8. / 1024 AS DECIMAL(8,2)), RowSize = CAST(SUM(CASE WHEN type_desc = 'ROWS' THEN size END) * 8. / 1024 AS DECIMAL(8,2)), TotalSize = CAST(SUM(size) * 8. / 1024 AS DECIMAL(8,2)) FROM sys.master_files WITH(NOWAIT) WHERE database_id = DB_ID() -- for current db GROUP BY database_id"; var model = AdminDb.ExecuteQuery <DbCounter>(size).ToList().Single(); model.StatCounters = counters; return(View(model)); } catch (Exception ex) { return(View(new DbCounter() { Databasename = "Function not available" })); } }
protected void btnAddCity_Click(object sender, EventArgs e) { AdminDb.AddCity(Convert.ToInt32(ddSelectNewState.SelectedValue), tbNewCityName.Text, cbNewMajorCity.Checked, Session["UserName"].ToString()); pnlAddCity.Visible = false; pnlBackdrop.Visible = false; BindDataToGridView(); }
public SprocTests() : base() { var tableName = "Game"; db.Execute( new Table(tableName) .AddColumn("Id", SqlType.Int, Syntax.Identity(1, 1)) .AddColumn("Title", SqlType.VarChar(100), Syntax.NotNull) .AddColumn("Html", SqlType.VarCharMax, Syntax.NotNull) .AddColumn("DateCreated", SqlType.DateTime, Syntax.NotNull) .End().Sql ); var admin = new AdminDb(db); admin.ExecuteRaw($@"DROP PROCEDURE IF EXISTS GetGames"); admin.ExecuteRaw($"CREATE PROCEDURE GetGames AS SELECT * FROM {tableName}"); admin.ExecuteRaw($@"DROP PROCEDURE IF EXISTS GetGamesByDateCreated"); admin.ExecuteRaw($@"CREATE PROCEDURE GetGamesByDateCreated(@DateCreated DATETIME) AS SELECT * FROM {tableName} WHERE DateCreated > @DateCreated"); admin.ExecuteRaw($@"DROP PROCEDURE IF EXISTS GetGameById"); admin.ExecuteRaw( $@"CREATE PROCEDURE GetGameById(@Id INT) AS BEGIN SELECT * FROM {tableName} WHERE Id = @Id END"); db.Insert(new Game() { Title = "A", Html = "B" }); }
protected void btnSave_Click(object sender, EventArgs e) { AdminDb.UpdateListing( Convert.ToInt32(lbListingId.Text), Convert.ToInt32(ddCity.SelectedValue), Convert.ToInt32(ddSubCategory.SelectedValue), tbHeadline.Text, tbLocation.Text, tbDescription.Text, Convert.ToDouble(tbPrice.Text), cbIsActive.Checked ); //clear form lbListingId.Text = ""; tbHeadline.Text = ""; tbLocation.Text = ""; lbUserID.Text = ""; tbPrice.Text = ""; tbDescription.Text = ""; cbIsActive.Checked = false; BindDataToGridView(); pnlListingEdit.Visible = false; pnlBackdrop.Visible = false; }
protected void btnSave_Click(object sender, EventArgs e) { AdminDb.UpdateUser( Convert.ToInt32(lbUserId.Text), tbFirstName.Text, tbLastName.Text, tbEmail.Text, tbPhoneNum.Text, cbIsAdmin.Checked, cbIsActive.Checked ); //clear form lbUserId.Text = ""; tbFirstName.Text = ""; tbLastName.Text = ""; tbEmail.Text = ""; tbPhoneNum.Text = ""; cbIsAdmin.Checked = false; cbIsActive.Checked = false; pnlUserEdit.Visible = false; pnlBackdrop.Visible = false; BindDataToGridView(); }
protected void gvUsers_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditUser") { int userID = Convert.ToInt32(e.CommandArgument); DataTable userTable = AdminDb.GetUserByID(userID); DataRow row = userTable.Rows[0]; lbUserId.Text = userID.ToString(); tbFirstName.Text = row["FirstName"].ToString(); tbLastName.Text = row["LastName"].ToString(); tbEmail.Text = row["Email"].ToString(); tbPhoneNum.Text = row["PhoneNum"].ToString(); cbIsActive.Checked = Convert.ToBoolean(row["Active"]); cbIsAdmin.Checked = Convert.ToBoolean(row["Admin"]); pnlUserEdit.Visible = true; pnlBackdrop.Visible = true; } else if (e.CommandName == "DeleteUser") { int userID = Convert.ToInt32(e.CommandArgument); AdminDb.DeleteUser(userID); BindDataToGridView(); } }
public ActionResult DeleteConfirmed(int id) { Team team = AdminDb.Teams.Find(id); AdminDb.Teams.Remove(team); AdminDb.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { var user = AdminDb.Users.Find(id); AdminDb.Users.Remove(user); AdminDb.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { CmsMedia media = AdminDb.Media.Find(id); AdminDb.Media.Remove(media); AdminDb.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { var tenant = AdminDb.Tenants.Find(id); AdminDb.Tenants.Remove(tenant); AdminDb.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { CmsPage cmspage = AdminDb.Pages.Find(id); AdminDb.Pages.Remove(cmspage); AdminDb.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { CmsMenu cmsmenu = AdminDb.Menus.Find(id); AdminDb.Menus.Remove(cmsmenu); AdminDb.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { Role role = AdminDb.Roles.Find(id); AdminDb.Roles.Remove(role); AdminDb.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { AddressBook addressbook = AdminDb.AddressBook.Find(id); AdminDb.AddressBook.Remove(addressbook); AdminDb.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { var orderstore = AdminDb.OrderProducts.Find(id); AdminDb.OrderProducts.Remove(orderstore); AdminDb.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { Catalog catalog = AdminDb.Catalog.Find(id); AdminDb.Catalog.Remove(catalog); AdminDb.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { Project project = AdminDb.Projects.Find(id); AdminDb.Projects.Remove(project); AdminDb.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Name,StreetNumber,Zip,City,Region,Default,Invoice,CreatedAt,ModifiedAt")] AddressBook addressbook) { if (ModelState.IsValid) { AdminDb.Entry(addressbook).State = EntityState.Modified; AdminDb.SaveChanges(); return(RedirectToAction("Index")); } return(View(addressbook)); }
public ActionResult Edit(CmsPage cmspage) { if (ModelState.IsValid) { AdminDb.Entry(cmspage).State = EntityState.Modified; AdminDb.SaveChanges(); return(RedirectToAction("Index")); } return(View(cmspage)); }
public void OnSaveClicked(object sender, EventArgs args) { adminDb = new AdminDb(); admin.AdminName = txtAdminName.Text; admin.Username = txtUsername.Text; admin.Email = txtEmail.Text; admin.Password = txtPassword.Text; adminDb.EditAdmin(admin); Navigation.PushAsync(new ManageAdmins()); }
public ManageAdmins() { InitializeComponent(); _database = new AdminDb(); var admins = _database.GetAllAdmins(); lstData.ItemsSource = admins; }
public ActionResult Edit(Project project) { if (ModelState.IsValid) { AdminDb.Entry(project).State = EntityState.Modified; AdminDb.SaveChanges(); return(RedirectToAction("Index")); } return(View(project)); }
public ActionResult Create(Team team) { if (ModelState.IsValid) { AdminDb.Teams.Add(team); AdminDb.SaveChanges(); return(RedirectToAction("Index")); } return(View(team)); }
public ActionResult Create(Catalog catalog) { if (ModelState.IsValid) { AdminDb.Catalog.Add(catalog); AdminDb.SaveChanges(); return(RedirectToAction("Index")); } return(View(catalog)); }
public ActionResult Create(Project project) { if (ModelState.IsValid) { AdminDb.Projects.Add(project); AdminDb.SaveChanges(); return(RedirectToAction("Index")); } return(View(project)); }
public ActionResult Create(CmsMenu cmsmenu) { if (ModelState.IsValid) { AdminDb.Menus.Add(cmsmenu); AdminDb.SaveChanges(); return(RedirectToAction("Index")); } return(View(cmsmenu)); }
public ActionResult Create(Role role) { if (ModelState.IsValid) { AdminDb.Roles.Add(role); AdminDb.SaveChanges(); return(RedirectToAction("Index")); } return(View(role)); }
public ActionResult Create(CmsPage cmspage) { if (ModelState.IsValid) { AdminDb.Pages.Add(cmspage); AdminDb.SaveChanges(); return(RedirectToAction("Index")); } return(View(cmspage)); }
protected void ddCategory_SelectedIndexChanged(object sender, EventArgs e) { if (ddCategory != null && ddCategory.SelectedIndex > 0 && ddSubCategory != null) { int selCategoryId = Convert.ToInt32(ddCategory.SelectedValue); ddSubCategory.DataSource = AdminDb.GetSubcategoriesByCategory(selCategoryId); ddSubCategory.DataTextField = "SubCategoryName"; ddSubCategory.DataValueField = "SubCategoryID"; ddSubCategory.DataBind(); } }
protected void ddState_SelectedIndexChanged(object sender, EventArgs e) { if (ddState != null && ddState.SelectedIndex > 0 && ddCity != null) { int selStateId = Convert.ToInt32(ddState.SelectedValue); ddCity.DataSource = AdminDb.GetCitiesByState(selStateId); ddCity.DataTextField = "CityName"; ddCity.DataValueField = "CityID"; ddCity.DataBind(); } }