/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hotel_app.Model.BBfx_s_g_j_ye_ls model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update BBfx_s_g_j_ye_ls set "); strSql.Append("yydh=@yydh,"); strSql.Append("qymc=@qymc,"); strSql.Append("jzzt=@jzzt,"); strSql.Append("xydw=@xydw,"); strSql.Append("ff_total=@ff_total,"); strSql.Append("ds_total=@ds_total,"); strSql.Append("qt_total=@qt_total,"); strSql.Append("ye_total=@ye_total,"); strSql.Append("czy_temp=@czy_temp"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@yydh", SqlDbType.VarChar, 50), new SqlParameter("@qymc", SqlDbType.VarChar, 50), new SqlParameter("@jzzt", SqlDbType.VarChar, 200), new SqlParameter("@xydw", SqlDbType.VarChar, 200), new SqlParameter("@ff_total", SqlDbType.Decimal, 9), new SqlParameter("@ds_total", SqlDbType.Decimal, 9), new SqlParameter("@qt_total", SqlDbType.Decimal, 9), new SqlParameter("@ye_total", SqlDbType.Decimal, 9), new SqlParameter("@czy_temp", SqlDbType.VarChar, 50), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.yydh; parameters[1].Value = model.qymc; parameters[2].Value = model.jzzt; parameters[3].Value = model.xydw; parameters[4].Value = model.ff_total; parameters[5].Value = model.ds_total; parameters[6].Value = model.qt_total; parameters[7].Value = model.ye_total; parameters[8].Value = model.czy_temp; parameters[9].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Hotel_app.Model.BBfx_s_g_j_ye_ls model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into BBfx_s_g_j_ye_ls("); strSql.Append("yydh,qymc,jzzt,xydw,ff_total,ds_total,qt_total,ye_total,czy_temp)"); strSql.Append(" values ("); strSql.Append("@yydh,@qymc,@jzzt,@xydw,@ff_total,@ds_total,@qt_total,@ye_total,@czy_temp)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@yydh", SqlDbType.VarChar, 50), new SqlParameter("@qymc", SqlDbType.VarChar, 50), new SqlParameter("@jzzt", SqlDbType.VarChar, 200), new SqlParameter("@xydw", SqlDbType.VarChar, 200), new SqlParameter("@ff_total", SqlDbType.Decimal, 9), new SqlParameter("@ds_total", SqlDbType.Decimal, 9), new SqlParameter("@qt_total", SqlDbType.Decimal, 9), new SqlParameter("@ye_total", SqlDbType.Decimal, 9), new SqlParameter("@czy_temp", SqlDbType.VarChar, 50) }; parameters[0].Value = model.yydh; parameters[1].Value = model.qymc; parameters[2].Value = model.jzzt; parameters[3].Value = model.xydw; parameters[4].Value = model.ff_total; parameters[5].Value = model.ds_total; parameters[6].Value = model.qt_total; parameters[7].Value = model.ye_total; parameters[8].Value = model.czy_temp; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Hotel_app.Model.BBfx_s_g_j_ye_ls GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,yydh,qymc,jzzt,xydw,ff_total,ds_total,qt_total,ye_total,czy_temp from BBfx_s_g_j_ye_ls "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Hotel_app.Model.BBfx_s_g_j_ye_ls model = new Hotel_app.Model.BBfx_s_g_j_ye_ls(); 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]["jzzt"] != null && ds.Tables[0].Rows[0]["jzzt"].ToString() != "") { model.jzzt = ds.Tables[0].Rows[0]["jzzt"].ToString(); } if (ds.Tables[0].Rows[0]["xydw"] != null && ds.Tables[0].Rows[0]["xydw"].ToString() != "") { model.xydw = ds.Tables[0].Rows[0]["xydw"].ToString(); } if (ds.Tables[0].Rows[0]["ff_total"] != null && ds.Tables[0].Rows[0]["ff_total"].ToString() != "") { model.ff_total = decimal.Parse(ds.Tables[0].Rows[0]["ff_total"].ToString()); } if (ds.Tables[0].Rows[0]["ds_total"] != null && ds.Tables[0].Rows[0]["ds_total"].ToString() != "") { model.ds_total = decimal.Parse(ds.Tables[0].Rows[0]["ds_total"].ToString()); } if (ds.Tables[0].Rows[0]["qt_total"] != null && ds.Tables[0].Rows[0]["qt_total"].ToString() != "") { model.qt_total = decimal.Parse(ds.Tables[0].Rows[0]["qt_total"].ToString()); } if (ds.Tables[0].Rows[0]["ye_total"] != null && ds.Tables[0].Rows[0]["ye_total"].ToString() != "") { model.ye_total = decimal.Parse(ds.Tables[0].Rows[0]["ye_total"].ToString()); } if (ds.Tables[0].Rows[0]["czy_temp"] != null && ds.Tables[0].Rows[0]["czy_temp"].ToString() != "") { model.czy_temp = ds.Tables[0].Rows[0]["czy_temp"].ToString(); } return(model); } else { return(null); } }