/// <summary> /// 得到一个对象实体 /// </summary> public JMP.MDL.jmp_channel_app_mapping GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, ChannelId, AppId, CreatedOn, CreatedByUerId, CreatedByUserName "); strSql.Append(" from jmp_channel_app_mapping "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; JMP.MDL.jmp_channel_app_mapping model = new JMP.MDL.jmp_channel_app_mapping(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } if (ds.Tables[0].Rows[0]["ChannelId"].ToString() != "") { model.ChannelId = int.Parse(ds.Tables[0].Rows[0]["ChannelId"].ToString()); } if (ds.Tables[0].Rows[0]["AppId"].ToString() != "") { model.AppId = int.Parse(ds.Tables[0].Rows[0]["AppId"].ToString()); } if (ds.Tables[0].Rows[0]["CreatedOn"].ToString() != "") { model.CreatedOn = DateTime.Parse(ds.Tables[0].Rows[0]["CreatedOn"].ToString()); } if (ds.Tables[0].Rows[0]["CreatedByUerId"].ToString() != "") { model.CreatedByUerId = int.Parse(ds.Tables[0].Rows[0]["CreatedByUerId"].ToString()); } model.CreatedByUserName = ds.Tables[0].Rows[0]["CreatedByUserName"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.MDL.jmp_channel_app_mapping model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update jmp_channel_app_mapping set "); strSql.Append(" ChannelId = @ChannelId , "); strSql.Append(" AppId = @AppId , "); strSql.Append(" CreatedOn = @CreatedOn , "); strSql.Append(" CreatedByUerId = @CreatedByUerId , "); strSql.Append(" CreatedByUserName = @CreatedByUserName "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@ChannelId", SqlDbType.Int, 4), new SqlParameter("@AppId", SqlDbType.Int, 4), new SqlParameter("@CreatedOn", SqlDbType.DateTime), new SqlParameter("@CreatedByUerId", SqlDbType.Int, 4), new SqlParameter("@CreatedByUserName", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.Id; parameters[1].Value = model.ChannelId; parameters[2].Value = model.AppId; parameters[3].Value = model.CreatedOn; parameters[4].Value = model.CreatedByUerId; parameters[5].Value = model.CreatedByUserName; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 获得数据列表 /// </summary> public List <JMP.MDL.jmp_channel_app_mapping> DataTableToList(DataTable dt) { List <JMP.MDL.jmp_channel_app_mapping> modelList = new List <JMP.MDL.jmp_channel_app_mapping>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { JMP.MDL.jmp_channel_app_mapping model; for (int n = 0; n < rowsCount; n++) { model = new JMP.MDL.jmp_channel_app_mapping(); if (dt.Rows[n]["Id"].ToString() != "") { model.Id = int.Parse(dt.Rows[n]["Id"].ToString()); } if (dt.Rows[n]["ChannelId"].ToString() != "") { model.ChannelId = int.Parse(dt.Rows[n]["ChannelId"].ToString()); } if (dt.Rows[n]["AppId"].ToString() != "") { model.AppId = int.Parse(dt.Rows[n]["AppId"].ToString()); } if (dt.Rows[n]["CreatedOn"].ToString() != "") { model.CreatedOn = DateTime.Parse(dt.Rows[n]["CreatedOn"].ToString()); } if (dt.Rows[n]["CreatedByUerId"].ToString() != "") { model.CreatedByUerId = int.Parse(dt.Rows[n]["CreatedByUerId"].ToString()); } model.CreatedByUserName = dt.Rows[n]["CreatedByUserName"].ToString(); modelList.Add(model); } } return(modelList); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.jmp_channel_app_mapping model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into jmp_channel_app_mapping("); strSql.Append("ChannelId,AppId,CreatedOn,CreatedByUerId,CreatedByUserName"); strSql.Append(") values ("); strSql.Append("@ChannelId,@AppId,@CreatedOn,@CreatedByUerId,@CreatedByUserName"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@ChannelId", SqlDbType.Int, 4), new SqlParameter("@AppId", SqlDbType.Int, 4), new SqlParameter("@CreatedOn", SqlDbType.DateTime), new SqlParameter("@CreatedByUerId", SqlDbType.Int, 4), new SqlParameter("@CreatedByUserName", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.ChannelId; parameters[1].Value = model.AppId; parameters[2].Value = model.CreatedOn; parameters[3].Value = model.CreatedByUerId; parameters[4].Value = model.CreatedByUserName; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.MDL.jmp_channel_app_mapping model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.jmp_channel_app_mapping model) { return(dal.Add(model)); }