private void btnImportData_Click(object sender, EventArgs e) { string id = txtID.Text.Trim(); using (var db = new NeoNoticeWorkEntities()) { List <string> nameList = GetHtmlContent(id); foreach (string name in nameList) { InspirationalQuotes model = new InspirationalQuotes(); model.Name = name; db.InspirationalQuotes.Add(model); } db.SaveChanges(); MessageBox.Show("导入成功!"); } }
/// <summary> /// Handles the Click event of the btnOK control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void btnOK_Click(object sender, EventArgs e) { using (NeoNoticeWorkEntities entity = new NeoNoticeWorkEntities()) { NoticeLog model = new NoticeLog(); model.BeginTime = BeginTime; model.EndTime = EndTime; model.CreateTime = DateTime.Now; model.Remark = txtRemark.Text.Trim(); model.TagID = (int)cbTags.SelectedValue; model.TagName = cbTags.Text; entity.NoticeLog.Add(model); entity.SaveChanges(); this.Close(); System.Media.SoundPlayer player = new System.Media.SoundPlayer(); player.SoundLocation = Application.StartupPath + "//sound.wav"; player.Load(); player.Stop(); } }