/// <summary> /// 增加一条数据 /// </summary> public int Add(Hotel_app.Model.Yxydw_jfbl model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Yxydw_jfbl("); strSql.Append("yydh,qymc,krly,fd_sl,bl)"); strSql.Append(" values ("); strSql.Append("@yydh,@qymc,@krly,@fd_sl,@bl)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@yydh", SqlDbType.VarChar, 50), new SqlParameter("@qymc", SqlDbType.VarChar, 50), new SqlParameter("@krly", SqlDbType.VarChar, 50), new SqlParameter("@fd_sl", SqlDbType.Decimal, 9), new SqlParameter("@bl", SqlDbType.Decimal, 9) }; parameters[0].Value = model.yydh; parameters[1].Value = model.qymc; parameters[2].Value = model.krly; parameters[3].Value = model.fd_sl; parameters[4].Value = model.bl; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Hotel_app.Model.Yxydw_jfbl GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,yydh,qymc,krly,fd_sl,bl from Yxydw_jfbl "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Hotel_app.Model.Yxydw_jfbl model = new Hotel_app.Model.Yxydw_jfbl(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["yydh"] != null && ds.Tables[0].Rows[0]["yydh"].ToString() != "") { model.yydh = ds.Tables[0].Rows[0]["yydh"].ToString(); } if (ds.Tables[0].Rows[0]["qymc"] != null && ds.Tables[0].Rows[0]["qymc"].ToString() != "") { model.qymc = ds.Tables[0].Rows[0]["qymc"].ToString(); } if (ds.Tables[0].Rows[0]["krly"] != null && ds.Tables[0].Rows[0]["krly"].ToString() != "") { model.krly = ds.Tables[0].Rows[0]["krly"].ToString(); } if (ds.Tables[0].Rows[0]["fd_sl"] != null && ds.Tables[0].Rows[0]["fd_sl"].ToString() != "") { model.fd_sl = decimal.Parse(ds.Tables[0].Rows[0]["fd_sl"].ToString()); } if (ds.Tables[0].Rows[0]["bl"] != null && ds.Tables[0].Rows[0]["bl"].ToString() != "") { model.bl = decimal.Parse(ds.Tables[0].Rows[0]["bl"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hotel_app.Model.Yxydw_jfbl model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Yxydw_jfbl set "); strSql.Append("yydh=@yydh,"); strSql.Append("qymc=@qymc,"); strSql.Append("krly=@krly,"); strSql.Append("fd_sl=@fd_sl,"); strSql.Append("bl=@bl"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@yydh", SqlDbType.VarChar, 50), new SqlParameter("@qymc", SqlDbType.VarChar, 50), new SqlParameter("@krly", SqlDbType.VarChar, 50), new SqlParameter("@fd_sl", SqlDbType.Decimal, 9), new SqlParameter("@bl", SqlDbType.Decimal, 9), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.yydh; parameters[1].Value = model.qymc; parameters[2].Value = model.krly; parameters[3].Value = model.fd_sl; parameters[4].Value = model.bl; parameters[5].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }