Esempio n. 1
0
        //Save DataSet Method
        public void SaveAll()
        {
            // if there are changes
            if (this.HasChanges())
            {
                if (Employees.GetChanges(DataRowState.Added) != null ||
                    Employees.GetChanges(DataRowState.Modified) != null)
                {
                    try
                    {
                        DataServices.SaveTable(FileName, EmployeesSELECT,
                                               Employees.GetChanges(DataRowState.Added));
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.Message); }

                    try
                    {
                        DataServices.SaveTable(FileName, EmployeesSELECT,
                                               Employees.GetChanges(DataRowState.Modified));
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.Message); }
                }

                // if there are rows to add or update
                if (TaskEmployees.GetChanges(DataRowState.Added) != null ||
                    TaskEmployees.GetChanges(DataRowState.Modified) != null)
                {
                    try
                    {
                        DataServices.SaveTable(FileName, TaskEmployeesSELECT,
                                               TaskEmployees.GetChanges(DataRowState.Added));
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.Message); }

                    try
                    {
                        DataServices.SaveTable(FileName, TaskEmployeesSELECT,
                                               TaskEmployees.GetChanges(DataRowState.Modified));
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.Message); }
                }

                // if there are rows to write to database
                if (ProjectTasks.GetChanges() != null)
                {
                    try
                    {
                        DataServices.SaveTable(FileName, ProjectTasksSELECT,
                                               ProjectTasks.GetChanges());
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.Message); }

                    try
                    {
                        DataServices.SaveTable(FileName, ProjectTasksSELECT,
                                               ProjectTasks.GetChanges(DataRowState.Modified));
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.Message); }
                }

                if (Projects.GetChanges(DataRowState.Deleted) != null)
                {
                    try
                    {
                        DataServices.SaveTable(FileName, ProjectsSELECT,
                                               Projects.GetChanges(DataRowState.Deleted));
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.Message); }

                    try
                    {
                        DataServices.SaveTable(FileName, ProjectsSELECT,
                                               Projects.GetChanges(DataRowState.Modified));
                    }
                    catch (Exception ex)
                    { Console.WriteLine(ex.Message); }
                }
            }
        }
Esempio n. 2
0
 //Add Table Method
 private void AddTable(string select, string tableName)
 {
     Tables.Add(DataServices.GetTable(FileName, select, tableName));
 }