/// <summary> /// 得到一个对象实体 /// </summary> public JMP.MDL.jmp_app_monitor_time_range GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, AppMonitorId, WhichHour, Minutes, CreatedOn, CreatedBy, ModifiedOn, ModifiedBy "); strSql.Append(" from jmp_app_monitor_time_range "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; JMP.MDL.jmp_app_monitor_time_range model = new JMP.MDL.jmp_app_monitor_time_range(); 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]["AppMonitorId"].ToString() != "") { model.AppMonitorId = int.Parse(ds.Tables[0].Rows[0]["AppMonitorId"].ToString()); } if (ds.Tables[0].Rows[0]["WhichHour"].ToString() != "") { model.WhichHour = int.Parse(ds.Tables[0].Rows[0]["WhichHour"].ToString()); } if (ds.Tables[0].Rows[0]["Minutes"].ToString() != "") { model.Minutes = int.Parse(ds.Tables[0].Rows[0]["Minutes"].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]["CreatedBy"].ToString() != "") { model.CreatedBy = int.Parse(ds.Tables[0].Rows[0]["CreatedBy"].ToString()); } if (ds.Tables[0].Rows[0]["ModifiedOn"].ToString() != "") { model.ModifiedOn = DateTime.Parse(ds.Tables[0].Rows[0]["ModifiedOn"].ToString()); } if (ds.Tables[0].Rows[0]["ModifiedBy"].ToString() != "") { model.ModifiedBy = int.Parse(ds.Tables[0].Rows[0]["ModifiedBy"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 获得数据列表 /// </summary> public List <JMP.MDL.jmp_app_monitor_time_range> DataTableToList(DataTable dt) { List <JMP.MDL.jmp_app_monitor_time_range> modelList = new List <JMP.MDL.jmp_app_monitor_time_range>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { JMP.MDL.jmp_app_monitor_time_range model; for (int n = 0; n < rowsCount; n++) { model = new JMP.MDL.jmp_app_monitor_time_range(); if (dt.Rows[n]["Id"].ToString() != "") { model.Id = int.Parse(dt.Rows[n]["Id"].ToString()); } if (dt.Rows[n]["AppMonitorId"].ToString() != "") { model.AppMonitorId = int.Parse(dt.Rows[n]["AppMonitorId"].ToString()); } if (dt.Rows[n]["WhichHour"].ToString() != "") { model.WhichHour = int.Parse(dt.Rows[n]["WhichHour"].ToString()); } if (dt.Rows[n]["Minutes"].ToString() != "") { model.Minutes = int.Parse(dt.Rows[n]["Minutes"].ToString()); } if (dt.Rows[n]["CreatedOn"].ToString() != "") { model.CreatedOn = DateTime.Parse(dt.Rows[n]["CreatedOn"].ToString()); } if (dt.Rows[n]["CreatedBy"].ToString() != "") { model.CreatedBy = int.Parse(dt.Rows[n]["CreatedBy"].ToString()); } if (dt.Rows[n]["ModifiedOn"].ToString() != "") { model.ModifiedOn = DateTime.Parse(dt.Rows[n]["ModifiedOn"].ToString()); } if (dt.Rows[n]["ModifiedBy"].ToString() != "") { model.ModifiedBy = int.Parse(dt.Rows[n]["ModifiedBy"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.MDL.jmp_app_monitor_time_range model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update jmp_app_monitor_time_range set "); strSql.Append(" AppMonitorId = @AppMonitorId , "); strSql.Append(" WhichHour = @WhichHour , "); strSql.Append(" Minutes = @Minutes , "); strSql.Append(" CreatedOn = @CreatedOn , "); strSql.Append(" CreatedBy = @CreatedBy , "); strSql.Append(" ModifiedOn = @ModifiedOn , "); strSql.Append(" ModifiedBy = @ModifiedBy "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@AppMonitorId", SqlDbType.Int, 4), new SqlParameter("@WhichHour", SqlDbType.Int, 4), new SqlParameter("@Minutes", SqlDbType.Int, 4), new SqlParameter("@CreatedOn", SqlDbType.DateTime), new SqlParameter("@CreatedBy", SqlDbType.Int, 4), new SqlParameter("@ModifiedOn", SqlDbType.DateTime), new SqlParameter("@ModifiedBy", SqlDbType.Int, 4) }; parameters[0].Value = model.Id; parameters[1].Value = model.AppMonitorId; parameters[2].Value = model.WhichHour; parameters[3].Value = model.Minutes; parameters[4].Value = model.CreatedOn; parameters[5].Value = model.CreatedBy; parameters[6].Value = model.ModifiedOn; parameters[7].Value = model.ModifiedBy; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.jmp_app_monitor_time_range model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into jmp_app_monitor_time_range("); strSql.Append("AppMonitorId,WhichHour,Minutes,CreatedOn,CreatedBy,ModifiedOn,ModifiedBy"); strSql.Append(") values ("); strSql.Append("@AppMonitorId,@WhichHour,@Minutes,@CreatedOn,@CreatedBy,@ModifiedOn,@ModifiedBy"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@AppMonitorId", SqlDbType.Int, 4), new SqlParameter("@WhichHour", SqlDbType.Int, 4), new SqlParameter("@Minutes", SqlDbType.Int, 4), new SqlParameter("@CreatedOn", SqlDbType.DateTime), new SqlParameter("@CreatedBy", SqlDbType.Int, 4), new SqlParameter("@ModifiedOn", SqlDbType.DateTime), new SqlParameter("@ModifiedBy", SqlDbType.Int, 4) }; parameters[0].Value = model.AppMonitorId; parameters[1].Value = model.WhichHour; parameters[2].Value = model.Minutes; parameters[3].Value = model.CreatedOn; parameters[4].Value = model.CreatedBy; parameters[5].Value = model.ModifiedOn; parameters[6].Value = model.ModifiedBy; 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_app_monitor_time_range model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.jmp_app_monitor_time_range model) { return(dal.Add(model)); }