Пример #1
0
 private void toolStripBackUp_Click(object sender, EventArgs e)
 {
     //检查文件是否存在
     if (!(File.Exists(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"//myContacts_BackUp.xml")))
     {
         StudentInfoBLL.CreateXml(StudentInfoBLL.Return_BackUpPath());
         if (StudentInfoBLL.ChangeXml(StudentInfoBLL.Return_BasePath(), StudentInfoBLL.Return_BackUpPath()))
         {
             MessageBox.Show("备份成功!");
         }
     }
     else if (MessageBox.Show("已有备份文件,是否覆盖?", "Confirm Message", MessageBoxButtons.OKCancel) == DialogResult.OK)
     {
         if (StudentInfoBLL.ChangeXml(StudentInfoBLL.Return_BasePath(), StudentInfoBLL.Return_BackUpPath()))
         {
             MessageBox.Show("备份成功");
         }
     }
 }
Пример #2
0
        void InitContacts()//初始化,获取文件信息
        {
            if (File.Exists(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"//myContacts.xml"))
            {
                dataGridView1.DataSource = StudentInfoBLL.GetAllContactsInfo(StudentInfoBLL.Return_BasePath());
            }
            else
            {
                StudentInfoBLL.CreateXml(StudentInfoBLL.Return_BasePath());
                dataGridView1.DataSource = StudentInfoBLL.GetAllContactsInfo(StudentInfoBLL.Return_BasePath());
            }

            dataGridView1.Columns[0].HeaderText = "学生编号";
            dataGridView1.Columns[1].HeaderText = "学生姓名";
            dataGridView1.Columns[2].HeaderText = "学生性别";
            dataGridView1.Columns[3].HeaderText = "专业";
            dataGridView1.Columns[4].HeaderText = "学生年龄";
            dataGridView1.Columns[5].HeaderText = "出生日期";
            dataGridView1.Columns[6].HeaderText = "手机号码";
            dataGridView1.Columns[7].HeaderText = "电子邮箱";
            dataGridView1.Columns[8].HeaderText = "家庭住址";
        }