/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hotel_app.Model.Q_ff_xyxf model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Q_ff_xyxf set "); strSql.Append("yydh=@yydh,"); strSql.Append("qymc=@qymc,"); strSql.Append("fyrx=@fyrx,"); strSql.Append("xfdr=@xfdr,"); strSql.Append("xfrb=@xfrb,"); strSql.Append("xfxm=@xfxm,"); strSql.Append("xfsl=@xfsl,"); strSql.Append("jjje=@jjje,"); strSql.Append("xfje=@xfje,"); strSql.Append("is_top=@is_top,"); strSql.Append("is_select=@is_select,"); strSql.Append("mxbh=@mxbh"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@yydh", SqlDbType.VarChar, 50), new SqlParameter("@qymc", SqlDbType.VarChar, 50), new SqlParameter("@fyrx", SqlDbType.VarChar, 50), new SqlParameter("@xfdr", SqlDbType.VarChar, 50), new SqlParameter("@xfrb", SqlDbType.VarChar, 50), new SqlParameter("@xfxm", SqlDbType.VarChar, 50), new SqlParameter("@xfsl", SqlDbType.Decimal, 9), new SqlParameter("@jjje", SqlDbType.Decimal, 9), new SqlParameter("@xfje", SqlDbType.Decimal, 9), new SqlParameter("@is_top", SqlDbType.Bit, 1), new SqlParameter("@is_select", SqlDbType.Bit, 1), new SqlParameter("@mxbh", SqlDbType.VarChar, 50), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.yydh; parameters[1].Value = model.qymc; parameters[2].Value = model.fyrx; parameters[3].Value = model.xfdr; parameters[4].Value = model.xfrb; parameters[5].Value = model.xfxm; parameters[6].Value = model.xfsl; parameters[7].Value = model.jjje; parameters[8].Value = model.xfje; parameters[9].Value = model.is_top; parameters[10].Value = model.is_select; parameters[11].Value = model.mxbh; parameters[12].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.Q_ff_xyxf model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Q_ff_xyxf("); strSql.Append("yydh,qymc,fyrx,xfdr,xfrb,xfxm,xfsl,jjje,xfje,is_top,is_select,mxbh)"); strSql.Append(" values ("); strSql.Append("@yydh,@qymc,@fyrx,@xfdr,@xfrb,@xfxm,@xfsl,@jjje,@xfje,@is_top,@is_select,@mxbh)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@yydh", SqlDbType.VarChar, 50), new SqlParameter("@qymc", SqlDbType.VarChar, 50), new SqlParameter("@fyrx", SqlDbType.VarChar, 50), new SqlParameter("@xfdr", SqlDbType.VarChar, 50), new SqlParameter("@xfrb", SqlDbType.VarChar, 50), new SqlParameter("@xfxm", SqlDbType.VarChar, 50), new SqlParameter("@xfsl", SqlDbType.Decimal, 9), new SqlParameter("@jjje", SqlDbType.Decimal, 9), new SqlParameter("@xfje", SqlDbType.Decimal, 9), new SqlParameter("@is_top", SqlDbType.Bit, 1), new SqlParameter("@is_select", SqlDbType.Bit, 1), new SqlParameter("@mxbh", SqlDbType.VarChar, 50) }; parameters[0].Value = model.yydh; parameters[1].Value = model.qymc; parameters[2].Value = model.fyrx; parameters[3].Value = model.xfdr; parameters[4].Value = model.xfrb; parameters[5].Value = model.xfxm; parameters[6].Value = model.xfsl; parameters[7].Value = model.jjje; parameters[8].Value = model.xfje; parameters[9].Value = model.is_top; parameters[10].Value = model.is_select; parameters[11].Value = model.mxbh; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
public string add_edit_delete_Q_ff_xyxf(string id, string yydh, string qymc, string fyrx, string xfdr, string xfrb, string xfxm, decimal xfsl, decimal xfje, string add_edit_delete, string czy, DateTime czsj, string cznr, string xxzs, decimal jjje, string mxbh) { string s = common_file.common_app.get_failure; BLL.Q_ff_xyxf B_Q_ff_xyxf = new Hotel_app.BLL.Q_ff_xyxf(); Model.Q_ff_xyxf M_Q_ff_xyxf = new Hotel_app.Model.Q_ff_xyxf(); if (add_edit_delete == common_file.common_app.get_add) { M_Q_ff_xyxf.yydh = yydh; M_Q_ff_xyxf.qymc = qymc; M_Q_ff_xyxf.fyrx = fyrx; M_Q_ff_xyxf.xfdr = xfdr; M_Q_ff_xyxf.xfrb = xfrb; M_Q_ff_xyxf.xfxm = xfxm; M_Q_ff_xyxf.xfsl = xfsl; M_Q_ff_xyxf.jjje = jjje; M_Q_ff_xyxf.xfje = xfje; M_Q_ff_xyxf.mxbh = mxbh; B_Q_ff_xyxf.Add(M_Q_ff_xyxf); s = common_file.common_app.get_suc; } else if (add_edit_delete == common_file.common_app.get_edit) { M_Q_ff_xyxf = B_Q_ff_xyxf.GetModel(int.Parse(id)); M_Q_ff_xyxf.fyrx = fyrx; M_Q_ff_xyxf.xfdr = xfdr; M_Q_ff_xyxf.xfrb = xfrb; M_Q_ff_xyxf.xfxm = xfxm; M_Q_ff_xyxf.xfsl = xfsl; M_Q_ff_xyxf.jjje = jjje; M_Q_ff_xyxf.xfje = xfje; M_Q_ff_xyxf.mxbh = mxbh; B_Q_ff_xyxf.Update(M_Q_ff_xyxf); s = common_file.common_app.get_suc; } else if (add_edit_delete == common_file.common_app.get_delete) { B_Q_ff_xyxf.Delete(int.Parse(id)); s = common_file.common_app.get_suc; } return(s); }
/// <summary> /// 得到一个对象实体 /// </summary> public Hotel_app.Model.Q_ff_xyxf GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,yydh,qymc,fyrx,xfdr,xfrb,xfxm,xfsl,jjje,xfje,is_top,is_select,mxbh from Q_ff_xyxf "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Hotel_app.Model.Q_ff_xyxf model = new Hotel_app.Model.Q_ff_xyxf(); 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]["fyrx"] != null && ds.Tables[0].Rows[0]["fyrx"].ToString() != "") { model.fyrx = ds.Tables[0].Rows[0]["fyrx"].ToString(); } if (ds.Tables[0].Rows[0]["xfdr"] != null && ds.Tables[0].Rows[0]["xfdr"].ToString() != "") { model.xfdr = ds.Tables[0].Rows[0]["xfdr"].ToString(); } if (ds.Tables[0].Rows[0]["xfrb"] != null && ds.Tables[0].Rows[0]["xfrb"].ToString() != "") { model.xfrb = ds.Tables[0].Rows[0]["xfrb"].ToString(); } if (ds.Tables[0].Rows[0]["xfxm"] != null && ds.Tables[0].Rows[0]["xfxm"].ToString() != "") { model.xfxm = ds.Tables[0].Rows[0]["xfxm"].ToString(); } if (ds.Tables[0].Rows[0]["xfsl"] != null && ds.Tables[0].Rows[0]["xfsl"].ToString() != "") { model.xfsl = decimal.Parse(ds.Tables[0].Rows[0]["xfsl"].ToString()); } if (ds.Tables[0].Rows[0]["jjje"] != null && ds.Tables[0].Rows[0]["jjje"].ToString() != "") { model.jjje = decimal.Parse(ds.Tables[0].Rows[0]["jjje"].ToString()); } if (ds.Tables[0].Rows[0]["xfje"] != null && ds.Tables[0].Rows[0]["xfje"].ToString() != "") { model.xfje = decimal.Parse(ds.Tables[0].Rows[0]["xfje"].ToString()); } if (ds.Tables[0].Rows[0]["is_top"] != null && ds.Tables[0].Rows[0]["is_top"].ToString() != "") { if ((ds.Tables[0].Rows[0]["is_top"].ToString() == "1") || (ds.Tables[0].Rows[0]["is_top"].ToString().ToLower() == "true")) { model.is_top = true; } else { model.is_top = false; } } if (ds.Tables[0].Rows[0]["is_select"] != null && ds.Tables[0].Rows[0]["is_select"].ToString() != "") { if ((ds.Tables[0].Rows[0]["is_select"].ToString() == "1") || (ds.Tables[0].Rows[0]["is_select"].ToString().ToLower() == "true")) { model.is_select = true; } else { model.is_select = false; } } if (ds.Tables[0].Rows[0]["mxbh"] != null && ds.Tables[0].Rows[0]["mxbh"].ToString() != "") { model.mxbh = ds.Tables[0].Rows[0]["mxbh"].ToString(); } return(model); } else { return(null); } }