示例#1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(GZS.Model.Invest.InvestCostM model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into InvestCost(");
            strSql.Append("loginName,Chineseintroduced,Englishintroduction,createdate,hits)");
            strSql.Append(" values (");
            strSql.Append("@loginName,@Chineseintroduced,@Englishintroduction,getdate(),@hits)");
            SqlParameter[] parameters =
            {
                //new SqlParameter("@Costid", SqlDbType.Int,4),
                new SqlParameter("@loginName",           SqlDbType.VarChar,   50),
                new SqlParameter("@Chineseintroduced",   SqlDbType.NVarChar),
                new SqlParameter("@Englishintroduction", SqlDbType.NVarChar),
                //new SqlParameter("@createdate", SqlDbType.DateTime),
                new SqlParameter("@hits",                SqlDbType.Int, 4)
            };
            //parameters[0].Value = model.Costid;
            parameters[0].Value = model.loginName;
            parameters[1].Value = model.Chineseintroduced;
            parameters[2].Value = model.Englishintroduction;
            //parameters[4].Value = model.createdate;
            parameters[3].Value = model.hits;
            object obj = DBHelper.ExecuteSql(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public GZS.Model.Invest.InvestCostM GetModel(int Costid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Costid,loginName,Chineseintroduced,Englishintroduction,createdate,hits from InvestCost ");
            strSql.Append(" where Costid=@Costid ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Costid", SqlDbType.Int, 4)
            };
            parameters[0].Value = Costid;

            GZS.Model.Invest.InvestCostM model = new GZS.Model.Invest.InvestCostM();
            DataSet ds = DBHelper.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Costid"].ToString() != "")
                {
                    model.Costid = int.Parse(ds.Tables[0].Rows[0]["Costid"].ToString());
                }
                model.loginName           = ds.Tables[0].Rows[0]["loginName"].ToString();
                model.Chineseintroduced   = ds.Tables[0].Rows[0]["Chineseintroduced"].ToString();
                model.Englishintroduction = ds.Tables[0].Rows[0]["Englishintroduction"].ToString();
                if (ds.Tables[0].Rows[0]["createdate"].ToString() != "")
                {
                    model.createdate = DateTime.Parse(ds.Tables[0].Rows[0]["createdate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["hits"].ToString() != "")
                {
                    model.hits = int.Parse(ds.Tables[0].Rows[0]["hits"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(GZS.Model.Invest.InvestCostM model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update InvestCost set ");
            strSql.Append("loginName=@loginName,");
            strSql.Append("Chineseintroduced=@Chineseintroduced,");
            strSql.Append("Englishintroduction=@Englishintroduction,");
            //strSql.Append("createdate=@createdate,");
            strSql.Append("hits=@hits");
            strSql.Append(" where Costid=@Costid ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Costid",              SqlDbType.Int,        4),
                new SqlParameter("@loginName",           SqlDbType.VarChar,   50),
                new SqlParameter("@Chineseintroduced",   SqlDbType.NVarChar),
                new SqlParameter("@Englishintroduction", SqlDbType.NVarChar),
                //new SqlParameter("@createdate", SqlDbType.DateTime),
                new SqlParameter("@hits",                SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Costid;
            parameters[1].Value = model.loginName;
            parameters[2].Value = model.Chineseintroduced;
            parameters[3].Value = model.Englishintroduction;
            //parameters[4].Value = model.createdate;
            parameters[4].Value = model.hits;

            int rows = DBHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
0
		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int Add(GZS.Model.Invest.InvestCostM model)
		{
		return dal.Add(model);
		}