/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.Model.DxGlobalLogError model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update DxGlobalLogError set "); strSql.Append(" CreatedOn = @CreatedOn , "); strSql.Append(" ClientId = @ClientId , "); strSql.Append(" ClientName = @ClientName , "); strSql.Append(" UserId = @UserId , "); strSql.Append(" TypeValue = @TypeValue , "); strSql.Append(" IpAddress = @IpAddress , "); strSql.Append(" Location = @Location , "); strSql.Append(" Summary = @Summary , "); strSql.Append(" Message = @Message "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@CreatedOn", SqlDbType.DateTime), new SqlParameter("@ClientId", SqlDbType.Int, 4), new SqlParameter("@ClientName", SqlDbType.NVarChar, 30), new SqlParameter("@UserId", SqlDbType.Int, 4), new SqlParameter("@TypeValue", SqlDbType.Int, 4), new SqlParameter("@IpAddress", SqlDbType.NVarChar, 30), new SqlParameter("@Location", SqlDbType.NVarChar, 255), new SqlParameter("@Summary", SqlDbType.NVarChar, 500), new SqlParameter("@Message", SqlDbType.NVarChar, -1) }; parameters[0].Value = model.Id; parameters[1].Value = model.CreatedOn; parameters[2].Value = model.ClientId; parameters[3].Value = model.ClientName; parameters[4].Value = model.UserId; parameters[5].Value = model.TypeValue; parameters[6].Value = model.IpAddress; parameters[7].Value = model.Location; parameters[8].Value = model.Summary; parameters[9].Value = model.Message; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public JMP.Model.DxGlobalLogError GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, CreatedOn, ClientId, ClientName, UserId, TypeValue, IpAddress, Location, Summary, Message "); strSql.Append(" from DxGlobalLogError "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; JMP.Model.DxGlobalLogError model = new JMP.Model.DxGlobalLogError(); 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]["CreatedOn"].ToString() != "") { model.CreatedOn = DateTime.Parse(ds.Tables[0].Rows[0]["CreatedOn"].ToString()); } if (ds.Tables[0].Rows[0]["ClientId"].ToString() != "") { model.ClientId = int.Parse(ds.Tables[0].Rows[0]["ClientId"].ToString()); } model.ClientName = ds.Tables[0].Rows[0]["ClientName"].ToString(); if (ds.Tables[0].Rows[0]["UserId"].ToString() != "") { model.UserId = int.Parse(ds.Tables[0].Rows[0]["UserId"].ToString()); } if (ds.Tables[0].Rows[0]["TypeValue"].ToString() != "") { model.TypeValue = int.Parse(ds.Tables[0].Rows[0]["TypeValue"].ToString()); } model.IpAddress = ds.Tables[0].Rows[0]["IpAddress"].ToString(); model.Location = ds.Tables[0].Rows[0]["Location"].ToString(); model.Summary = ds.Tables[0].Rows[0]["Summary"].ToString(); model.Message = ds.Tables[0].Rows[0]["Message"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.Model.DxGlobalLogError model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into DxGlobalLogError("); strSql.Append("CreatedOn,ClientId,ClientName,UserId,TypeValue,IpAddress,Location,Summary,Message"); strSql.Append(") values ("); strSql.Append("@CreatedOn,@ClientId,@ClientName,@UserId,@TypeValue,@IpAddress,@Location,@Summary,@Message"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CreatedOn", SqlDbType.DateTime), new SqlParameter("@ClientId", SqlDbType.Int, 4), new SqlParameter("@ClientName", SqlDbType.NVarChar, 30), new SqlParameter("@UserId", SqlDbType.Int, 4), new SqlParameter("@TypeValue", SqlDbType.Int, 4), new SqlParameter("@IpAddress", SqlDbType.NVarChar, 30), new SqlParameter("@Location", SqlDbType.NVarChar, 255), new SqlParameter("@Summary", SqlDbType.NVarChar, 500), new SqlParameter("@Message", SqlDbType.NVarChar, -1) }; parameters[0].Value = model.CreatedOn; parameters[1].Value = model.ClientId; parameters[2].Value = model.ClientName; parameters[3].Value = model.UserId; parameters[4].Value = model.TypeValue; parameters[5].Value = model.IpAddress; parameters[6].Value = model.Location; parameters[7].Value = model.Summary; parameters[8].Value = model.Message; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 获得数据列表 /// </summary> public List <JMP.Model.DxGlobalLogError> DataTableToList(DataTable dt) { List <JMP.Model.DxGlobalLogError> modelList = new List <JMP.Model.DxGlobalLogError>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { JMP.Model.DxGlobalLogError model; for (int n = 0; n < rowsCount; n++) { model = new JMP.Model.DxGlobalLogError(); if (dt.Rows[n]["Id"].ToString() != "") { model.Id = int.Parse(dt.Rows[n]["Id"].ToString()); } if (dt.Rows[n]["CreatedOn"].ToString() != "") { model.CreatedOn = DateTime.Parse(dt.Rows[n]["CreatedOn"].ToString()); } if (dt.Rows[n]["ClientId"].ToString() != "") { model.ClientId = int.Parse(dt.Rows[n]["ClientId"].ToString()); } model.ClientName = dt.Rows[n]["ClientName"].ToString(); if (dt.Rows[n]["UserId"].ToString() != "") { model.UserId = int.Parse(dt.Rows[n]["UserId"].ToString()); } if (dt.Rows[n]["TypeValue"].ToString() != "") { model.TypeValue = int.Parse(dt.Rows[n]["TypeValue"].ToString()); } model.IpAddress = dt.Rows[n]["IpAddress"].ToString(); model.Location = dt.Rows[n]["Location"].ToString(); model.Summary = dt.Rows[n]["Summary"].ToString(); model.Message = dt.Rows[n]["Message"].ToString(); modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.Model.DxGlobalLogError model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.Model.DxGlobalLogError model) { return(dal.Add(model)); }