zoukankan      html  css  js  c++  java
  • Cache使用方法1

    代码
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using ypxt.IDAL;
    using System.Data;
    using System.Data.SqlClient;
    using ypxt.MODEL;
    using ypxt.DBUtility;
    namespace ypxt.SQLDAL
    {
      
    public  class DALKey: IKey
        {
            
    private const string PARM_KeyId = "@KeyId";
            
    private const string PARM_KeyText = "@KeyText";
            
    private const string PARM_AdverId = "@AdverId";
            
    private const string PARM_Money = "@Money";

            
    private const string ADD_Keyinfo = "Insert into Key(KeyText,AdverId,Money) values(" + PARM_KeyText + "," + PARM_AdverId + "," + PARM_Money + ")";
            
    private const string UPDATE_Keyinfo = "UPDATE Key SET KeyText=" + PARM_KeyText + ",AdverId=" + PARM_AdverId + ",Money=" + PARM_Money + " WHERE CorpId=" + PARM_KeyId;
            
    private const string DELETE_KeyinfoByID = "DELETE FROM Key WHERE KeyId=" + PARM_KeyId;
            
    private const string SELECT_KeyinfoByID = "SELECT * FROM Key WHERE KeyId=" + PARM_KeyId;
            
    private const string SELECT_Keyinfo = "SELECT * FROM Key";
     
         
    /// 增加数据 ---郑
         #region 

            
    public bool addKeyinfo(Keyinfo Keyinfo)
           {
               SqlParameter[] param 
    = GetKeyinfoParameters();
               setKeyinfoParameters(param, Keyinfo);
               
    int result = SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, CommandType.Text, ADD_Keyinfo, param);
               
    if (result == 0)
               {
                   
    return false;
               }
               
    return true;
           }
            
    public static SqlParameter[] GetKeyinfoParameters()
            {
                
    //从缓存里面取参数,如果缓存里面没有参数,就将 参数加入缓存里面,,)
                SqlParameter[] param = SqlHelper.GetCachedParameters(ADD_Keyinfo);//.GetCachedParameters(ADD_MEMBERINFO);//从缓存里面取数据
                
    //将参数加入缓存里面
                if (param == null)
                {
                    
    /// 创建各个参数
                    param = new SqlParameter[]{
                     
    new SqlParameter(PARM_KeyText,SqlDbType.NVarChar,50),
                     
    new SqlParameter(PARM_AdverId,SqlDbType.Int,30),
                     
    new SqlParameter(PARM_Money,SqlDbType.Decimal,30)                
                    };
                    
    //放入缓存
                    SqlHelper.CacheParameters(ADD_Keyinfo, param);
                }
                
    return param;
            }

            
    public static void setKeyinfoParameters(SqlParameter[] parms, Keyinfo Keyinfo)
            {
                parms[
    0].Value = Keyinfo.KeyText;
                parms[
    1].Value = Keyinfo.AdverId;
                parms[
    2].Value = Keyinfo.Money;
               
            }
           
    #endregion
           
    #region      
            
    public bool updateKeyinfo(Keyinfo Keyinfo)
          {
              
    return true;
          }
           
    #endregion
            
    public bool deleteKeyinfo(int KeyinfoID)
          {
              
    return true;
          }
     
        }
    }
  • 相关阅读:
    阶段性总结---初始阶段
    微信授权以及微信支付所遇到的坑(完善)
    CSS3学习
    Playing with String(codeforces 305E)
    Treblecross(uva 10561)
    序列操作(bzoj 1858)
    传送带(bzoj 1857)
    字符串(bzoj 1856)
    刷题比赛(洛谷 1707)
    大楼(bzoj 2165)
  • 原文地址:https://www.cnblogs.com/muer/p/1724684.html
Copyright © 2011-2022 走看看