Ejemplo n.º 1
0
 public int Add(Model.Comment comment)
 {
     using (IDbConnection cn = new MySqlConnection(cns)) {
         string sql = "insert into Comment(commentID,workId,userName,CommentContent,CommentTime)" + "values(@commentID,@workId,@userName,@CommentContent,@CommentTime);";
         sql += "SELECT @@IDENTITY";
         return(cn.ExecuteScalar <int>(sql, comment));
     }
 }
Ejemplo n.º 2
0
 public int Update(Model.Comment comment)
 {
     using (IDbConnection cn = new MySqlConnection(cns))
     {
         string sql = "update Comment set CommentContent=@CommentContent,CommentTime=@CommentContent where commentID=@commentID";
         return(cn.Execute(sql, comment));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static int Add(Model.Comment model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Comment(");
            strSql.Append("orderId,orderNo,productId,commentType,dataType,fromId,commentInfo,commentDesc,img1Url,img2Url,img3Url,img4Url,status,remark,addTime,addUser,infoType)");
            strSql.Append(" values (");
            strSql.Append("@orderId,@orderNo,@productId,@commentType,@dataType,@fromId,@commentInfo,@commentDesc,@img1Url,@img2Url,@img3Url,@img4Url,@status,@remark,@addTime,@addUser,@infoType)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@orderId",     SqlDbType.Int,          4),
                new SqlParameter("@orderNo",     SqlDbType.VarChar,     50),
                new SqlParameter("@productId",   SqlDbType.Int,          4),
                new SqlParameter("@commentType", SqlDbType.Int,          4),
                new SqlParameter("@dataType",    SqlDbType.Int,          4),
                new SqlParameter("@fromId",      SqlDbType.Int,          4),
                new SqlParameter("@commentInfo", SqlDbType.VarChar,   1500),
                new SqlParameter("@commentDesc", SqlDbType.VarChar,    150),
                new SqlParameter("@img1Url",     SqlDbType.VarChar,    150),
                new SqlParameter("@img2Url",     SqlDbType.VarChar,    150),
                new SqlParameter("@img3Url",     SqlDbType.VarChar,    150),
                new SqlParameter("@img4Url",     SqlDbType.VarChar,    150),
                new SqlParameter("@status",      SqlDbType.Int,          4),
                new SqlParameter("@remark",      SqlDbType.VarChar,    150),
                new SqlParameter("@addTime",     SqlDbType.DateTime),
                new SqlParameter("@addUser",     SqlDbType.Int,          4),
                new SqlParameter("@infoType",    SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.orderId;
            parameters[1].Value  = model.orderNo;
            parameters[2].Value  = model.productId;
            parameters[3].Value  = model.commentType;
            parameters[4].Value  = model.dataType;
            parameters[5].Value  = model.fromId;
            parameters[6].Value  = model.commentInfo;
            parameters[7].Value  = model.commentDesc;
            parameters[8].Value  = model.img1Url;
            parameters[9].Value  = model.img2Url;
            parameters[10].Value = model.img3Url;
            parameters[11].Value = model.img4Url;
            parameters[12].Value = model.status;
            parameters[13].Value = model.remark;
            parameters[14].Value = model.addTime;
            parameters[15].Value = model.addUser;
            parameters[16].Value = model.infoType;

            object obj = DBHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static Model.Comment GetModelMobile(object productId, object userId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from Comment ");
            strSql.Append(" where productId=" + productId + " and addUser = "******" and orderId = 0");

            Model.Comment model = new Model.Comment();
            DataSet       ds    = DBHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static Model.Comment GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,orderId,orderNo,productId,commentType,dataType,fromId,commentInfo,commentDesc,img1Url,img2Url,img3Url,img4Url,status,remark,addTime,addUser,infoType from Comment ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Model.Comment model = new Model.Comment();
            DataSet       ds    = DBHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public static Model.Comment DataRowToModel(DataRow row)
 {
     Model.Comment model = new Model.Comment();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["orderId"] != null && row["orderId"].ToString() != "")
         {
             model.orderId = int.Parse(row["orderId"].ToString());
         }
         if (row["orderNo"] != null)
         {
             model.orderNo = row["orderNo"].ToString();
         }
         if (row["productId"] != null && row["productId"].ToString() != "")
         {
             model.productId = int.Parse(row["productId"].ToString());
         }
         if (row["commentType"] != null && row["commentType"].ToString() != "")
         {
             model.commentType = int.Parse(row["commentType"].ToString());
         }
         if (row["dataType"] != null && row["dataType"].ToString() != "")
         {
             model.dataType = int.Parse(row["dataType"].ToString());
         }
         if (row["fromId"] != null && row["fromId"].ToString() != "")
         {
             model.fromId = int.Parse(row["fromId"].ToString());
         }
         if (row["commentInfo"] != null)
         {
             model.commentInfo = row["commentInfo"].ToString();
         }
         if (row["commentDesc"] != null)
         {
             model.commentDesc = row["commentDesc"].ToString();
         }
         if (row["img1Url"] != null)
         {
             model.img1Url = row["img1Url"].ToString();
         }
         if (row["img2Url"] != null)
         {
             model.img2Url = row["img2Url"].ToString();
         }
         if (row["img3Url"] != null)
         {
             model.img3Url = row["img3Url"].ToString();
         }
         if (row["img4Url"] != null)
         {
             model.img4Url = row["img4Url"].ToString();
         }
         if (row["status"] != null && row["status"].ToString() != "")
         {
             model.status = int.Parse(row["status"].ToString());
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
         if (row["addTime"] != null && row["addTime"].ToString() != "")
         {
             model.addTime = DateTime.Parse(row["addTime"].ToString());
         }
         if (row["addUser"] != null && row["addUser"].ToString() != "")
         {
             model.addUser = int.Parse(row["addUser"].ToString());
         }
         if (row["infoType"] != null && row["infoType"].ToString() != "")
         {
             model.infoType = int.Parse(row["infoType"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool Update(Model.Comment model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Comment set ");
            strSql.Append("orderId=@orderId,");
            strSql.Append("orderNo=@orderNo,");
            strSql.Append("productId=@productId,");
            strSql.Append("commentType=@commentType,");
            strSql.Append("dataType=@dataType,");
            strSql.Append("fromId=@fromId,");
            strSql.Append("commentInfo=@commentInfo,");
            strSql.Append("commentDesc=@commentDesc,");
            strSql.Append("img1Url=@img1Url,");
            strSql.Append("img2Url=@img2Url,");
            strSql.Append("img3Url=@img3Url,");
            strSql.Append("img4Url=@img4Url,");
            strSql.Append("status=@status,");
            strSql.Append("remark=@remark,");
            strSql.Append("addTime=@addTime,");
            strSql.Append("addUser=@addUser,");
            strSql.Append("infoType=@infoType");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@orderId",     SqlDbType.Int,          4),
                new SqlParameter("@orderNo",     SqlDbType.VarChar,     50),
                new SqlParameter("@productId",   SqlDbType.Int,          4),
                new SqlParameter("@commentType", SqlDbType.Int,          4),
                new SqlParameter("@dataType",    SqlDbType.Int,          4),
                new SqlParameter("@fromId",      SqlDbType.Int,          4),
                new SqlParameter("@commentInfo", SqlDbType.VarChar,   1500),
                new SqlParameter("@commentDesc", SqlDbType.VarChar,    150),
                new SqlParameter("@img1Url",     SqlDbType.VarChar,    150),
                new SqlParameter("@img2Url",     SqlDbType.VarChar,    150),
                new SqlParameter("@img3Url",     SqlDbType.VarChar,    150),
                new SqlParameter("@img4Url",     SqlDbType.VarChar,    150),
                new SqlParameter("@status",      SqlDbType.Int,          4),
                new SqlParameter("@remark",      SqlDbType.VarChar,    150),
                new SqlParameter("@addTime",     SqlDbType.DateTime),
                new SqlParameter("@addUser",     SqlDbType.Int,          4),
                new SqlParameter("@infoType",    SqlDbType.Int,          4),
                new SqlParameter("@id",          SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.orderId;
            parameters[1].Value  = model.orderNo;
            parameters[2].Value  = model.productId;
            parameters[3].Value  = model.commentType;
            parameters[4].Value  = model.dataType;
            parameters[5].Value  = model.fromId;
            parameters[6].Value  = model.commentInfo;
            parameters[7].Value  = model.commentDesc;
            parameters[8].Value  = model.img1Url;
            parameters[9].Value  = model.img2Url;
            parameters[10].Value = model.img3Url;
            parameters[11].Value = model.img4Url;
            parameters[12].Value = model.status;
            parameters[13].Value = model.remark;
            parameters[14].Value = model.addTime;
            parameters[15].Value = model.addUser;
            parameters[16].Value = model.infoType;
            parameters[17].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }