예제 #1
0
 /// <summary>
 /// Update an existing item in the Project List
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static void Update(Project item)
 {
     Project toUpdate = AllProjects.Find(proj => proj.Id == item.Id);
     toUpdate = new Project()
     {
         ConnectionStringDestination = item.ConnectionStringDestination,
         ConnectionStringSource = item.ConnectionStringSource,
         Id = item.Id,
         Name = item.Name,
         Type = item.Type,
         WasLastUsed = item.WasLastUsed
     };
 }
예제 #2
0
 private void OpenProject()
 {
     
         if (listView1.SelectedItems.Count != 0)
         {
             Project item = new Project();
             item.ConnectionStringDestination = projects[listView1.SelectedItems[0].Index].ConnectionStringDestination;
             item.ConnectionStringSource = projects[listView1.SelectedItems[0].Index].ConnectionStringSource;
             item.Id = projects[listView1.SelectedItems[0].Index].Id;
             item.Name = projects[listView1.SelectedItems[0].Index].Name;
             item.Type = projects[listView1.SelectedItems[0].Index].Type;
             if (OnSelect != null)
                 OnSelect(item);
         }                                     
 }
예제 #3
0
 private void form_OnRename(Project itemSelected)
 {
     Project.Save(itemSelected);
 }
예제 #4
0
 private void form_OnSelect(Project itemSelected)
 {
     try
     {
         if (itemSelected != null)
         {
             ActiveProject = itemSelected;
             mySqlConnectFront1.ConnectionString = itemSelected.ConnectionStringSource;
             mySqlConnectFront2.ConnectionString = itemSelected.ConnectionStringDestination;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #5
0
 private void form_OnRename(Project itemSelected)
 {
     try
     {
         Project.Save(itemSelected);
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #6
0
 private void form_OnDelete(Project itemSelected)
 {
     try
     {
         Project.Delete(itemSelected.Id);
         if (ActiveProject != null)
         {
             if (ActiveProject.Id == itemSelected.Id)
             {
                 ActiveProject = null;
                 mySqlConnectFront1.ConnectionString = "";
                 mySqlConnectFront2.ConnectionString = "";
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #7
0
 private void button1_Click_1(object sender, EventArgs e)
 {
     try
     {
         if (ActiveProject == null)
         {
             ActiveProject = new Project
                                 {
                                     ConnectionStringSource = mySqlConnectFront1.ConnectionString,
                                     ConnectionStringDestination = mySqlConnectFront2.ConnectionString,
                                     Name = String.Format("[{0}].[{1}] - [{2}].[{3}]",
                                                 ((SqlServerConnectFront)mySqlConnectFront1).ServerName,
                                                 mySqlConnectFront1.DatabaseName,
                                                 ((SqlServerConnectFront)mySqlConnectFront2).ServerName,
                                                 mySqlConnectFront2.DatabaseName),
                                     Type = Project.ProjectType.SQLServer
                                 };
         }
         ActiveProject.Id = Project.Save(ActiveProject);
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #8
0
파일: Project.cs 프로젝트: pclancy/ODBX
 private static int Add(Project item)
 {
     int maxId = 0;
     Project.DoSqlSomething(
         "SELECT MAX(ProjectId) AS NewId FROM Project WHERE Internal = 0",
         reader => maxId = int.Parse(reader["NewId"].ToString()),
         "INSERT INTO Project (Name, ConnectionStringSource, ConnectionStringDestination, Options, Type, Internal) VALUES ('" + item.Name.Replace("'","''") + "','" + item.ConnectionStringSource + "','" + item.ConnectionStringDestination + "','" + item.Options + "'," + ((int) item.Type).ToString() + ",0)");
     return maxId;
 }
예제 #9
0
 private void btnNewProject_Click(object sender, EventArgs e)
 {
     mySqlConnectFront1.ConnectionString = "";
     mySqlConnectFront2.ConnectionString = "";
     ActiveProject = null;
 }
예제 #10
0
 /// <summary>
 /// Add a Project to the list in the databse
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static void Add(Project item)
 {
     AllProjects.Add(item);
 }
예제 #11
0
        public static void SaveLastConfiguration(string ConnectionStringSource, string ConnectionStringDestination)
        {
            Project lastUsedProject = AllProjects.Find(proj => proj.ConnectionStringSource.ToLower() == ConnectionStringSource.ToLower() && proj.ConnectionStringDestination.ToLower() == ConnectionStringDestination.ToLower());
            AllProjects.ForEach(proj => proj.WasLastUsed = false);

            if (lastUsedProject == null)
            {
                lastUsedProject = new Project() 
                { 
                    ConnectionStringDestination = ConnectionStringDestination, 
                    ConnectionStringSource = ConnectionStringSource, 
                    Type = ProjectType.SQLServer, 
                    WasLastUsed = true
                };
                lastUsedProject.Id = Project.AllProjects.Count + 1;
                Add(lastUsedProject);
            }
            else
            {
                lastUsedProject.WasLastUsed = true;
                lastUsedProject.ConnectionStringSource = ConnectionStringSource;
                lastUsedProject.ConnectionStringDestination = ConnectionStringDestination;
                Update(lastUsedProject);
            }

            //Serialize the changes back down to disk
            Serialize();
        }
예제 #12
0
파일: Project.cs 프로젝트: pclancy/ODBX
 public static Project GetLastConfiguration()
 {
     Project item = null;
     Project.DoSqlSomething(
         "SELECT * FROM Project WHERE Internal = 1 ORDER BY Name",
         reader => item = new Project
             {
                 Id = int.Parse(reader["ProjectId"].ToString()),
                 ConnectionStringSource = reader["ConnectionStringSource"].ToString(),
                 ConnectionStringDestination = reader["ConnectionStringDestination"].ToString(),
                 Type = (ProjectType)(long)reader["Type"],
                 //Options = (SqlOption) reader["Options"],
                 Name = reader["Name"].ToString()
             });
     return item;
 }
예제 #13
0
파일: Project.cs 프로젝트: pclancy/ODBX
 private static int Update(Project item)
 {
     Project.DoSqlSomething(
         "UPDATE Project SET Name = '" + item.Name.Replace("'","''") + "', ConnectionStringSource = '" + item.ConnectionStringSource + "', ConnectionStringDestination = '" + item.ConnectionStringDestination + "', Type = " + ((int)item.Type).ToString() + " WHERE ProjectId = " + item.Id.ToString(),
         null);
     return item.Id;
 }
예제 #14
0
 private void form_OnDelete(Project itemSelected)
 {
     Project.Delete(itemSelected.Id);
     if (ActiveProject != null)
     {
         if (ActiveProject.Id == itemSelected.Id)
         {
             ActiveProject = null;
             mySqlConnectFront1.ConnectionString = "";
             mySqlConnectFront2.ConnectionString = "";
         }
     }
 }
예제 #15
0
        /// <summary>
        /// Save an item, decide whether to insert or update.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public static void Save(Project item)
        {
            Project projectToSave = AllProjects.Find(proj => proj.Id == item.Id);

            if (projectToSave == null)
            {
                item.Id = Project.AllProjects.Count + 1;
                Add(item);
            }
            else
                Update(projectToSave);

            Serialize();
        }
예제 #16
0
 private void form_OnSelect(Project itemSelected)
 {
     if (itemSelected != null)
     {
         ActiveProject = itemSelected;
         mySqlConnectFront1.ConnectionString = itemSelected.ConnectionStringSource;
         mySqlConnectFront2.ConnectionString = itemSelected.ConnectionStringDestination;
     }
 }
예제 #17
0
 private void OpenProject()
 {
     try
     {
         if (listView1.SelectedItems.Count != 0)
         {
             Project item = new Project();
             item.ConnectionStringDestination = projects[listView1.SelectedItems[0].Index].ConnectionStringDestination;
             item.ConnectionStringSource = projects[listView1.SelectedItems[0].Index].ConnectionStringSource;
             item.Id = projects[listView1.SelectedItems[0].Index].Id;
             item.Name = projects[listView1.SelectedItems[0].Index].Name;
             item.Options = projects[listView1.SelectedItems[0].Index].Options;
             item.Type = projects[listView1.SelectedItems[0].Index].Type;
             if (OnSelect != null)
                 OnSelect(item);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #18
0
        private void btnSaveProject_Click(object sender, EventArgs e)
        {
            if (ActiveProject == null)
            {
                ActiveProject = new Project
                {
                    ConnectionStringSource = mySqlConnectFront1.ConnectionString,
                    ConnectionStringDestination = mySqlConnectFront2.ConnectionString,
                    Name = mySqlConnectFront1.DatabaseName + " - " + mySqlConnectFront2.DatabaseName,
                    Type = Project.ProjectType.SQLServer
                };
            }
            Project.Save(ActiveProject);

        }
예제 #19
0
파일: Project.cs 프로젝트: pclancy/ODBX
        public static int Save(Project item)
        {
            if (item.Id == 0)
                return Add(item);

            return Update(item);
        }