using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using Winsoft.GOV.Framework.Model; using Dapper; namespace Winsoft.GOV.Framework.Provider { public class BranchProvider : BaseProvider { public BranchProvider(County county) : base(county) { } public Branch Find(string guid) { const string sql = "select * from branch where guid=@guid"; using (IDbConnection connection = GetDbConnection()) { return connection.QueryFirstOrDefault(sql, new { guid = guid}); } } public void Insert(Branch b) { const string sql = "insert branch(guid, shortname, position) values(@guid, @shortname, @position);"; using (IDbConnection connection = GetDbConnection()) { connection.Execute(sql, b); } } //public PagedResult Select(int pageIndex, int pageSize) //{ // return null; //} public IEnumerable FindAll() { const string sql = "select * from branch order by position"; using (IDbConnection connection = GetDbConnection()) { return connection.Query(sql); } } public IEnumerable FindOnceRunBranch() { const string sql = "select ouguid as guid, ql_dep as ShortName from oncerunpowermatters group by ouguid, ql_dep order by ouguid"; using (IDbConnection connection = GetDbConnection()) { return connection.Query(sql); } } public IEnumerable FindByApplyType(int type) { string sql = "(select QL_DEP as ShortName, OUGUID as guid from powermattertype where ApplyCode = @applyCode group by OUGUID, QL_DEP order by ouguid)"; using (IDbConnection connection = GetDbConnection()) { return connection.Query(sql, new { applyCode = type }); } //if (type > -1 && type < ApplyType.Names.Length) //{ // string sql = "(select QL_DEP as ShortName, OUGUID as guid from powermattertype where ApplyCode = @applyCode group by OUGUID, QL_DEP)"; // using (IDbConnection connection = GetDbConnection()) // { // return connection.Query(sql, new { applyCode = type }); // } //} //else //{ // string sql = "select QL_DEP as ShortName, OUGUID as guid from oncerunpowermatters where ql_inner_code not in (select ql_inner_code from PowerMatterType) group by OUGUID, ql_dep"; // using (IDbConnection connection = GetDbConnection()) // { // return connection.Query(sql); // } //} } } }