protected void Page_Load(object sender, EventArgs e) { theStaff = (staff)Session["staff"]; System.Diagnostics.Debug.WriteLine("theStaff:" + theStaff.staffId); check checker = DBModel.sharedDBModel().addNewCheckRecord(theStaff.staffId); checkDetailTable = DBModel.sharedDBModel().getCheckDetailInfoWithStaffId(checker.checkId, theStaff.staffId); }
/** * 58.新增盘点记录(测试通过) * 参数:员工Id * 返回值:盘点记录 */ public check addNewCheckRecord(string staffId) { string shopId = getShopIdByStaffId(staffId); System.Diagnostics.Debug.WriteLine("shopIdhihif:" + shopId); string newCheckId = createNewId("check"); using (YMDBEntities db = new YMDBEntities()) { try { check newCheck = new check { checkerId = staffId, shopId = shopId, checkTime = DateTime.Now, checkId = newCheckId, }; db.check.Add(newCheck); db.SaveChanges(); return newCheck; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("没找到shopId导致完整性约束不满足,拒绝插入数据库,请检查staffId."); System.Diagnostics.Debug.WriteLine(ex.StackTrace); return null; } } }