Exemplo n.º 1
0
        private void x_configurationGrid_AddingNewItem(object sender, AddingNewItemEventArgs e)
        {
            try
            {
                NewConfiguration          = new GroupMaterialPurposeMedium();
                NewConfiguration.Id       = 0;
                NewConfiguration.Group    = "";
                NewConfiguration.Material = "";
                NewConfiguration.Purpose  = "";
                NewConfiguration.Medium   = "";
                NewConfiguration.IsEdit   = true;
                var col = from t in context.d_Group_of_Study select t.Group_of_Study;
                NewConfiguration.ListGroup = col.ToList();
                col = from t in context.d_Material select t.material;
                NewConfiguration.ListMaterial = col.ToList();
                col = from t in context.d_Purpose_of_study select t.purpose;
                NewConfiguration.ListPurpose = col.ToList();
                col = from t in context.d_Medium select t.medium;
                NewConfiguration.ListMedium = col.ToList();

                e.NewItem = NewConfiguration;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemplo n.º 2
0
        //добавление существующих конфигураций
        private ObservableCollection <GroupMaterialPurposeMedium> FillConfiguration()
        {
            try
            {
                ObservableCollection <GroupMaterialPurposeMedium> myCol = new ObservableCollection <GroupMaterialPurposeMedium>();

                var elCol = context.d_Group_of_Study;

                if (elCol != null)
                {
                    foreach (var el in elCol)
                    {
                        var elCol2 = el.p_Group_Material;

                        foreach (var el2 in elCol2)
                        {
                            var elCol3 = el2.p_Group_Material_Purpose;

                            foreach (var el3 in elCol3)
                            {
                                var elCol4 = el3.p_Group_Material_Purpose_Medium;

                                foreach (var el4 in elCol4)
                                {
                                    GroupMaterialPurposeMedium item = new GroupMaterialPurposeMedium();

                                    item.Id       = el4.id;
                                    item.Group    = el.Group_of_Study;
                                    item.Material = el2.d_Material.material;
                                    item.Purpose  = el3.d_Purpose_of_study.purpose;
                                    item.Medium   = el4.d_Medium.medium;
                                    item.IsEdit   = false;
                                    myCol.Add(item);
                                }
                            }
                        }
                    }
                }

                return(myCol);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " " + ex.StackTrace);
                return(null);
            }
        }