Esempio n. 1
0
        // store current data present on datagrid into inter table
        public void SaveDataToInterTable(ObservableCollection <Subject> gridData)
        {
            string IID = GetIID();  // get IID
            List <SubjectInterTable> updatedSubjects = new List <SubjectInterTable>();

            // Construct data to store into Inter Table
            foreach (var data in gridData)
            {
                SubjectInterTable subject = new SubjectInterTable()
                {
                    IID  = IID,
                    Id   = data.Id,
                    Name = data.Name,
                    SubjectCategoryId = (int)data.SubjectCategoryId,
                    Status            = (bool)data.Status
                };
                updatedSubjects.Add(subject);
            }
            try
            {
                using (demoEntities db = new demoEntities())
                {
                    // Finally, Store the data into Inter Table
                    foreach (var subjectData in updatedSubjects)
                    {
                        int success = db.SaveDataToInterTable(subjectData.IID, subjectData.Id, subjectData.Name, subjectData.SubjectCategoryId, subjectData.Status);
                    }
                    // Call Store Procedure to sync data between Inter_Table and Subject_Master Table
                    var result = db.Merge_SubjectMaster_SubjectInterTable(IID);
                }
            }
            catch (Exception ex)
            {
            }
        }