public int Update(Model.WxKeysClassModel model) { int j = 0; int obj = 0; StringBuilder sql = new StringBuilder(); sql.Append(" Update Wx_MediaClass set Contents=@Contents,Types=@Types,Mid=@Mid,Sid=@Sid where Id=@Id"); SqlParameter[] para = new SqlParameter[] { new SqlParameter("@Types", model.Types), new SqlParameter("@Contents", model.Contents), new SqlParameter("@Mid", model.Mid), new SqlParameter("@Sid", model.Sid), new SqlParameter("@Id", model.Id) }; try { SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql.ToString(), para); obj = model.Id; } catch (Exception) { obj = 0; } return(obj); }
public int Add(Model.WxKeysClassModel model) { int j = 0; int obj = 0; StringBuilder sql = new StringBuilder(); sql.Append(" INSERT Wx_KeysClass("); sql.Append(" ClassName,"); sql.Append("StatusId,"); sql.Append("Keys,Contents,Mp3,Pic,Types,Mid,Sid"); sql.Append(" )values("); sql.Append("@ClassName,"); sql.Append("@StatusId,"); sql.Append("@Keys,@Contents,@Mp3,@Pic,@Types,@Mid,@Sid)"); SqlParameter[] para = new SqlParameter[] { new SqlParameter("@ClassName", model.ClassName), new SqlParameter("@StatusId", model.StatusId), new SqlParameter("@Keys", model.Keys), new SqlParameter("@Types", model.Types), new SqlParameter("@Contents", model.Contents), new SqlParameter("@Mp3", model.Mp3), new SqlParameter("@Pic", model.Pic), new SqlParameter("@Mid", model.Mid), new SqlParameter("@Sid", model.Sid) }; try { obj = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql.ToString(), para); // string a = SqlHelper.ExecuteDataTable(trans, CommandType.Text, "select @@IDENTITY").Rows[0][0].ToString(); // string sqls = "insert into wx_keys(classid,types,contents,mp3,pic,mid,sid) values('" + obj + "','" + m.Types + "','" + m.Contents + "','" + m.Mp3 + "','" + m.Pic + "','" + m.Mid + "','" + m.Sid + "') "; } catch (Exception) { obj = 0; } return(obj); }
public int Update(Model.WxKeysClassModel model) { int j = 0; int obj = 0; StringBuilder sql = new StringBuilder(); sql.Append(" Update Wx_KeysClass set ClassName=@ClassName,Mp3=@Mp3,Contents=@Contents,Pic=@Pic,Types=@Types,Mid=@Mid,Sid=@Sid,Keys=@Keys where Id=@Id"); SqlParameter[] para = new SqlParameter[] { new SqlParameter("@ClassName", model.ClassName), new SqlParameter("@StatusId", model.StatusId), new SqlParameter("@Keys", model.Keys), new SqlParameter("@Types", model.Types), new SqlParameter("@Contents", model.Contents), new SqlParameter("@Mp3", model.Mp3), new SqlParameter("@Pic", model.Pic), new SqlParameter("@Mid", model.Mid), new SqlParameter("@Sid", model.Sid), new SqlParameter("@Id", model.Id) }; try { SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql.ToString(), para); obj = model.Id; } catch (Exception) { obj = 0; } return(obj); }
public Model.WxKeysClassModel GetModel(int id) { StringBuilder sql = new StringBuilder(); sql.Append("select * from Wx_MediaClass where id=" + id); Model.WxKeysClassModel model = new Model.WxKeysClassModel(); SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.Text, sql.ToString()); if (dr.Read()) { model.Id = Convert.ToInt32(dr["Id"].ToString()); model.Sid = dr["Sid"].ToString(); model.Mid = dr["Mid"].ToString(); model.Contents = dr["contents"].ToString(); model.Types = dr["Types"].ToString(); } return(model); }