/// <summary> /// 更新一条数据 /// </summary> public void Update(Tunnel.Model.Tunnel_MingXing model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@m_id", SqlDbType.Int,4), new SqlParameter("@m_uid", SqlDbType.Int,4), new SqlParameter("@m_img", SqlDbType.VarChar,50), new SqlParameter("@m_content", SqlDbType.VarChar,2000), new SqlParameter("@m_year", SqlDbType.Int,4), new SqlParameter("@m_moon", SqlDbType.Int,4), new SqlParameter("@m_title",SqlDbType.VarChar,100)}; parameters[0].Value = model.m_id; parameters[1].Value = model.m_uid; parameters[2].Value = model.m_img; parameters[3].Value = model.m_content; parameters[4].Value = model.m_year; parameters[5].Value = model.m_moon; parameters[6].Value = model.Title; DbHelperSQL.RunProcedure("UP_Tunnel_MingXing_Update",parameters,out rowsAffected); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Tunnel.Model.Tunnel_MingXing model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@m_id", SqlDbType.Int,4), new SqlParameter("@m_uid", SqlDbType.Int,4), new SqlParameter("@m_img", SqlDbType.VarChar,50), new SqlParameter("@m_content", SqlDbType.VarChar,2000), new SqlParameter("@m_year", SqlDbType.Int,4), new SqlParameter("@m_moon", SqlDbType.Int,4), new SqlParameter("@m_title",SqlDbType.VarChar,100)}; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.m_uid; parameters[2].Value = model.m_img; parameters[3].Value = model.m_content; parameters[4].Value = model.m_year; parameters[5].Value = model.m_moon; parameters[6].Value = model.Title; DbHelperSQL.RunProcedure("UP_Tunnel_MingXing_ADD",parameters,out rowsAffected); return (int)parameters[0].Value; }
/// <summary> /// 得到一个对象实体 /// </summary> public Tunnel.Model.Tunnel_MingXing GetModel(int m_id) { SqlParameter[] parameters = { new SqlParameter("@m_id", SqlDbType.Int,4)}; parameters[0].Value = m_id; Tunnel.Model.Tunnel_MingXing model=new Tunnel.Model.Tunnel_MingXing(); DataSet ds= DbHelperSQL.RunProcedure("UP_Tunnel_MingXing_GetModel",parameters,"ds"); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["m_id"].ToString()!="") { model.m_id=int.Parse(ds.Tables[0].Rows[0]["m_id"].ToString()); } if(ds.Tables[0].Rows[0]["m_uid"].ToString()!="") { model.m_uid=int.Parse(ds.Tables[0].Rows[0]["m_uid"].ToString()); } model.m_img=ds.Tables[0].Rows[0]["m_img"].ToString(); model.m_content=ds.Tables[0].Rows[0]["m_content"].ToString(); if(ds.Tables[0].Rows[0]["m_year"].ToString()!="") { model.m_year=int.Parse(ds.Tables[0].Rows[0]["m_year"].ToString()); } if(ds.Tables[0].Rows[0]["m_moon"].ToString()!="") { model.m_moon=int.Parse(ds.Tables[0].Rows[0]["m_moon"].ToString()); } model.Title = ds.Tables[0].Rows[0]["m_title"].ToString(); return model; } else { return null; } }