コード例 #1
0
 public ActionResult Index4(Models.Constructor t)
 {
     string[] temp;
     if (t.DataType == "int")
     {
         temp = new string[4] {
             "int", t.NameCondition, t.IntCondition.ToString(), t.Sign
         };
     }
     else if (t.DataType == "double")
     {
         temp = new string[4] {
             "double", t.NameCondition, t.DoubleCondition.ToString(), t.Sign
         };
     }
     else if (t.DataType == "datetime")
     {
         temp = new string[4] {
             "datetime", t.NameCondition, t.DataTimeCondition.ToString(), t.Sign
         };
     }
     else
     {
         temp = new string[4] {
             "string", t.NameCondition, t.StringCondition.ToString(), null
         };
     }
     constructor.Conditions.Add(temp);
     return(View("Index5", constructor)); //отображение окна условий
 }
コード例 #2
0
 public ActionResult Index(string[] table)
 {
     TempData["ActiveConstructor"] = true;
     Models.Constructor c = new Models.Constructor {
         SelectedTables = table
     };
     c.Attributes = c.GetAttributes();
     return(View("Index2", c));
 }
コード例 #3
0
 public ActionResult Index2(Models.Constructor t) // получение выбранных атрибутов
 {
     constructor.SelectedAttributes = t.SelectedAttributes;
     constructor.References         = constructor.GetReferences();
     if (constructor.SelectedTables.Length == 1)
     {
         return(View("Index4", constructor));
     }
     return(View("Index3", constructor)); // отображение ссылок
 }
コード例 #4
0
 public ActionResult Index3(Models.Constructor c)
 {
     TempData["ActiveConstructor"] = true;
     return(View("Index4", c));
 }
コード例 #5
0
 public ActionResult Index2(Models.Constructor c)
 {
     TempData["ActiveConstructor"] = true;
     c.References = c.GetReferences();
     return(View("Index3", c));
 }
コード例 #6
0
        public ActionResult Index5(Models.Constructor t)
        {
            string str = "SELECT ";

            for (int i = 0; i < constructor.SelectedAttributes.Length; i++)
            {
                str += constructor.TranslateAttributes(constructor.SelectedAttributes[i]);
                if (i == constructor.SelectedAttributes.Length - 1)
                {
                    str += " ";
                }
                else
                {
                    str += ", ";
                }
            }
            str += "FROM ";
            for (int i = 0; i < constructor.SelectedTables.Length; i++)
            {
                str += constructor.TranslateTables(constructor.SelectedTables[i]);
                if (i == constructor.SelectedTables.Length - 1)
                {
                    str += " ";
                }
                else
                {
                    str += ", ";
                }
            }
            if (constructor.Conditions.Count() > 0 || constructor.SelectedReferences.Length > 0)
            {
                str += "WHERE ";
                if (constructor.Conditions.Count() > 0)
                {
                    for (int i = 0; i < constructor.Conditions.Count(); i++)
                    {
                        string[] el = constructor.Conditions[i];
                        str += constructor.TranslateAttributes(el[1]) + " ";
                        if (el[3] == null)
                        {
                            str += "= N\"" + el[2] + "\"";
                        }
                        else if (el[3] == "=")
                        {
                            str += "= " + el[2];
                        }
                        else
                        {
                            str += el[3] + " @" + i + " ";
                        }
                        str += " ";
                        if (constructor.SelectedReferences.Length > 0 || i != constructor.Conditions.Count() - 1)
                        {
                            str += "AND ";
                        }
                    }
                }
                if (constructor.SelectedReferences.Length > 0)
                {
                    for (int i = 0; i < constructor.SelectedReferences.Length; i++)
                    {
                        str += constructor.TranslateReferences(constructor.SelectedReferences[i]) + " ";
                        if (i != constructor.SelectedReferences.Length - 1)
                        {
                            str += " AND ";
                        }
                    }
                }
            }

            TempData["alertMessage"] = str;

            Models.ModelDBContainer db = new Models.ModelDBContainer();
            try
            {
                //if (constructor.Conditions.Count() > 0)
                //    for (int i = 0; i < constructor.Conditions.Count(); i++)
                //    {
                //        System.Data.SqlClient.SqlParameter param = new System.Data.SqlClient.SqlParameter("@name", "%Samsung%");
                //    }

                var res = db.Database.SqlQuery <object>(str);
            }
            catch (Exception ex)
            {
                TempData["alertMessage"] = str + " ERROR!!!";
            }
            db.Dispose();
            return(View("Index5", constructor));
        }
コード例 #7
0
 public ActionResult Index3(Models.Constructor t) //получение выбранных ссылок
 {
     constructor.SelectedReferences = t.SelectedReferences;
     constructor.Conditions         = new List <string[]>();
     return(View("Index4", constructor)); //отображение окна условий
 }