/// <summary> /// 对象实体绑定数据 /// </summary> public ManagementCenter.Model.Profession ReaderBind(IDataReader dataReader) { ManagementCenter.Model.Profession model = new ManagementCenter.Model.Profession(); model.Nindcd = dataReader["Nindcd"].ToString(); model.Nindnme = dataReader["Nindnme"].ToString(); model.EnNindnme = dataReader["EnNindnme"].ToString(); return(model); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(ManagementCenter.Model.Profession model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ProfessionInfo set "); strSql.Append("Nindnme=@Nindnme,"); strSql.Append("EnNindnme=@EnNindnme"); strSql.Append(" where Nindcd=@Nindcd "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "Nindcd", DbType.String, model.Nindcd); db.AddInParameter(dbCommand, "Nindnme", DbType.String, model.Nindnme); db.AddInParameter(dbCommand, "EnNindnme", DbType.String, model.EnNindnme); db.ExecuteNonQuery(dbCommand); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(ManagementCenter.Model.Profession model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ProfessionInfo("); strSql.Append("Nindcd,Nindnme,EnNindnme)"); strSql.Append(" values ("); strSql.Append("@Nindcd,@Nindnme,@EnNindnme)"); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "Nindcd", DbType.String, model.Nindcd); db.AddInParameter(dbCommand, "Nindnme", DbType.String, model.Nindnme); db.AddInParameter(dbCommand, "EnNindnme", DbType.String, model.EnNindnme); db.ExecuteNonQuery(dbCommand); }
/// <summary> /// 得到一个对象实体 /// </summary> public ManagementCenter.Model.Profession GetModel(string Nindcd) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Nindcd,Nindnme,EnNindnme from ProfessionInfo "); strSql.Append(" where Nindcd=@Nindcd "); Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()); db.AddInParameter(dbCommand, "Nindcd", DbType.String, Nindcd); ManagementCenter.Model.Profession model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
/// <summary> /// 窗体加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LastTradingPriceManagerUI_Load(object sender, EventArgs e) { ManagementCenter.Model.Profession pro; List <ManagementCenter.Model.Profession> list = new List <ManagementCenter.Model.Profession>(); pro = new ManagementCenter.Model.Profession(); pro.EnNindnme = "aa"; pro.Nindcd = "aa2"; pro.Nindnme = "aa3"; list.Add(pro); pro = new ManagementCenter.Model.Profession(); pro.EnNindnme = "bb"; pro.Nindcd = "bb2"; pro.Nindnme = "bb3"; list.Add(pro); gridControl1.DataSource = list; btnReckoning.Enabled = true; }