in Program.cs I add this code:
- services.AddDbContext<InventoryDbContext>(context => context.UseSqlServer(constr));
- services.AddScoped<IClassService, ClassService>();
- services.AddScoped<ICategoryService, CategoryService>();
in MDIForm I add this code:
- private readonly IClassService classService;
- private readonly ICategoryService categoryService;
- public MdiForm(IClassificationService classificationService, ICategoryService categoryService){
- this.classService = classService;
- this.categoryService = categoryService;}
then to show a category from MDI I do this code. But in order to add the classService from CategoryForm to Classification, it should be a part of CategoryForm.
from MDI Form to show CategoryForm:
- var categoryForm = new frmCategory(classService, categoryService);
- categoryForm.ShowDialog();
- from CategoryForm to show ClassForm:
- var classForm = new frmClass(classService);
- classForm .ShowDialog();