/// <summary> /// 增加一条数据 /// </summary> public long Add(JY.Model.Information model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.BigInt, 8), new SqlParameter("@InformationTypeId", SqlDbType.Int, 4), new SqlParameter("@InformationName", SqlDbType.NVarChar, 50), new SqlParameter("@InformationContent", SqlDbType.NText), new SqlParameter("@InformationPic", SqlDbType.NVarChar, 50), new SqlParameter("@Description", SqlDbType.NText), new SqlParameter("@CreateDate", SqlDbType.DateTime), new SqlParameter("@Sort", SqlDbType.Int, 4), new SqlParameter("@IsDelete", SqlDbType.Bit, 1) }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.InformationTypeId; parameters[2].Value = model.InformationName; parameters[3].Value = model.InformationContent; parameters[4].Value = model.InformationPic; parameters[5].Value = model.Description; parameters[6].Value = model.CreateDate; parameters[7].Value = model.Sort; parameters[8].Value = model.IsDelete; DbHelperSQL.RunProcedure("Information_ADD", parameters, out rowsAffected); return((long)parameters[0].Value); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JY.Model.Information model) { int rowsAffected = 0; SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.BigInt, 8), new SqlParameter("@InformationTypeId", SqlDbType.Int, 4), new SqlParameter("@InformationName", SqlDbType.NVarChar, 50), new SqlParameter("@InformationContent", SqlDbType.NText), new SqlParameter("@InformationPic", SqlDbType.NVarChar, 50), new SqlParameter("@Description", SqlDbType.NText), new SqlParameter("@CreateDate", SqlDbType.DateTime), new SqlParameter("@Sort", SqlDbType.Int, 4), new SqlParameter("@IsDelete", SqlDbType.Bit, 1) }; parameters[0].Value = model.ID; parameters[1].Value = model.InformationTypeId; parameters[2].Value = model.InformationName; parameters[3].Value = model.InformationContent; parameters[4].Value = model.InformationPic; parameters[5].Value = model.Description; parameters[6].Value = model.CreateDate; parameters[7].Value = model.Sort; parameters[8].Value = model.IsDelete; DbHelperSQL.RunProcedure("Information_Update", parameters, out rowsAffected); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public JY.Model.Information GetModel(long ID) { SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.BigInt) }; parameters[0].Value = ID; JY.Model.Information model = new JY.Model.Information(); DataSet ds = DbHelperSQL.RunProcedure("Information_GetModel", parameters, "ds"); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = long.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["InformationTypeId"] != null && ds.Tables[0].Rows[0]["InformationTypeId"].ToString() != "") { model.InformationTypeId = int.Parse(ds.Tables[0].Rows[0]["InformationTypeId"].ToString()); } if (ds.Tables[0].Rows[0]["InformationName"] != null && ds.Tables[0].Rows[0]["InformationName"].ToString() != "") { model.InformationName = ds.Tables[0].Rows[0]["InformationName"].ToString(); } if (ds.Tables[0].Rows[0]["InformationContent"] != null && ds.Tables[0].Rows[0]["InformationContent"].ToString() != "") { model.InformationContent = ds.Tables[0].Rows[0]["InformationContent"].ToString(); } if (ds.Tables[0].Rows[0]["InformationPic"] != null && ds.Tables[0].Rows[0]["InformationPic"].ToString() != "") { model.InformationPic = ds.Tables[0].Rows[0]["InformationPic"].ToString(); } if (ds.Tables[0].Rows[0]["Description"] != null && ds.Tables[0].Rows[0]["Description"].ToString() != "") { model.Description = ds.Tables[0].Rows[0]["Description"].ToString(); } if (ds.Tables[0].Rows[0]["CreateDate"] != null && ds.Tables[0].Rows[0]["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(ds.Tables[0].Rows[0]["CreateDate"].ToString()); } if (ds.Tables[0].Rows[0]["Sort"] != null && ds.Tables[0].Rows[0]["Sort"].ToString() != "") { model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString()); } if (ds.Tables[0].Rows[0]["IsDelete"] != null && ds.Tables[0].Rows[0]["IsDelete"].ToString() != "") { if ((ds.Tables[0].Rows[0]["IsDelete"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsDelete"].ToString().ToLower() == "true")) { model.IsDelete = true; } else { model.IsDelete = false; } } return(model); } else { return(null); } }