/// <summary> /// 更新一条数据 /// </summary> public bool Update(WeiXinPF.Model.wx_ucard_privileges model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update wx_ucard_privileges set "); strSql.Append("wid=@wid,"); strSql.Append("pName=@pName,"); strSql.Append("beginDate=@beginDate,"); strSql.Append("endDate=@endDate,"); strSql.Append("usedContent=@usedContent,"); strSql.Append("userDegree=@userDegree,"); strSql.Append("sId=@sId,"); strSql.Append("createDate=@createDate,"); strSql.Append("sort_id=@sort_id"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@pName", SqlDbType.VarChar, 100), new SqlParameter("@beginDate", SqlDbType.DateTime), new SqlParameter("@endDate", SqlDbType.DateTime), new SqlParameter("@usedContent", SqlDbType.VarChar, 1500), new SqlParameter("@userDegree", SqlDbType.VarChar, 500), new SqlParameter("@sId", SqlDbType.Int, 4), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.wid; parameters[1].Value = model.pName; parameters[2].Value = model.beginDate; parameters[3].Value = model.endDate; parameters[4].Value = model.usedContent; parameters[5].Value = model.userDegree; parameters[6].Value = model.sId; parameters[7].Value = model.createDate; parameters[8].Value = model.sort_id; parameters[9].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WeiXinPF.Model.wx_ucard_privileges DataRowToModel(DataRow row) { WeiXinPF.Model.wx_ucard_privileges model = new WeiXinPF.Model.wx_ucard_privileges(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["wid"] != null && row["wid"].ToString() != "") { model.wid = int.Parse(row["wid"].ToString()); } if (row["pName"] != null) { model.pName = row["pName"].ToString(); } if (row["beginDate"] != null && row["beginDate"].ToString() != "") { model.beginDate = DateTime.Parse(row["beginDate"].ToString()); } if (row["endDate"] != null && row["endDate"].ToString() != "") { model.endDate = DateTime.Parse(row["endDate"].ToString()); } if (row["usedContent"] != null) { model.usedContent = row["usedContent"].ToString(); } if (row["userDegree"] != null) { model.userDegree = row["userDegree"].ToString(); } if (row["sId"] != null && row["sId"].ToString() != "") { model.sId = int.Parse(row["sId"].ToString()); } if (row["createDate"] != null && row["createDate"].ToString() != "") { model.createDate = DateTime.Parse(row["createDate"].ToString()); } if (row["sort_id"] != null && row["sort_id"].ToString() != "") { model.sort_id = int.Parse(row["sort_id"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(WeiXinPF.Model.wx_ucard_privileges model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into wx_ucard_privileges("); strSql.Append("wid,pName,beginDate,endDate,usedContent,userDegree,sId,createDate,sort_id)"); strSql.Append(" values ("); strSql.Append("@wid,@pName,@beginDate,@endDate,@usedContent,@userDegree,@sId,@createDate,@sort_id)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@pName", SqlDbType.VarChar, 100), new SqlParameter("@beginDate", SqlDbType.DateTime), new SqlParameter("@endDate", SqlDbType.DateTime), new SqlParameter("@usedContent", SqlDbType.VarChar, 1500), new SqlParameter("@userDegree", SqlDbType.VarChar, 500), new SqlParameter("@sId", SqlDbType.Int, 4), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@sort_id", SqlDbType.Int, 4) }; parameters[0].Value = model.wid; parameters[1].Value = model.pName; parameters[2].Value = model.beginDate; parameters[3].Value = model.endDate; parameters[4].Value = model.usedContent; parameters[5].Value = model.userDegree; parameters[6].Value = model.sId; parameters[7].Value = model.createDate; parameters[8].Value = model.sort_id; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WeiXinPF.Model.wx_ucard_privileges GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,wid,pName,beginDate,endDate,usedContent,userDegree,sId,createDate,sort_id from wx_ucard_privileges "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; WeiXinPF.Model.wx_ucard_privileges model = new WeiXinPF.Model.wx_ucard_privileges(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }