Пример #1
0
        public ActionResult Create(FormCollection formCollection, string tableName = "")
        {
            DataViewModel model = new DataViewModel();
            model.tableName = tableName;

            string statement = "INSERT INTO " + tableName + " (";

            // Assuming [0] is the __RequestVerificationToken
            for (int i = 1; i < formCollection.AllKeys.Count(); i++)
            {
                statement += formCollection.AllKeys[i];
                if (i < formCollection.AllKeys.Count() - 1)
                {
                    statement += ", ";
                }
            }
            statement += ") VALUES (";

            // Assuming [0] is the __RequestVerificationToken
            for (int i = 1; i < formCollection.AllKeys.Count(); i++)
            {
                statement += "'" + formCollection[formCollection.AllKeys[i]] + "'";
                if (i < formCollection.AllKeys.Count() - 1)
                {
                    statement += ", ";
                }
            }
            statement += ")";
            db.executeStatement(statement);

            return View(model);
        }
Пример #2
0
        public ActionResult Create(string tableName = "")
        {
            DataViewModel model = new DataViewModel();
            model.tableName = tableName;
            string statement = "SELECT column_name, data_type "
                               + "FROM information_schema.columns"
                               + " WHERE table_name = '" + tableName + "'";

            model.table = db.getTableFromStatement(statement);

            return View(model);
        }
Пример #3
0
        public ActionResult Delete(string tableName = "", string id = "")
        {
            DataViewModel model = new DataViewModel();
            model.tableName = tableName;
            model.id = id;
            string statement = "SELECT column_name, data_type "
                               + "FROM information_schema.columns"
                               + " WHERE table_name = '" + tableName + "'";
            model.table = db.getTableFromStatement(statement);

            statement = "SELECT * FROM " + tableName + " WHERE ID = " + id;
            model.valuesTable = db.getTableFromStatement(statement);

            return View(model);
        }
Пример #4
0
        public ActionResult Delete(FormCollection formCollection, string tableName = "", string id = "")
        {
            DataViewModel model = new DataViewModel();
            model.tableName = tableName;
            model.id = id;
            string statement = "DELETE FROM " + tableName + " WHERE ID = " + id;
            db.executeStatement(statement);

            return View(model);
        }
Пример #5
0
        public ActionResult Index(DataViewModel model)
        {
            if (ModelState.IsValid)
            {
                model.table = db.getTableFromParameters(model.columnList, model.tableName);
            }

            return View(model);
        }
Пример #6
0
        public ActionResult Index()
        {
            DataViewModel model = new DataViewModel();
            model.tableName = "Users";
            model.table = db.getTableFromParameters(model.columnList, model.tableName);

            return View(model);
        }
Пример #7
0
        public ActionResult Edit(FormCollection formCollection, string tableName = "", string id = "")
        {
            DataViewModel model = new DataViewModel();
            model.tableName = tableName;
            model.id = id;
            string statement = "UPDATE " + tableName + " SET ";

            // Assuming [0] is the __RequestVerificationToken
            for (int i = 1; i < formCollection.AllKeys.Count(); i++)
            {
                statement += formCollection.AllKeys[i] + "=";
                statement += "'" + formCollection[formCollection.AllKeys[i]] + "'";
                if (i < formCollection.AllKeys.Count() - 1)
                {
                    statement += ", ";
                }
            }
            statement += " WHERE ID = " + id;
            db.executeStatement(statement);

            return View(model);
        }