| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- 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>
- {
- private static BranchProvider instance;
- public BranchProvider() : base("gov")
- {
- }
- public static BranchProvider Instance
- {
- get
- {
- CreateInstance(ref instance);
- return instance;
- }
- }
- 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);
- // }
- //}
- }
- }
- }
|