public ActionResult Save(string type, string code) { HiddenCode findOne = db.HiddenCode.Find(type, code); if (findOne == null) {//add findOne = new HiddenCode(); findOne.Name = code; TryUpdateModel <HiddenCode>(findOne); if (code == "不涉及" || code == "不限制") { findOne.InDateTime = DateTime.MaxValue; } else { findOne.InDateTime = DateTime.Now; } findOne.InUserId = UserInfo.UserId; db.HiddenCode.Add(findOne); } else { findOne.Name = code; TryUpdateModel <HiddenCode>(findOne); } db.SaveChanges(); return(Json(findOne)); }
public ActionResult EditChild(string type, string code) { HiddenCode findOne = new HiddenCode(); if (!string.IsNullOrEmpty(type)) { findOne = db.HiddenCode.Find(type, code); } return(PartialView("_PartialChildEdit", findOne)); }
// Called in receive mode when the user picks the code they think they heard. Scores their selection, pauses for two seconds, then re-runs receive mode. private void ScoreSelection() { comboCodeList.Visible = false; HiddenCode selCode = (HiddenCode)comboCodeList.SelectedItem; if (selCode.Code == ChosenCode) { correctCount++; CorrectUpdateScore(); } else { WrongUpdateScore(InstrumentMode.Receive); } Refresh(); Thread.Sleep(2000); ++doneCount; StartReceiveMode(); }
private void button2_Click(object sender, EventArgs e) { openFileDialog1.InitialDirectory = @"C:\Users\huohaitao\Desktop\导入需求书"; openFileDialog1.Multiselect = true; if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { using (var db = new PurchaseEntities()) { foreach (string filename in openFileDialog1.FileNames) { textBox1.Text = filename; MSExcelUtil msExcelUtil = new MSExcelUtil(); Workbook workbook = msExcelUtil.OpenExcelByMSExcel(filename); Worksheet sheet = workbook.ActiveSheet; int rowIndex = 2; string type = null; do { type = msExcelUtil.GetCellValue(sheet, 1, rowIndex); string content = msExcelUtil.GetCellValue(sheet, 2, rowIndex); string childChk = msExcelUtil.GetCellValue(sheet, 3, rowIndex); if (string.IsNullOrEmpty(content)) { continue; } string[] items = content.Split('/'); foreach (string item in items) { HiddenCode code = new HiddenCode(); code.Type = type.Trim(); code.Code = item.Trim(); code.Name = item.Trim(); if (item == "不限制" || item == "不涉及") { code.InDateTime = DateTime.MaxValue; } else { code.InDateTime = DateTime.Now; } code.InUserId = "sysadmin"; code.UseChk = true; if (db.HiddenCode.Find(type, item) == null) { db.HiddenCode.Add(code); } if (db.HiddenCodeType.Where(x => x.TypName == code.Type).Count() == 0) { db.HiddenCodeType.Add(new HiddenCodeType() { InDateTime = DateTime.Now, InUserId = "sysadmin", TypName = code.Type, ChildChk = string.IsNullOrEmpty(childChk) ? false : Convert.ToBoolean(childChk), }); db.SaveChanges(); } } rowIndex++; } while (!string.IsNullOrEmpty(type)); try { db.SaveChanges(); } catch (DbEntityValidationException dex) { MessageBox.Show(dex.Message); } MessageBox.Show("导入完成"); } } } }