프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / Form / ID2DBSetting.cs @ 0760d1ad

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

1 8847ea67 gaqhf
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 (xtraFolderBrowserDialog.ShowDialog() == DialogResult.OK)
52
            {
53
                if (xtraFolderBrowserDialog.SelectedPath[xtraFolderBrowserDialog.SelectedPath.Length - 1] == '\\')
54
                    xtraFolderBrowserDialog.SelectedPath = xtraFolderBrowserDialog.SelectedPath.Remove(xtraFolderBrowserDialog.SelectedPath.Length - 1);
55
                textBoxProjectDriectory.Text = xtraFolderBrowserDialog.SelectedPath;
56
            }
57
        }
58
59
        private void btnSave_Click(object sender, EventArgs e)
60
        {
61
            Project_Info _ProjectInfo = Project_Info.GetInstance();
62
            if (radioGroup.SelectedIndex == 0)
63
            {
64
                _ProjectInfo.DBType = ID2DB_Type.SQLite;
65
                _ProjectInfo.ServerIP = string.Empty;
66
                _ProjectInfo.Port = string.Empty;
67
                _ProjectInfo.DBUser = string.Empty;
68
                _ProjectInfo.DBPassword = string.Empty;
69
            }
70
            else if (radioGroup.SelectedIndex == 1)
71
            {
72
                _ProjectInfo.DBType = ID2DB_Type.MSSQL;
73
                _ProjectInfo.ServerIP = textBoxServerIP.Text;
74
                _ProjectInfo.Port = textBoxPort.Text;
75
                _ProjectInfo.DBUser = textBoxDBUser.Text;
76
                _ProjectInfo.DBPassword = textBoxDBPassword.Text;
77
            }
78
            _ProjectInfo.DefaultPath = textBoxProjectDriectory.Text;
79
80
            if (Project_DB.ConnTestAndCreateTable())
81
            {
82
                Settings.Default.ProjectPath = _ProjectInfo.DefaultPath;
83
                Settings.Default.ProjectDBType = (int)_ProjectInfo.DBType;
84
                Settings.Default.ProjectServerIP = _ProjectInfo.ServerIP;
85
                Settings.Default.ProjectPort = _ProjectInfo.Port;
86
                Settings.Default.ProjectDBUser = _ProjectInfo.DBUser;
87
                Settings.Default.ProjectDBPassword = _ProjectInfo.DBPassword;
88
                Settings.Default.Save();
89
                DialogResult = DialogResult.OK;
90
            }
91
            else
92
            {
93
                MessageBox.Show(Msg.FailProjectSelect, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning);
94
            }
95
        }
96
97
        private void btnCancel_Click(object sender, EventArgs e)
98
        {
99
            DialogResult = DialogResult.Cancel;
100
        }
101
    }
102
}
클립보드 이미지 추가 (최대 크기: 500 MB)