コード例 #1
0
        private void ProAddBtn_Click(object sender, EventArgs e)
        {
            XmlOperator    xmlOperator = new XmlOperator();
            OpenFileDialog fileDialog  = new OpenFileDialog();

            //fileDialog.Multiselect = true;
            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                //MessageBox.Show(fileDialog.FileName);
                SerializableDictionary <int, StructureOfProblem> p = xmlOperator.readXML(fileDialog.FileName);
                if (this.Main_TreeView.Nodes.Count == 0 || this.Main_TreeView.SelectedNode == null)
                {
                    //this.Main_TreeView.Nodes.Add(NewProblemName);
                    foreach (int key in p.Keys)
                    {
                        TreeNode minnode = new TreeNode();
                        minnode.Text = ProblemList.GetProblem(key).QuestionName;
                        this.Main_TreeView.Nodes.Add(minnode);
                        ProblemList.Add(ProblemList.GetProblem(key));
                    }
                }
                else
                {
                    //this.Main_TreeView.SelectedNode.Nodes.Add(NewProblemName);
                    foreach (int key in p.Keys)
                    {
                        TreeNode minnode = new TreeNode();
                        minnode.Text = ProblemList.GetProblem(key).QuestionName;
                        this.Main_TreeView.SelectedNode.Nodes.Add(minnode);
                        ProblemList.Add(ProblemList.GetProblem(key));
                    }
                }
            }
        }
コード例 #2
0
 public ElectricityCharges()
 {
     this.Location      = new System.Drawing.Point(500, 500);
     this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
     InitializeComponent();
     //本地存在电费信息的文档 读取并展示
     if (File.Exists(Application.StartupPath.Substring(0, Application.StartupPath.Length - 10) + "\\Properties\\Search_Electricity\\dist\\" + "ElectInfo.txt"))
     {
         drawCurve(Application.StartupPath.Substring(0, Application.StartupPath.Length - 10) + "\\Properties\\Search_Electricity\\dist\\" + "ElectInfo.txt");
     }
     try
     {
         if (File.Exists(Application.StartupPath.Substring(0, Application.StartupPath.Length - 10) + "\\Properties\\Search_Electricity\\" + GlobalData.user.RoomId + "Info.xml"))
         {
             XmlOperator <ElectInfo> xmlOperator = new XmlOperator <ElectInfo>();
             ElectInfo info = xmlOperator.readXML(Application.StartupPath.Substring(0, Application.StartupPath.Length - 10) + "\\Properties\\Search_Electricity\\" + GlobalData.user.RoomId + "Info.xml");
             this.label5.Text          = info.Elect;
             this.dateTimePicker1.Text = info.Time;
         }
         this.label4.Text = GlobalData.user.RoomId + "";
     }
     catch (Exception e)
     {
         LogHelper.WriteLog(typeof(ElectricityCharges), e);
         MessageBox.Show("请先完善信息");
     }
 }
コード例 #3
0
        public InformationManage()
        {
            this.Location      = new System.Drawing.Point(500, 500);
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            InitializeComponent();
            if (!File.Exists("User//User" + GlobalData.stuId + ".xml"))
            {
                MessageBox.Show("第一次登录请完善信息");
            }
            User user = null;

            try
            {
                user = xmlOperator.readXML("User//User" + GlobalData.stuId + ".xml");
                this.nameInput.AppendText(user.Name.Length != 0 ? user.Name : "");
                this.jwxtPasswordInput.AppendText(user.Jwxtpassword.Length != 0 ? user.Jwxtpassword : "");
                this.stuIDInput.AppendText(!user.StudentId.Equals(0) ? user.StudentId + "" : "");
                this.schoolInput.AppendText(user.School.Length != 0 ? user.School : "");
                this.cardIDInput.AppendText(!user.StudentId.Equals(0) ? user.CardId + "" : "");
                this.passwordInput.AppendText(user.Password.Length != 0 ? user.Password : "");
                this.majorInput.AppendText(user.Major.Length != 0 ? user.Major : "");
                this.roomInput.AppendText(!user.RoomId.Equals(0) ? user.RoomId + "" : "");

                GlobalData.user = user;
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(typeof(InformationManage), ex);
            }
        }
コード例 #4
0
        public void XmlreadTest()
        {
            XmlOperator xmlOperator = new XmlOperator();
            SerializableDictionary <int, StructureOfProblem> p = xmlOperator.readXML("Problem//Problem.xml");

            Assert.IsTrue(p.ContainsKey(1));
            Assert.AreEqual("testing", p[1].QuestionDescription);
        }
コード例 #5
0
        public void InformationManageTest()
        {
            XmlOperator <User> xmlOperator = new XmlOperator <User>();
            User user = new User();

            user.Name         = "张锦亮";
            user.StudentId    = 2016052355;
            user.Jwxtpassword = "******";
            user.Major        = "软件工程";
            string   filename = "User//User" + user.StudentId.ToString() + ".xml";
            checkDir check    = new checkDir();

            check.check("User//");
            xmlOperator.saveXML(filename, user);
            Assert.IsTrue(File.Exists(filename));
            User resUser = xmlOperator.readXML(filename);

            Assert.AreEqual(user.Name, resUser.Name);
            Assert.AreEqual(user.Jwxtpassword, resUser.Jwxtpassword);
            Assert.AreEqual(user.Major, resUser.Major);
        }
コード例 #6
0
        public void readXMLTest()
        {
            if (Directory.Exists("User//"))
            {
                DirectoryInfo di = new DirectoryInfo("User//");
                di.Delete(true);
            }
                
            User user = new User();

            user.Name = "卓裕轩";
            //user.StudentId = 2016052355;
            user.Jwxtpassword = "******";
            user.Major        = "软件工程";
            XmlOperator p = new XmlOperator();

            p.XMLSerialized(user);
            User resUser = p.readXML("");

            Assert.AreEqual(user.Name, resUser.Name);
            Assert.AreEqual(user.Jwxtpassword, resUser.Jwxtpassword);
            Assert.AreEqual(user.Major, resUser.Major);
        }