| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- 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<Branch>
- {
- 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<Branch>(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<Branch> Select(int pageIndex, int pageSize)
- //{
- // return null;
- //}
- public IEnumerable<Branch> FindAll()
- {
- const string sql = "select * from branch order by position";
- using (IDbConnection connection = GetDbConnection())
- {
- return connection.Query<Branch>(sql);
- }
- }
- public IEnumerable<Branch> 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<Branch>(sql);
- }
- }
- public IEnumerable<Branch> 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<Branch>(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<Branch>(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<Branch>(sql);
- // }
- //}
- }
- }
- }
|