/// <summary> /// 增加一条数据 /// </summary> public bool Add(BranchVsSiteModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into CORE.dbo.BranchVsSite ("); strSql.Append("BranchId,SiteId,VsOrder"); strSql.Append(") values ("); strSql.Append("@BranchId,@SiteId,@VsOrder"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@BranchId", SqlDbType.VarChar, 50), new SqlParameter("@SiteId", SqlDbType.Decimal, 9), new SqlParameter("@VsOrder", SqlDbType.Int, 4) }; parameters[0].Value = model.BranchId; parameters[1].Value = model.SiteId; parameters[2].Value = model.VsOrder; bool result = false; try { helper.ExecSqlReInt(strSql.ToString(), parameters); result = true; } catch (Exception ex) { this.helper.Close(); throw ex; } finally { } return(result); }
/// <summary> /// 得到一个对象实体 /// </summary> public BranchVsSiteModel GetModel(string BranchId, decimal SiteId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select BranchId, SiteId, VsOrder "); strSql.Append(" from CORE.dbo.BranchVsSite "); strSql.Append(" where BranchId=@BranchId and SiteId=@SiteId "); SqlParameter[] parameters = { new SqlParameter("@BranchId", SqlDbType.VarChar, 50), new SqlParameter("@SiteId", SqlDbType.Decimal, 9) }; parameters[0].Value = BranchId; parameters[1].Value = SiteId; BranchVsSiteModel model = new BranchVsSiteModel(); DataSet ds = helper.ExecSqlReDs(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { model.BranchId = ds.Tables[0].Rows[0]["BranchId"].ToString(); if (ds.Tables[0].Rows[0]["SiteId"].ToString() != "") { model.SiteId = decimal.Parse(ds.Tables[0].Rows[0]["SiteId"].ToString()); } if (ds.Tables[0].Rows[0]["VsOrder"].ToString() != "") { model.VsOrder = int.Parse(ds.Tables[0].Rows[0]["VsOrder"].ToString()); } return(model); } else { return(model); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BranchVsSiteModel model) { bool reValue = true; int reCount = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("update CORE.dbo.BranchVsSite set "); strSql.Append(" BranchId = @BranchId , "); strSql.Append(" SiteId = @SiteId , "); strSql.Append(" VsOrder = @VsOrder "); strSql.Append(" where BranchId=@BranchId and SiteId=@SiteId "); SqlParameter[] parameters = { new SqlParameter("@BranchId", SqlDbType.VarChar, 50), new SqlParameter("@SiteId", SqlDbType.Decimal, 9), new SqlParameter("@VsOrder", SqlDbType.Int, 4) }; parameters[0].Value = model.BranchId; parameters[1].Value = model.SiteId; parameters[2].Value = model.VsOrder; try {//异常处理 reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters); } catch (Exception ex) { this.helper.Close(); throw ex; } if (reCount <= 0) { reValue = false; } return(reValue); }