public static FinancialForm GetFormById(int financialFormId) { FinancialForm entity = null; using (SmizeeContext Context = new SmizeeContext()) { entity = Context.FinancialForms.FirstOrDefault(f => f.FinancialFormID == financialFormId); // force context to get Form string code = entity.Form.Periodicity.Code; int functionalAreaID = entity.Form.FormType.FunctionalAreaID; } return(entity); }
public static bool CheckFormsByFormDate(int formId, int productionUnitId, DateTime formDate) { bool result = false; FinancialForm entity = null; using (SmizeeContext Context = new SmizeeContext()) { entity = Context.FinancialForms.FirstOrDefault(fef => (fef.FormID == formId) & (fef.ProductionUnitID == productionUnitId) & (fef.FormDate == formDate)); if (entity != null) { result = true; } } return(result); }
public static int CreateForm(int formId, int productionUnitId, int periodNumber, DateTime formDate) { int financialFormId = 0; FinancialForm entity = new FinancialForm(); using (var db = new Models.SmizeeContext()) { entity.FormID = formId; entity.StateID = 1; entity.ProductionUnitID = productionUnitId; entity.PeriodNumber = periodNumber; entity.FormDate = formDate; db.FinancialForms.Add(entity); db.SaveChanges(); financialFormId = entity.FinancialFormID; } return(financialFormId); }