Ejemplo n.º 1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <TZClickM> DataTableToList(DataTable dt)
        {
            List <TZClickM> modelList = new List <TZClickM>();
            int             rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                TZClickM model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new TZClickM();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    model.loginName = dt.Rows[n]["loginName"].ToString();
                    if (dt.Rows[n]["createTime"].ToString() != "")
                    {
                        model.createTime = DateTime.Parse(dt.Rows[n]["createTime"].ToString());
                    }
                    if (dt.Rows[n]["ClickId"].ToString() != "")
                    {
                        model.ClickId = int.Parse(dt.Rows[n]["ClickId"].ToString());
                    }
                    if (dt.Rows[n]["PageId"].ToString() != "")
                    {
                        model.PageId = int.Parse(dt.Rows[n]["PageId"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(TZClickM model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TZClick set ");
            strSql.Append("loginName=@loginName,");
            strSql.Append("createTime=@createTime,");
            strSql.Append("ClickId=@ClickId,");
            strSql.Append("PageId=@PageId");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",         SqlDbType.Int,        4),
                new SqlParameter("@loginName",  SqlDbType.VarChar,   50),
                new SqlParameter("@createTime", SqlDbType.DateTime),
                new SqlParameter("@ClickId",    SqlDbType.Int,        4),
                new SqlParameter("@PageId",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.loginName;
            parameters[2].Value = model.createTime;
            parameters[3].Value = model.ClickId;
            parameters[4].Value = model.PageId;
            int rows = DBHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(TZClickM model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TZClick(");
            strSql.Append("loginName,createTime,ClickId,PageId)");
            strSql.Append(" values (");
            strSql.Append("@loginName,getdate(),@ClickId,@PageId)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@loginName", SqlDbType.VarChar, 50),
                //new SqlParameter("@createTime", SqlDbType.DateTime),
                new SqlParameter("@ClickId",   SqlDbType.Int,      4),
                new SqlParameter("@PageId",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.loginName;
            //parameters[1].Value = model.createTime;
            parameters[1].Value = model.ClickId;
            parameters[2].Value = model.PageId;
            object obj = DBHelper.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TZClickM GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,PageId,loginName,createTime,ClickId from TZClick ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            TZClickM model = new TZClickM();
            DataSet  ds    = DBHelper.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.loginName = ds.Tables[0].Rows[0]["loginName"].ToString();
                if (ds.Tables[0].Rows[0]["createTime"].ToString() != "")
                {
                    model.createTime = DateTime.Parse(ds.Tables[0].Rows[0]["createTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ClickId"].ToString() != "")
                {
                    model.ClickId = int.Parse(ds.Tables[0].Rows[0]["ClickId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["PageId"].ToString() != "")
                {
                    model.PageId = int.Parse(ds.Tables[0].Rows[0]["PageId"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(TZClickM model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(TZClickM model)
 {
     return(dal.Add(model));
 }