Пример #1
0
        protected virtual void Initialize()
        {
            textBox2.Enabled = false;
            dbHost           = AppSetting.LoadInitialSetting("DB_IP", "127.0.0.1");
            dbUser           = AppSetting.LoadInitialSetting("DB_USER", "root");
            dbPass           = AppSetting.LoadInitialSetting("DB_PASSWORD", "123");
            dbName           = AppSetting.LoadInitialSetting("DB_NAME", "huachun");
            SQL = new MySQL(dbHost, dbUser, dbPass, dbName);

            numbers = SQL.Read1DArrayNoCondition_SQL_Data(DB_No, DB_TableName);
            names   = SQL.Read1DArrayNoCondition_SQL_Data(DB_Name, DB_TableName);

            dataTable = new DataTable("MyNewTable");
            dataTable.Columns.Add(rowNo, typeof(String));
            dataTable.Columns.Add(rowName, typeof(String));
            dataGridView1.DataSource         = dataTable;
            dataGridView1.ReadOnly           = true;
            dataGridView1.AllowUserToAddRows = false;
            dataGridView1.MultiSelect        = false;

            DataRow dataRow;

            for (int i = 0; i < numbers.Length; i++)
            {
                dataRow          = dataTable.NewRow();
                dataRow[rowNo]   = numbers[i];
                dataRow[rowName] = SQL.Read_SQL_data(DB_Name, DB_TableName, DB_No + " = '" + numbers[i] + "'");
                dataTable.Rows.Add(dataRow);
            }
        }
Пример #2
0
        private void RefreshDatagridview()
        {
            dataTable.Clear();

            string[]   dateArr = SQL.Read1DArrayNoCondition_SQL_Data("date", "holiday");
            DateTime[] dates   = new DateTime[dateArr.Length];
            for (int i = 0; i < dateArr.Length; i++)
            {
                dates[i] = Functions.TransferSQLDateToDateTime(dateArr[i]);
            }
            Array.Sort(dates);

            DataRow dataRow;

            for (int i = 0; i < dates.Length; i++)
            {
                dataRow       = dataTable.NewRow();
                dataRow["日期"] = dates[i].Year.ToString() + "/" + dates[i].Month.ToString() + "/" + dates[i].Day.ToString();
                dataRow["星期"] = Functions.ComputeDayOfWeek(dates[i]);
                dataRow["理由"] = SQL.Read_SQL_data("reason", "holiday", "date = '" + dates[i].Year.ToString() + "-" + dates[i].Month.ToString() + "-" + dates[i].Day.ToString() + "'");
                string working = SQL.Read_SQL_data("working", "holiday", "date = '" + dates[i].Year.ToString() + "-" + dates[i].Month.ToString() + "-" + dates[i].Day.ToString() + "'");
                if (working == "1")
                {
                    dataRow["放假/補班"] = "放假";
                }
                else
                {
                    dataRow["放假/補班"] = "補班";
                }
                dataTable.Rows.Add(dataRow);
            }
        }
        private void Initialize()
        {
            dbHost = AppSetting.LoadInitialSetting("DB_IP", "127.0.0.1");
            dbUser = AppSetting.LoadInitialSetting("DB_USER", "root");
            dbPass = AppSetting.LoadInitialSetting("DB_PASSWORD", "123");
            dbName = AppSetting.LoadInitialSetting("DB_NAME", "huachun");

            SQL = new MySQL(dbHost, dbUser, dbPass, dbName);

            arrayCity = new ArrayList();

            string[] cities = SQL.Read1DArrayNoCondition_SQL_Data("distinct city", "city");

            for (int i = 0; i < cities.Length; i++)
            {
                comboBoxCity.Items.Add(cities[i]);
            }
            comboBoxCity.SelectedIndex = 0;
        }