/// <summary> /// 增加一条数据 /// </summary> public bool Add(Hotel_app.Model.VIEW_tt_krlb model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into VIEW_tt_krlb("); strSql.Append("yydh,qymc,lsbh,krxm,krly,ddsj,lksj,Expr1,fjrb,fjbh,lzfs,sjfjjg,xsy,main_sec,ddbh)"); strSql.Append(" values ("); strSql.Append("@yydh,@qymc,@lsbh,@krxm,@krly,@ddsj,@lksj,@Expr1,@fjrb,@fjbh,@lzfs,@sjfjjg,@xsy,@main_sec,@ddbh)"); SqlParameter[] parameters = { new SqlParameter("@yydh", SqlDbType.VarChar, 50), new SqlParameter("@qymc", SqlDbType.VarChar, 50), new SqlParameter("@lsbh", SqlDbType.VarChar, 50), new SqlParameter("@krxm", SqlDbType.VarChar, 50), new SqlParameter("@krly", SqlDbType.VarChar, 50), new SqlParameter("@ddsj", SqlDbType.DateTime), new SqlParameter("@lksj", SqlDbType.DateTime), new SqlParameter("@Expr1", SqlDbType.VarChar, 50), new SqlParameter("@fjrb", SqlDbType.VarChar, 50), new SqlParameter("@fjbh", SqlDbType.VarChar, 50), new SqlParameter("@lzfs", SqlDbType.Decimal, 9), new SqlParameter("@sjfjjg", SqlDbType.Decimal, 9), new SqlParameter("@xsy", SqlDbType.VarChar, 50), new SqlParameter("@main_sec", SqlDbType.VarChar, 50), new SqlParameter("@ddbh", SqlDbType.VarChar, 50) }; parameters[0].Value = model.yydh; parameters[1].Value = model.qymc; parameters[2].Value = model.lsbh; parameters[3].Value = model.krxm; parameters[4].Value = model.krly; parameters[5].Value = model.ddsj; parameters[6].Value = model.lksj; parameters[7].Value = model.Expr1; parameters[8].Value = model.fjrb; parameters[9].Value = model.fjbh; parameters[10].Value = model.lzfs; parameters[11].Value = model.sjfjjg; parameters[12].Value = model.xsy; parameters[13].Value = model.main_sec; parameters[14].Value = model.ddbh; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hotel_app.Model.VIEW_tt_krlb model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update VIEW_tt_krlb set "); strSql.Append("yydh=@yydh,"); strSql.Append("qymc=@qymc,"); strSql.Append("lsbh=@lsbh,"); strSql.Append("krxm=@krxm,"); strSql.Append("krly=@krly,"); strSql.Append("ddsj=@ddsj,"); strSql.Append("lksj=@lksj,"); strSql.Append("Expr1=@Expr1,"); strSql.Append("fjrb=@fjrb,"); strSql.Append("fjbh=@fjbh,"); strSql.Append("lzfs=@lzfs,"); strSql.Append("sjfjjg=@sjfjjg,"); strSql.Append("xsy=@xsy,"); strSql.Append("main_sec=@main_sec,"); strSql.Append("ddbh=@ddbh"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@yydh", SqlDbType.VarChar, 50), new SqlParameter("@qymc", SqlDbType.VarChar, 50), new SqlParameter("@lsbh", SqlDbType.VarChar, 50), new SqlParameter("@krxm", SqlDbType.VarChar, 50), new SqlParameter("@krly", SqlDbType.VarChar, 50), new SqlParameter("@ddsj", SqlDbType.DateTime), new SqlParameter("@lksj", SqlDbType.DateTime), new SqlParameter("@Expr1", SqlDbType.VarChar, 50), new SqlParameter("@fjrb", SqlDbType.VarChar, 50), new SqlParameter("@fjbh", SqlDbType.VarChar, 50), new SqlParameter("@lzfs", SqlDbType.Decimal, 9), new SqlParameter("@sjfjjg", SqlDbType.Decimal, 9), new SqlParameter("@xsy", SqlDbType.VarChar, 50), new SqlParameter("@main_sec", SqlDbType.VarChar, 50), new SqlParameter("@ddbh", SqlDbType.VarChar, 50) }; parameters[0].Value = model.yydh; parameters[1].Value = model.qymc; parameters[2].Value = model.lsbh; parameters[3].Value = model.krxm; parameters[4].Value = model.krly; parameters[5].Value = model.ddsj; parameters[6].Value = model.lksj; parameters[7].Value = model.Expr1; parameters[8].Value = model.fjrb; parameters[9].Value = model.fjbh; parameters[10].Value = model.lzfs; parameters[11].Value = model.sjfjjg; parameters[12].Value = model.xsy; parameters[13].Value = model.main_sec; parameters[14].Value = model.ddbh; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Hotel_app.Model.VIEW_tt_krlb GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 yydh,qymc,lsbh,krxm,krly,ddsj,lksj,Expr1,fjrb,fjbh,lzfs,sjfjjg,xsy,main_sec,ddbh from VIEW_tt_krlb "); strSql.Append(" where "); SqlParameter[] parameters = { }; Hotel_app.Model.VIEW_tt_krlb model = new Hotel_app.Model.VIEW_tt_krlb(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { 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]["lsbh"] != null && ds.Tables[0].Rows[0]["lsbh"].ToString() != "") { model.lsbh = ds.Tables[0].Rows[0]["lsbh"].ToString(); } if (ds.Tables[0].Rows[0]["krxm"] != null && ds.Tables[0].Rows[0]["krxm"].ToString() != "") { model.krxm = ds.Tables[0].Rows[0]["krxm"].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]["ddsj"] != null && ds.Tables[0].Rows[0]["ddsj"].ToString() != "") { model.ddsj = DateTime.Parse(ds.Tables[0].Rows[0]["ddsj"].ToString()); } if (ds.Tables[0].Rows[0]["lksj"] != null && ds.Tables[0].Rows[0]["lksj"].ToString() != "") { model.lksj = DateTime.Parse(ds.Tables[0].Rows[0]["lksj"].ToString()); } if (ds.Tables[0].Rows[0]["Expr1"] != null && ds.Tables[0].Rows[0]["Expr1"].ToString() != "") { model.Expr1 = ds.Tables[0].Rows[0]["Expr1"].ToString(); } if (ds.Tables[0].Rows[0]["fjrb"] != null && ds.Tables[0].Rows[0]["fjrb"].ToString() != "") { model.fjrb = ds.Tables[0].Rows[0]["fjrb"].ToString(); } if (ds.Tables[0].Rows[0]["fjbh"] != null && ds.Tables[0].Rows[0]["fjbh"].ToString() != "") { model.fjbh = ds.Tables[0].Rows[0]["fjbh"].ToString(); } if (ds.Tables[0].Rows[0]["lzfs"] != null && ds.Tables[0].Rows[0]["lzfs"].ToString() != "") { model.lzfs = decimal.Parse(ds.Tables[0].Rows[0]["lzfs"].ToString()); } if (ds.Tables[0].Rows[0]["sjfjjg"] != null && ds.Tables[0].Rows[0]["sjfjjg"].ToString() != "") { model.sjfjjg = decimal.Parse(ds.Tables[0].Rows[0]["sjfjjg"].ToString()); } if (ds.Tables[0].Rows[0]["xsy"] != null && ds.Tables[0].Rows[0]["xsy"].ToString() != "") { model.xsy = ds.Tables[0].Rows[0]["xsy"].ToString(); } if (ds.Tables[0].Rows[0]["main_sec"] != null && ds.Tables[0].Rows[0]["main_sec"].ToString() != "") { model.main_sec = ds.Tables[0].Rows[0]["main_sec"].ToString(); } if (ds.Tables[0].Rows[0]["ddbh"] != null && ds.Tables[0].Rows[0]["ddbh"].ToString() != "") { model.ddbh = ds.Tables[0].Rows[0]["ddbh"].ToString(); } return(model); } else { return(null); } }