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