예제 #1
0
파일: Log.cs 프로젝트: datvp/WpfMVVM
        public void Info(Model.DownHis m)
        {
            var query = "INSERT INTO DownHis(DriverName,TotalSize,Progress,Status,CreatedOn)VALUES(@DriverName,@TotalSize,@Progress,@Status,@CreatedOn)";
            var found = CheckExist("DownHis", "DriverName", m.DriverName);

            if (found)
            {
                query = "UPDATE DownHis SET TotalSize=@TotalSize,Progress=@Progress,Status=@Status,CreatedOn=@CreatedOn WHERE DriverName=@DriverName";
            }
            List <SQLiteParameter> param = new List <SQLiteParameter>();

            param.Add(new SQLiteParameter("@DriverName", m.DriverName));
            param.Add(new SQLiteParameter("@TotalSize", m.TotalSize));
            param.Add(new SQLiteParameter("@Progress", m.Progress));
            param.Add(new SQLiteParameter("@Status", m.Status));
            param.Add(new SQLiteParameter("@CreatedOn", DateTime.Now.ToString("yyyy-MM-dd HH:MM tt")));
            DAL.ExecQuery(query, param);
        }
예제 #2
0
파일: Log.cs 프로젝트: datvp/WpfMVVM
        public ObservableCollection <Model.DownHis> GetListDownHis()
        {
            ObservableCollection <Model.DownHis> collection = new ObservableCollection <Model.DownHis>();
            string query = "Select * from DownHis";
            var    dt    = DAL.GetList(query, null);

            if (dt == null)
            {
                return(collection);
            }
            foreach (DataRow r in dt.Rows)
            {
                Model.DownHis m = new Model.DownHis();
                m.DriverName = r["DriverName"].ToString();
                m.TotalSize  = int.Parse(r["TotalSize"].ToString());
                m.Progress   = int.Parse(r["Progress"].ToString());
                m.Status     = r["Status"].ToString();
                collection.Add(m);
            }
            return(collection);
        }