/// <summary> /// 得到一个对象实体 /// </summary> public LPWeb.Model.BranchManagers GetModel(int BranchId, int BranchMgrId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 BranchId,BranchMgrId from BranchManagers "); strSql.Append(" where BranchId=@BranchId and BranchMgrId=@BranchMgrId "); SqlParameter[] parameters = { new SqlParameter("@BranchId", SqlDbType.Int, 4), new SqlParameter("@BranchMgrId", SqlDbType.Int, 4) }; parameters[0].Value = BranchId; parameters[1].Value = BranchMgrId; LPWeb.Model.BranchManagers model = new LPWeb.Model.BranchManagers(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["BranchId"].ToString() != "") { model.BranchId = int.Parse(ds.Tables[0].Rows[0]["BranchId"].ToString()); } if (ds.Tables[0].Rows[0]["BranchMgrId"].ToString() != "") { model.BranchMgrId = int.Parse(ds.Tables[0].Rows[0]["BranchMgrId"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(LPWeb.Model.BranchManagers model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update BranchManagers set "); strSql.Append("BranchId=@BranchId,"); strSql.Append("BranchMgrId=@BranchMgrId"); strSql.Append(" where BranchId=@BranchId and BranchMgrId=@BranchMgrId "); SqlParameter[] parameters = { new SqlParameter("@BranchId", SqlDbType.Int, 4), new SqlParameter("@BranchMgrId", SqlDbType.Int, 4) }; parameters[0].Value = model.BranchId; parameters[1].Value = model.BranchMgrId; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(LPWeb.Model.BranchManagers model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into BranchManagers("); strSql.Append("BranchId,BranchMgrId)"); strSql.Append(" values ("); strSql.Append("@BranchId,@BranchMgrId)"); SqlParameter[] parameters = { new SqlParameter("@BranchId", SqlDbType.Int, 4), new SqlParameter("@BranchMgrId", SqlDbType.Int, 4) }; parameters[0].Value = model.BranchId; parameters[1].Value = model.BranchMgrId; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }