Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="dicSet"></param>
        /// <param name="strWhere"></param>
        /// <param name="connStr">数据库链接字符,可跨库查询</param>
        /// <returns></returns>
        public int UpdateModel <T>(Dictionary <string, string> dicSet, string strWhere, string connStr) where T : new()
        {
            T      t      = new T();
            Type   type   = t.GetType();
            string strSql = "Update " + type.Name + " Set ";
            int    flat   = 0;

            foreach (var item in dicSet)
            {
                if (flat == 0)
                {
                    strSql += item.Key + "='" + item.Value + "'";
                    flat++;
                }
                else
                {
                    strSql += " , " + item.Key + "='" + item.Value + "'";
                }
            }
            if (strWhere == string.Empty)
            {
                return(0);
            }
            else
            {
                strSql = strSql + " where  " + strWhere;

                db.ConnStr = connStr;

                return(db.ExecuteNonQuery(strSql));
            }
        }
Exemple #2
0
        public int AddShare(Jw_share js)
        {
            string sql = _cb.InsertModel <Jw_share>(js);

            return(db.ExecuteNonQuery(sql));
        }