Esempio n. 1
0
        public static List <SysStatusInfoModel> SelectSysStatusData()
        {
            List <SysStatusInfoModel> sysStatusInfoModelList = new List <SysStatusInfoModel>();

            using (SQLiteConnection conn = new SQLiteConnection(connStr))
            {
                try
                {
                    conn.Open();
                    string sql = "SELECT * FROM SysStatusInfo";

                    SQLiteDataAdapter ap = new SQLiteDataAdapter(sql, conn);

                    DataSet ds = new DataSet();
                    ap.Fill(ds);
                    ap.Dispose();


                    DataTable dt = ds.Tables[0];
                    foreach (DataRow item in dt.Rows)
                    {
                        SysStatusInfoModel sysStatusInfoModel = new SysStatusInfoModel();
                        sysStatusInfoModel.id         = Convert.ToInt32(item["id"]);
                        sysStatusInfoModel.num        = (int)item["num"];
                        sysStatusInfoModel.SysStatus  = (string)item["sysStatus"];
                        sysStatusInfoModel.CreateDate = (string)item["CreateDate"];
                        sysStatusInfoModel.CreateTime = (string)item["CreateTime"];

                        sysStatusInfoModelList.Add(sysStatusInfoModel);
                    }
                }
                catch (Exception ex)
                {
                    LogUtil.LogError(ex);
                }
                finally
                {
                    conn.Close();
                    conn.Dispose();
                }
            }

            return(sysStatusInfoModelList);
        }
Esempio n. 2
0
        public static void InsertSysStatusData(SysStatusInfoModel sysStatusInfoModel)
        {
            using (SQLiteConnection conn = new SQLiteConnection(connStr))
            {
                try
                {
                    conn.Open();
                    string sql = "SELECT * FROM SysStatusInfo";

                    SQLiteDataAdapter ap = new SQLiteDataAdapter(sql, conn);
                    DataSet           ds = new DataSet();
                    ap.Fill(ds);
                    ap.Dispose();
                    DataTable dt = ds.Tables[0];


                    DataRow dataRow = dt.NewRow();
                    dt.Rows.Add(dataRow);

                    sql = "INSERT INTO SysStatusInfo(num,sysStatus,CreateDate,CreateTime) " +
                          "VALUES(@num,@SysStatus,@CreateDate,@CreateTime)";

                    object[] paramList = sysStatusInfoModel.GetObjectList();

                    SQLiteHelper.ExecuteNonQuery(conn, sql, paramList);
                }
                catch (Exception ex)
                {
                    LogUtil.LogError(ex);
                }
                finally
                {
                    conn.Close();
                    conn.Dispose();
                }
            }
        }