public int SpareIncomeCreate(spare_income _obj, string AccountName, string WarehouseName, string CurrencyCode) { objDataContext = new DriveEntities(); _obj.is_remains_input = 0; if (AccountName.Length > 0) _obj.account = objDataContext.accounts.FirstOrDefault(i => i.name == AccountName); _obj.warehouse = objDataContext.warehouses.FirstOrDefault(i => i.name == WarehouseName); _obj.currency = objDataContext.currencies.FirstOrDefault(i => i.code == CurrencyCode); objDataContext.AddTospare_income(_obj); objDataContext.SaveChanges(); return _obj.id; }