/// <summary> /// 得到一个对象实体 /// </summary> public WeiXinPF.Model.wx_sjb_jcDetail DataRowToModel(DataRow row) { WeiXinPF.Model.wx_sjb_jcDetail model = new WeiXinPF.Model.wx_sjb_jcDetail(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["uid"] != null && row["uid"].ToString() != "") { model.uid = int.Parse(row["uid"].ToString()); } if (row["rcId"] != null && row["rcId"].ToString() != "") { model.rcId = int.Parse(row["rcId"].ToString()); } if (row["bsId"] != null && row["bsId"].ToString() != "") { model.bsId = int.Parse(row["bsId"].ToString()); } if (row["jcRetType"] != null && row["jcRetType"].ToString() != "") { model.jcRetType = int.Parse(row["jcRetType"].ToString()); } if (row["retIsRight"] != null && row["retIsRight"].ToString() != "") { if ((row["retIsRight"].ToString() == "1") || (row["retIsRight"].ToString().ToLower() == "true")) { model.retIsRight = true; } else { model.retIsRight = false; } } if (row["createDate"] != null && row["createDate"].ToString() != "") { model.createDate = DateTime.Parse(row["createDate"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(WeiXinPF.Model.wx_sjb_jcDetail model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update wx_sjb_jcDetail set "); strSql.Append("uid=@uid,"); strSql.Append("rcId=@rcId,"); strSql.Append("bsId=@bsId,"); strSql.Append("jcRetType=@jcRetType,"); strSql.Append("retIsRight=@retIsRight,"); strSql.Append("createDate=@createDate"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@uid", SqlDbType.Int, 4), new SqlParameter("@rcId", SqlDbType.Int, 4), new SqlParameter("@bsId", SqlDbType.Int, 4), new SqlParameter("@jcRetType", SqlDbType.Int, 4), new SqlParameter("@retIsRight", SqlDbType.Bit, 1), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.uid; parameters[1].Value = model.rcId; parameters[2].Value = model.bsId; parameters[3].Value = model.jcRetType; parameters[4].Value = model.retIsRight; parameters[5].Value = model.createDate; parameters[6].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(WeiXinPF.Model.wx_sjb_jcDetail model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into wx_sjb_jcDetail("); strSql.Append("uid,rcId,bsId,jcRetType,retIsRight,createDate)"); strSql.Append(" values ("); strSql.Append("@uid,@rcId,@bsId,@jcRetType,@retIsRight,@createDate)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@uid", SqlDbType.Int, 4), new SqlParameter("@rcId", SqlDbType.Int, 4), new SqlParameter("@bsId", SqlDbType.Int, 4), new SqlParameter("@jcRetType", SqlDbType.Int, 4), new SqlParameter("@retIsRight", SqlDbType.Bit, 1), new SqlParameter("@createDate", SqlDbType.DateTime) }; parameters[0].Value = model.uid; parameters[1].Value = model.rcId; parameters[2].Value = model.bsId; parameters[3].Value = model.jcRetType; parameters[4].Value = model.retIsRight; parameters[5].Value = model.createDate; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WeiXinPF.Model.wx_sjb_jcDetail GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,uid,rcId,bsId,jcRetType,retIsRight,createDate from wx_sjb_jcDetail "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; WeiXinPF.Model.wx_sjb_jcDetail model = new WeiXinPF.Model.wx_sjb_jcDetail(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }