示例#1
0
        public ActionResult Show4Survey3(Survey3 n)
        {
            int ID = 0;
            SqlConnectionStringBuilder builder = ConnString();

            using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
            {
                connection.Open();
                String sql = DBQuery();

                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            ID = reader.GetInt32(0);
                        }
                    }
                }
            }

            using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
                using (SqlCommand command = connection.CreateCommand())
                {
                    command.CommandText = "UPDATE [dbo].[UserInfo] SET Culture='" + n.Genre + "' WHERE ID=" + ID;

                    connection.Open();
                    command.ExecuteNonQuery();
                    connection.Close();
                }
            ViewBag.Name = n.Genre;
            return(RedirectToAction("Show4Survey", "Home"));
        }
示例#2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Survey3 survey3 = db.Survey3.Find(id);

            db.Survey3.Remove(survey3);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#3
0
 public ActionResult Edit([Bind(Include = "Classification,ID,Century,Genre,ImageUrl")] Survey3 survey3)
 {
     if (ModelState.IsValid)
     {
         db.Entry(survey3).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(survey3));
 }
示例#4
0
        public ActionResult Create([Bind(Include = "Classification,ID,Century,Genre,ImageUrl")] Survey3 survey3)
        {
            if (ModelState.IsValid)
            {
                db.Survey3.Add(survey3);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(survey3));
        }
示例#5
0
        public ActionResult Show4Survey3(Survey3 n)
        {
            int    ID             = 0;
            string name           = "";
            string classification = "";
            string culture        = "";
            string century        = "";

            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();

            builder.DataSource     = "artserverfinal.database.windows.net";
            builder.UserID         = "finalproject";
            builder.Password       = "******";
            builder.InitialCatalog = "ArtInfo";

            using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
            {
                connection.Open();
                StringBuilder sb = new StringBuilder();
                sb.Append("SELECT TOP 1 [ID], [Name], [Classification], [Culture], [Century] ");
                sb.Append("FROM [dbo].[UserInfo] ");
                sb.Append("ORDER BY [ID] DESC");
                String sql = sb.ToString();

                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            ID   = reader.GetInt32(0);
                            name = reader.GetString(1);
                            //classification = reader.GetString(2);
                            //culture = reader.GetString(3);
                            //century = reader.GetString(4);
                        }
                    }
                }
            }

            using (SqlConnection connection = new SqlConnection(builder.ConnectionString))
                using (SqlCommand command = connection.CreateCommand())
                {
                    command.CommandText = "UPDATE [dbo].[UserInfo] SET Culture='" + n.Genre + "' WHERE ID=" + ID;

                    connection.Open();
                    command.ExecuteNonQuery();
                    connection.Close();
                }
            ViewBag.Name = n.Genre;
            return(RedirectToAction("Index", "Survey3"));
        }
示例#6
0
        // GET: Survey3/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Survey3 survey3 = db.Survey3.Find(id);

            if (survey3 == null)
            {
                return(HttpNotFound());
            }
            return(View(survey3));
        }