프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / Form / ID2DBSetting.cs @ b2e32d43

이력 | 보기 | 이력해설 | 다운로드 (4.13 KB)

1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Data;
5
using System.Drawing;
6
using System.Linq;
7
using System.Text;
8
using System.Threading.Tasks;
9
using System.Windows.Forms;
10
using Converter.SPPID.Properties;
11
using Converter.BaseModel;
12

    
13
namespace Converter.SPPID.Form
14
{
15
    public partial class ID2DBSetting : DevExpress.XtraBars.Ribbon.RibbonForm
16
    {
17
        public ID2DBSetting()
18
        {
19
            InitializeComponent();
20

    
21
            Project_Info _ProjectInfo = Project_Info.GetInstance();
22
            textBoxProjectDriectory.Text = Settings.Default.ProjectPath;
23
            radioGroup.SelectedIndex = Settings.Default.ProjectDBType;
24
            textBoxServerIP.Text = Settings.Default.ProjectServerIP;
25
            textBoxPort.Text = Settings.Default.ProjectPort;
26
            textBoxDBUser.Text = Settings.Default.ProjectDBUser;
27
            textBoxDBPassword.Text = Settings.Default.ProjectDBPassword;
28
        }
29

    
30
        private void radioGroup_SelectedIndexChanged(object sender, EventArgs e)
31
        {
32
            ChangeUI();
33
        }
34

    
35
        private void ChangeUI()
36
        {
37
            if (radioGroup.SelectedIndex == 0)
38
            {
39
                Size = new Size(415, 214);
40
                layoutControlInfo.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
41
            }
42
            else if (radioGroup.SelectedIndex == 1)
43
            {
44
                Size = new Size(415, 367);
45
                layoutControlInfo.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
46
            }
47
        }
48

    
49
        private void btnProjectDriectory_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
50
        {
51
            if (!string.IsNullOrWhiteSpace(textBoxProjectDriectory.Text))
52
            {
53
                xtraFolderBrowserDialog.SelectedPath = textBoxProjectDriectory.Text;
54
            }            
55
            if (xtraFolderBrowserDialog.ShowDialog() == DialogResult.OK)
56
            {
57
                if (xtraFolderBrowserDialog.SelectedPath[xtraFolderBrowserDialog.SelectedPath.Length - 1] == '\\')
58
                    xtraFolderBrowserDialog.SelectedPath = xtraFolderBrowserDialog.SelectedPath.Remove(xtraFolderBrowserDialog.SelectedPath.Length - 1);
59
                textBoxProjectDriectory.Text = xtraFolderBrowserDialog.SelectedPath;
60
            }
61
        }
62

    
63
        private void btnSave_Click(object sender, EventArgs e)
64
        {
65
            Project_Info _ProjectInfo = Project_Info.GetInstance();
66
            if (radioGroup.SelectedIndex == 0)
67
            {
68
                _ProjectInfo.DBType = ID2DB_Type.SQLite;
69
                _ProjectInfo.ServerIP = string.Empty;
70
                _ProjectInfo.Port = string.Empty;
71
                _ProjectInfo.DBUser = string.Empty;
72
                _ProjectInfo.DBPassword = string.Empty;
73
            }
74
            else if (radioGroup.SelectedIndex == 1)
75
            {
76
                _ProjectInfo.DBType = ID2DB_Type.MSSQL;
77
                _ProjectInfo.ServerIP = textBoxServerIP.Text;
78
                _ProjectInfo.Port = textBoxPort.Text;
79
                _ProjectInfo.DBUser = textBoxDBUser.Text;
80
                _ProjectInfo.DBPassword = textBoxDBPassword.Text;
81
            }
82
            _ProjectInfo.DefaultPath = textBoxProjectDriectory.Text;
83

    
84
            if (Project_DB.ConnTestAndCreateTable())
85
            {
86
                Settings.Default.ProjectPath = _ProjectInfo.DefaultPath;
87
                Settings.Default.ProjectDBType = (int)_ProjectInfo.DBType;
88
                Settings.Default.ProjectServerIP = _ProjectInfo.ServerIP;
89
                Settings.Default.ProjectPort = _ProjectInfo.Port;
90
                Settings.Default.ProjectDBUser = _ProjectInfo.DBUser;
91
                Settings.Default.ProjectDBPassword = _ProjectInfo.DBPassword;
92
                Settings.Default.Save();
93
                DialogResult = DialogResult.OK;
94
            }
95
            else
96
            {
97
                MessageBox.Show(Msg.FailProjectSelect, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
98
            }
99
        }
100

    
101
        private void btnCancel_Click(object sender, EventArgs e)
102
        {
103
            DialogResult = DialogResult.Cancel;
104
        }
105
    }
106
}
클립보드 이미지 추가 (최대 크기: 500 MB)