Exemplo n.º 1
0
 /// <summary>
 /// 得到一个对象实体,从缓存中
 /// </summary>
 public TDTK.PlatForm.MVC4.Model.CardLogin GetModelByCache(int ID)
 {
     TDTK.PlatForm.MVC4.Model.CardLogin cl = new TDTK.PlatForm.MVC4.Model.CardLogin();
     cl.ID = ID;
     string CacheKey = "CardLoginModel-" + ID;
     object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
     if (objModel == null)
     {
         try
         {
             objModel = dal.GetModel(cl);
             if (objModel != null)
             {
                 int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
                 Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
             }
         }
         catch { }
     }
     return (TDTK.PlatForm.MVC4.Model.CardLogin)objModel;
 }
Exemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public TDTK.PlatForm.MVC4.Model.CardLogin DataRowToModel(DataRow row)
 {
     TDTK.PlatForm.MVC4.Model.CardLogin model = new TDTK.PlatForm.MVC4.Model.CardLogin();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["CardID"] != null)
         {
             model.CardID = row["CardID"].ToString();
         }
         if (row["UserName"] != null)
         {
             model.UserName = row["UserName"].ToString();
         }
         if (row["UserCode"] != null)
         {
             model.UserCode = row["UserCode"].ToString();
         }
     }
     return model;
 }
Exemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TDTK.PlatForm.MVC4.Model.CardLogin GetModel(TDTK.PlatForm.MVC4.Model.CardLogin t)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 ID,CardID,UserName,UserCode from CardLogin ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.Int,4)
			};
            parameters[0].Value = t.ID;

            TDTK.PlatForm.MVC4.Model.CardLogin model = new TDTK.PlatForm.MVC4.Model.CardLogin();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }