ホテル管理システム
ogi
yesterday 1a1c8e71fcd14858f595029f089b2d4a00202b32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using HotelPms.Share.Data;
using HotelPms.Share.Windows.Util;
using HotelPms.SourceFactory.Table;
using HotelPms.SourceFactory.Util;
using NPOI.SS.UserModel;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace HotelPms.SourceFactory
{
    public partial class ExcelToTable : Form
    {
        public ExcelToTable()
        {
            InitializeComponent();
        }
 
        private void OpenExcel_Click(object sender, EventArgs e)
        {
            if (txtExcelPath.Text.Length == 0)
            {
                openFileDialog1.InitialDirectory = Application.StartupPath;
                if (openFileDialog1.ShowDialog() != DialogResult.OK) { return; }
                txtExcelPath.Text = openFileDialog1.FileName;
            }
 
            cmbSheet.Items.Clear();
            using (NPOIExcel excel = new NPOIExcel(txtExcelPath.Text))
            {
                for (int i = 0; i < excel.Workbook.NumberOfSheets; i++)
                {
                    cmbSheet.Items.Add(excel.Workbook.GetSheetAt(i).SheetName);
                }
            }
        }
 
        private void button3_Click(object sender, EventArgs e)
        {
            using(SqlFactory sqlFactory = new SqlFactory())
            {
                sqlFactory.CreateByExcel(txtExcelPath.Text, new DBConnectItem() { HostName = txtHost.Text, UserID = txtUser.Text, Password = txtPassword.Text, DBName = txtDB.Text });
            }
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            using (NPOIExcel excel = new NPOIExcel(txtExcelPath.Text))
            {
                ICell A1 = excel.GetCell("A1");
                ICell B1 = excel.GetCell("B1");
                ICell C1 = excel.GetCell("C1");
                ICell D1 = excel.GetCell("D1");
                ICell E1 = excel.GetCell("E1");
                ICell F1 = excel.GetCell("F1");
                ICell G1 = excel.GetCell("G1");
                ICell H1 = excel.GetCell("H1");
                ICell I1 = excel.GetCell("I1");
                ICell J1 = excel.GetCell("J1");
                ICell K1 = excel.GetCell("K1");
                ICell L1 = excel.GetCell("L1");
            }
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            using (NPOIExcel excel = new NPOIExcel(txtExcelPath.Text))
            {
                excel.SetCurrentSheet(cmbSheet.SelectedIndex);
                using (SqlFactory sqlFactory = new())
                {
                    sqlFactory.DBSetting = new DBConnectItem() { HostName = txtHost.Text, UserID = txtUser.Text, Password = txtPassword.Text, DBName = txtDB.Text };
                    bool ret = sqlFactory.CreateBySheet(excel);
                    MessageBox.Show($"結果:{ret}");
                }
            }
        }
 
        private void button4_Click(object sender, EventArgs e)
        {
            txtContext.Text = EnumFactory.Create(txtExcelPath.Text, cmbSheet.SelectedIndex);
        }
    }
}