예제 #1
0
파일: QueryUI.cs 프로젝트: Zexks/QLite
 public void SetQuery(Query query)
 {
     string[] answers = new string[query.Variables.Count];
     for (int i = 0; i < query.Variables.Count; i++)
         if (QDialog.InputBox("Parameter " + (i + 1).ToString() + " of " + query.Variables.Count.ToString(), query.Variables[i].Question, ref answers[i]) == DialogResult.Cancel || answers[i] == "")
             answers[i] = query.Variables[i].Default;
     txtQuery.Text = String.Format(query.Text, answers);
 }
예제 #2
0
파일: QEngine_XML.cs 프로젝트: Zexks/QLite
        public static void AddQuery(Query query)
        {
            foreach (XmlNode node in Global.QliteDefaults.XmlDefaults.ChildNodes[0])
                if (node.Name.ToUpper() == "QUERIES")
                { node.AppendChild(CreateQueryNode(query)); break; }

            using (FileStream WRITER = new FileStream(Global.QliteDefaults.XmlFileName, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite))
            { Global.QliteDefaults.XmlDefaults.Save(WRITER); WRITER.Close(); }
        }
예제 #3
0
파일: QueryMenu.cs 프로젝트: Zexks/QLite
 public void MoveQuery(int target, QueryMenuItems menus, Query query)
 {
     _MenuItems[_MenuItems.IndexOf(menus[0])].QuerySet.RemoveAt(menus[0].QuerySet.IndexOf(query));
     if (target >= _MenuItems[_MenuItems.IndexOf(menus[1])].QuerySet.Count - 1)
     { _MenuItems[_MenuItems.IndexOf(menus[1])].QuerySet.Add(query); }
     else { _MenuItems[_MenuItems.IndexOf(menus[1])].QuerySet.Insert(target, query); }
     _MenuItems[_MenuItems.IndexOf(menus[0])].Update_QuerySet();
     _MenuItems[_MenuItems.IndexOf(menus[1])].Update_QuerySet();
     _MenuItems.UpdateIndex();
     AlignControls();
 }
예제 #4
0
파일: Query.cs 프로젝트: Zexks/QLite
 public bool CompareQuery(Query query)
 {
     if (Title != query.Title) return false;
     if (Text != query.Text) return false;
     if (Parent != query.Parent) return false;
     if (Index != query.Index) return false;
     if (query.Variables.Count != Variables.Count) return false;
     else for (int i = 0; i < Variables.Count; i++)
             if (!Variables[i].CompareVariable(query.Variables[i])) return false;
     return true;
 }
예제 #5
0
파일: QEngine_XML.cs 프로젝트: Zexks/QLite
 private static XmlNode CreateQueryNode(Query inQuery)
 {
     XmlNode newQueryNode = Global.QliteDefaults.XmlDefaults.CreateNode(XmlNodeType.Element, "Query", Global.QliteDefaults.XmlDefaults.NamespaceURI);
     newQueryNode.Attributes.Append(Global.QliteDefaults.XmlDefaults.CreateAttribute("Title"));
     newQueryNode.Attributes[0].Value = inQuery.Title;
     newQueryNode.Attributes.Append(Global.QliteDefaults.XmlDefaults.CreateAttribute("Type"));
     newQueryNode.Attributes[1].Value = inQuery.Parent.ToString();
     newQueryNode.Attributes.Append(Global.QliteDefaults.XmlDefaults.CreateAttribute("Index"));
     newQueryNode.Attributes[2].Value = inQuery.Index.ToString();
     newQueryNode.AppendChild(Global.QliteDefaults.XmlDefaults.CreateCDataSection(inQuery.Text));
     foreach (QueryVariable var in inQuery.Variables)
     {
         XmlNode varNode = Global.QliteDefaults.XmlDefaults.CreateNode(XmlNodeType.Element, "Var", Global.QliteDefaults.XmlDefaults.NamespaceURI);
         varNode.Attributes.Append(Global.QliteDefaults.XmlDefaults.CreateAttribute("Default"));
         varNode.Attributes[0].Value = inQuery.Variables[inQuery.Variables.IndexOf(var)].Default;
         varNode.AppendChild(Global.QliteDefaults.XmlDefaults.CreateCDataSection(inQuery.Variables[inQuery.Variables.IndexOf(var)].Question));
         newQueryNode.AppendChild(varNode);
     }
     return newQueryNode;
 }
예제 #6
0
파일: QEngine_XML.cs 프로젝트: Zexks/QLite
 public static void UpdateQuery(Query newQuery, Query oldQuery)
 {
     foreach (XmlNode node in Global.QliteDefaults.XmlDefaults.ChildNodes[0])
         if (node.Name.ToUpper() == "QUERIES")
             foreach (XmlNode queryNode in node.ChildNodes)
                 foreach (XmlAttribute att in queryNode.Attributes)
                     if (att.Name.ToUpper() == "TITLE" && att.Value == oldQuery.Title)
                     { node.ReplaceChild(CreateQueryNode(newQuery), queryNode); goto Finish; }
     Finish:
     using (FileStream WRITER = new FileStream(Global.QliteDefaults.XmlFileName, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite))
     { Global.QliteDefaults.XmlDefaults.Save(WRITER); WRITER.Close(); }
 }
예제 #7
0
        public Query CreateQuery(XmlNode QueryNode)
        {
            Query tmpQuery = new Query();
            foreach (XmlAttribute att in QueryNode.Attributes)
                switch (att.Name.ToUpper())
                {
                    case "TITLE":
                        tmpQuery.Title = att.Value;
                        break;
                    case "TYPE":
                        tmpQuery.Parent = Convert.ToInt32(att.Value);
                        break;
                    case "INDEX":
                        tmpQuery.Index = Convert.ToInt32(att.Value);
                        break;
                }

            if (QueryNode.ChildNodes.Count > 1)
                for (int i = 1; i < QueryNode.ChildNodes.Count; i++)
                    tmpQuery.Variables.Add(CreateVariable(QueryNode.ChildNodes[i]));

            tmpQuery.Text = QueryNode.FirstChild.InnerText;
            return tmpQuery;
        }
예제 #8
0
파일: QXML.cs 프로젝트: Zexks/QLite
 public static void DeleteQuery(Query query)
 {
     foreach (XmlNode node in Global.Defaults.XmlDefaults.ChildNodes[0])
         if (node.Name.ToUpper() == "QUERIES")
             foreach (XmlNode queryNode in node.ChildNodes)
                 foreach (XmlAttribute att in queryNode.Attributes)
                     if (att.Name.ToUpper() == "TITLE")
                         if (att.Value.ToUpper() == query.Title.ToUpper())
                         { node.RemoveChild(queryNode); goto Finish; }
     Finish:
     using (FileStream WRITER = new FileStream(Global.Defaults.XmlFileName, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite))
     { Global.Defaults.XmlDefaults.Save(WRITER); WRITER.Close(); }
 }