/** * 23.员工新建入库登记表 * 参数:员工Id * 返回:一个新添加的入库登记表(通过测试) //个人感觉这个不需要修改库存,在添加细节的时候再修改库存------->请注意 */ public inBase addNewIn(string inStaffId){ string currentShopId = getShopIdByStaffId(inStaffId); using (YMDBEntities db = new YMDBEntities()) { try { string newId = createNewId("inBase"); inBase newInBase = new inBase { inId = newId, shopId = currentShopId, staffId = inStaffId, inTime = DateTime.Now, }; db.inBase.Add(newInBase); db.SaveChanges(); return newInBase; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("添加入库失败."); System.Diagnostics.Debug.WriteLine(ex.StackTrace); return null; } } }
/** * 61.增加商店入库记录(测试通过) * 参数:员工Id * 返回值:入库记录 */ public inBase addNewInBaseRecord(string staffId) { string shopId = getShopIdByStaffId(staffId); string newId = createNewId("inBase"); using (YMDBEntities db = new YMDBEntities()) { try { inBase newInBase = new inBase { inId = newId, shopId = shopId, staffId = staffId, inTime = DateTime.Now, }; db.inBase.Add(newInBase); db.SaveChanges(); return newInBase; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("没找到shopId导致完整性约束不满足,拒绝插入数据库,请检查staffId."); System.Diagnostics.Debug.WriteLine(ex.StackTrace); return null; } } }