Example #1
0
        /*加载系统setting配置,每页10条*/
        private void Settings_Load(object sender, EventArgs e)
        {
            string sSql = "SELECT Settings.SettingsID, Settings.SettingsName,Settings.SettingsSelect, COUNT(DISTINCT Reader.ReaderID) as ReadNum, COUNT(Antenna.AntennaID) as AntennaNum, Store.StoreName  " +
                          "from Settings " +
                          "LEFT JOIN Reader ON Reader.SettingsID = Settings.SettingsID " +
                          "LEFT JOIN Antenna ON Antenna.ReaderID = Reader.ReaderID " +
                          "LEFT JOIN Store ON Store.StoreID = Settings.StoreID " +
                          "GROUP BY Settings.SettingsID,Settings.SettingsName,Settings.SettingsSelect,Store.StoreName " +
                          "order by SettingsID ; ";

                        #if false  //modify at 20171202
            SqlConnection conn = DbConn.sqlConn();
                        #else
            SqlConnection conn = SqlAccess.Connection();
                        #endif
            try
            {
                //conn.Open();      delete at 20171202
                SqlCommand     sqlCmd = new SqlCommand(sSql.ToString(), conn);
                SqlDataAdapter sda    = new SqlDataAdapter(sqlCmd);
                DataSet        ds     = new DataSet();
                sda.Fill(ds, "Settings");
                //dataGridViewSettings.DataSource = ds.Tables["Settings"].DefaultView;
                dataGridViewSettings.DataSource = ds.Tables["Settings"];
                conn.Close();
            }
            catch (SqlException ex)
            {
                Log.WriteLog(LogType.Error, (ex.Message));
            }
        }