示例#1
0
 public ExcelXMLLayout(ExcelSolution solution)
 {
     m_primary = "id";
     m_primary_comment = "";
     m_typed = true;
     m_path = "样例.xml";
     m_allkey = new List<KeyPair>(10);
     m_solution = solution;
     m_name = "sample";
     m_sheet = "Sheet1";
 }
示例#2
0
        public bool Load(string file = "config.xml")
        {
            try
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

                doc.Load(file);
                System.Xml.XmlNode root = doc.SelectSingleNode("root");
                m_solutions.Clear();
                foreach (System.Xml.XmlNode xls in root.SelectNodes("excel"))
                {
                    ExcelSolution solu = new ExcelSolution(this);
                    solu.name = xls.Attributes["name"].Value;
                    solu.path = xls.Attributes["path"].Value;

                    foreach (System.Xml.XmlNode layoutNode in xls.SelectNodes("layout"))
                    {
                        ExcelXMLLayout layout = new ExcelXMLLayout(solu);
                        layout.path = layoutNode.Attributes["path"].Value;
                        layout.sheet = layoutNode.Attributes["sheet"].Value;
                        layout.name = layoutNode.Attributes["name"].Value;
                        layout.summary = layoutNode.Attributes["summary"].Value;
                        layout.typed = bool.Parse(layoutNode.Attributes["typed"].Value);
                        try { layout.primary = layoutNode.Attributes["primary"].Value; }
                        catch (Exception) { }
                        try { layout.primaryComment = layoutNode.Attributes["primary-comment"].Value; }
                        catch (Exception) { }

                        foreach (System.Xml.XmlNode column in layoutNode.SelectNodes("column"))
                        {
                            layout.Add(
                                column.InnerText,
                                (ExcelXMLLayout.KeyType)Enum.Parse(typeof(ExcelXMLLayout.KeyType), column.Attributes["type"].Value)
                            );
                        }
                        solu.AddLayout(layout);
                    }

                    AddSolution(solu);
                }
                return true;
            }
            catch (Exception err)
            {
                System.Diagnostics.Debug.WriteLine(err.Message);
            }
            return false;
        }
示例#3
0
        private void 添加ExcelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DB.ExcelSolution solu = new DB.ExcelSolution(mgr);

            mgr.AddSolution(solu);
            Util_AddExcelSolution(tvExcel.SelectedNode, solu);
        }
示例#4
0
        private void tvExcel_AfterSelect(object sender, TreeViewEventArgs e)
        {
            txtColumnName.Enabled = false;

            if (e.Node.Tag is DB.ExcelXMLLayout)
            {
                CurrentLayout = e.Node.Tag as DB.ExcelXMLLayout;
                CurrentSolution = CurrentLayout.solution;
            }
            else if (e.Node.Tag is DB.ExcelSolution)
            {
                CurrentLayout = null;
                CurrentSolution = e.Node.Tag as DB.ExcelSolution;
            }
            else
            {
                CurrentLayout = null;
                CurrentSolution = null;

                if (e.Node.Tag is DB.ExcelXMLLayout.KeyPair)
                {
                    txtColumnName.Text = (e.Node.Tag as DB.ExcelXMLLayout.KeyPair).name;
                    txtColumnName.Enabled = true;
                }
            }
            Util_ShowLayout();
            Util_ShowSolution();
        }
示例#5
0
 public void RemoveSolution(ExcelSolution solu)
 {
     m_solutions.Remove(solu);
 }
示例#6
0
 public void AddSolution(ExcelSolution solu)
 {
     m_solutions.Add(solu);
 }