/// <summary> /// 更新一条数据 /// </summary> public void Update(ManagementCenter.Model.HKStockInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update HKStockInfo set "); strSql.Append("StockName=@StockName,"); strSql.Append("StockPinYin=@StockPinYin,"); strSql.Append("turnovervolume=@turnovervolume,"); strSql.Append("Paydt=@Paydt,"); strSql.Append("Nindcd=@Nindcd,"); strSql.Append("PerHandThighOrShare=@PerHandThighOrShare,"); strSql.Append("IsSellNull=@IsSellNull"); strSql.Append(" where StockCode=@StockCode "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "StockCode", DbType.String, model.StockCode); db.AddInParameter(dbCommand, "StockName", DbType.String, model.StockName); db.AddInParameter(dbCommand, "StockPinYin", DbType.String, model.StockPinYin); db.AddInParameter(dbCommand, "turnovervolume", DbType.Double, model.turnovervolume); db.AddInParameter(dbCommand, "Paydt", DbType.String, model.Paydt); db.AddInParameter(dbCommand, "Nindcd", DbType.String, model.Nindcd); db.AddInParameter(dbCommand, "PerHandThighOrShare", DbType.Int32, model.PerHandThighOrShare); db.AddInParameter(dbCommand, "IsSellNull", DbType.Int32, model.IsSellNull); db.ExecuteNonQuery(dbCommand); }
/// <summary> /// 得到一个对象实体 /// </summary> public ManagementCenter.Model.HKStockInfo GetModel(string StockCode) { StringBuilder strSql = new StringBuilder(); strSql.Append("select StockCode,StockName,StockPinYin,turnovervolume,Paydt,Nindcd,PerHandThighOrShare,IsSellNull from HKStockInfo "); strSql.Append(" where StockCode=@StockCode "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "StockCode", DbType.String, StockCode); ManagementCenter.Model.HKStockInfo model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(ManagementCenter.Model.HKStockInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into HKStockInfo("); strSql.Append("StockCode,StockName,StockPinYin,turnovervolume,Paydt,Nindcd,PerHandThighOrShare,IsSellNull)"); strSql.Append(" values ("); strSql.Append("@StockCode,@StockName,@StockPinYin,@turnovervolume,@Paydt,@Nindcd,@PerHandThighOrShare,@IsSellNull)"); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "StockCode", DbType.String, model.StockCode); db.AddInParameter(dbCommand, "StockName", DbType.String, model.StockName); db.AddInParameter(dbCommand, "StockPinYin", DbType.String, model.StockPinYin); db.AddInParameter(dbCommand, "turnovervolume", DbType.Double, model.turnovervolume); db.AddInParameter(dbCommand, "Paydt", DbType.String, model.Paydt); db.AddInParameter(dbCommand, "Nindcd", DbType.String, model.Nindcd); db.AddInParameter(dbCommand, "PerHandThighOrShare", DbType.Int32, model.PerHandThighOrShare); db.AddInParameter(dbCommand, "IsSellNull", DbType.Int32, model.IsSellNull); db.ExecuteNonQuery(dbCommand); }
/// <summary> /// 对象实体绑定数据 /// </summary> public ManagementCenter.Model.HKStockInfo ReaderBind(IDataReader dataReader) { ManagementCenter.Model.HKStockInfo model = new ManagementCenter.Model.HKStockInfo(); object ojb; model.StockCode = dataReader["StockCode"].ToString(); model.StockName = dataReader["StockName"].ToString(); model.StockPinYin = dataReader["StockPinYin"].ToString(); ojb = dataReader["turnovervolume"]; if (ojb != null && ojb != DBNull.Value) { model.turnovervolume = (double)ojb; } model.Paydt = dataReader["Paydt"].ToString(); model.Nindcd = dataReader["Nindcd"].ToString(); ojb = dataReader["PerHandThighOrShare"]; if (ojb != null && ojb != DBNull.Value) { model.PerHandThighOrShare = (int)ojb; } ojb = dataReader["IsSellNull"]; if (ojb != null && ojb != DBNull.Value) { model.IsSellNull = (int)ojb; } ojb = dataReader["BreedClassID"]; if (ojb != null && ojb != DBNull.Value) { model.BreedClassID = (int)ojb; } //ojb = dataReader["CodeFormSource"]; //if (ojb != null && ojb != DBNull.Value) //{ // model.CodeFromSource = (int)ojb; //} return(model); }