private void btn_search_Click(object sender, EventArgs e) { if (cB_Search_Item.Text == string.Empty) { dGV_Search.DataSource = StudentInfoBLL.GetAllContactsInfo(StudentInfoBLL.Return_BasePath()); InitHeadTitle(); } else { if (textBox_Searchtext.Text != string.Empty) { StudentInfo contactSearch = new StudentInfo(); switch (cB_Search_Item.SelectedIndex) { case 0: contactSearch.ContactId = Int32.Parse(textBox_Searchtext.Text); break; case 1: contactSearch.Name = textBox_Searchtext.Text; break; } dGV_Search.DataSource = StudentInfoBLL.GetContactsList(contactSearch); InitHeadTitle(); } else { MessageBox.Show("请输入要查询的" + cB_Search_Item.Text); } } }
public FormSearch() { InitializeComponent(); dGV_Search.DataSource = StudentInfoBLL.GetAllContactsInfo(StudentInfoBLL.Return_BasePath()); InitHeadTitle(); }
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("备份成功"); } } }
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 = "家庭住址"; }