From 1a1c8e71fcd14858f595029f089b2d4a00202b32 Mon Sep 17 00:00:00 2001
From: ogi <Administrator@S-OGI-PC>
Date: Fri, 05 Dec 2025 09:24:16 +0900
Subject: [PATCH] プロジェクトファイルを追加。

---
 HotelPms.Share.Windows/Tool/DBLogin.cs |  155 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 155 insertions(+), 0 deletions(-)

diff --git a/HotelPms.Share.Windows/Tool/DBLogin.cs b/HotelPms.Share.Windows/Tool/DBLogin.cs
new file mode 100644
index 0000000..7eb3586
--- /dev/null
+++ b/HotelPms.Share.Windows/Tool/DBLogin.cs
@@ -0,0 +1,155 @@
+using System;
+using System.Data;
+using System.Text;
+using System.Windows.Forms;
+using System.IO;
+using HotelPms.Share.IO;
+
+namespace HotelPms.Share.Windows.Tool
+{
+    public partial class DBLogin : Form
+    {
+        private string listFile = @"\LoginInfo.vic";
+
+        private string userID = string.Empty;
+        private string passWord = string.Empty;
+        private string dataSource = string.Empty;
+        private string catalog = string.Empty;
+
+        /// <summary>���[�U�[</summary>
+        public string UseID
+        {
+            get { return userID; }
+            set { userID = value; }
+        }
+
+        /// <summary>�p�X���[�h</summary>
+        public string PassWord
+        {
+            get { return passWord; }
+            set { passWord = value; }
+        }
+
+        /// <summary>�f�[�^�x�[�X���݂̃p�\�R����</summary>
+        public string DataSource
+        {
+            get { return dataSource; }
+            set { dataSource = value; }
+        }
+
+        /// <summary>�f�[�^�x�[�X��</summary>
+        public string Catalog
+        {
+            get { return catalog; }
+            set { catalog = value; }
+        }
+
+        public DBLogin()
+        {
+            //SqlDataSourceEnumerator instance = SqlDataSourceEnumerator.Instance;
+            //System.Data.DataTable table = instance.GetDataSources();
+
+            InitializeComponent();
+
+            // Display the contents of the table.
+            //DisplayData(table);
+        }
+
+        private void Login_Shown(object sender, EventArgs e)
+        {
+            if (this.cmbSrcDataSource.Items.Count > 0)
+            {
+                this.cmbSrcDataSource.SelectedIndex = 0;
+            }
+
+            if (!File.Exists(Application.StartupPath + listFile)) { return; }
+
+            listBox1.Items.Clear();
+            using (StreamReader sr = new StreamReader(Application.StartupPath + listFile, Encoding.Default))
+            {
+                string line = string.Empty;
+
+                while ((line = sr.ReadLine()) != null)
+                {
+                    listBox1.Items.Add(line);
+                }
+                sr.Close();
+            }
+
+        }
+
+        private void DisplayData(System.Data.DataTable table)
+        {
+            foreach (System.Data.DataRow row in table.Rows)
+            {
+                this.cmbSrcDataSource.Items.Add(row["ServerName"].ToString());
+            }
+        }
+
+        private void Save()
+        {
+            string line = cmbSrcDataSource.Text + "," + txtDstUser.Text + "," + txtDstPassword.Text + "," + txtDstCatalog.Text;
+            if (!listBox1.Items.Contains(line))
+            {
+                listBox1.Items.Add(line);
+            }
+
+            StringBuilder fileInfo = new StringBuilder();
+            foreach (string item in listBox1.Items)
+            {
+                fileInfo.Append(item + Environment.NewLine);
+            }
+            FileOperation.Delete(Application.StartupPath + listFile);
+            File.WriteAllText(Application.StartupPath + listFile, fileInfo.ToString(), Encoding.Default);
+        }
+
+        private void btnLogin_Click(object sender, EventArgs e)
+        {
+            userID = txtDstUser.Text;
+            passWord = txtDstPassword.Text;
+            dataSource = cmbSrcDataSource.Text;
+            catalog = txtDstCatalog.Text;
+
+            Save();
+
+            this.DialogResult = DialogResult.OK;
+            this.Close();
+        }
+
+        private void btnCancel_Click(object sender, EventArgs e)
+        {
+            this.DialogResult = DialogResult.Cancel;
+            this.Close();
+        }
+
+        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            if(listBox1.SelectedIndex == -1) { return;}
+            string[] items = listBox1.Items[listBox1.SelectedIndex].ToString().Split(new char[]{','});
+
+            cmbSrcDataSource.Text = items[0];
+            txtDstUser.Text = items[1];
+            txtDstPassword.Text = items[2];
+            txtDstCatalog.Text = items[3];
+        }
+
+        private void cmbSrcDataSource_DropDown(object sender, EventArgs e)
+        {
+            ComboBox obj = sender as ComboBox;
+            if (obj.Items.Count == 0)
+            {
+                this.Cursor = System.Windows.Forms.Cursors.AppStarting;
+
+                //SqlDataSourceEnumerator sqlServerList = System.Data.Sql.SqlDataSourceEnumerator.Instance;
+                //using (DataTable dtServerList = sqlServerList.GetDataSources())
+                //{
+                //    foreach (DataRow dRow in dtServerList.Rows)
+                //    {
+                //        obj.Items.Add(dRow["ServerName"].ToString());
+                //    }
+                //}
+                this.Cursor = System.Windows.Forms.Cursors.Default;
+            }
+        }
+    }
+}
\ No newline at end of file

--
Gitblit v1.10.0