You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
172 lines
4.6 KiB
172 lines
4.6 KiB
using Entity.Sugar;
|
|
using Entity.ViewModels;
|
|
using SqlSugar;
|
|
using SqlSugar.Base;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace EasyBL.WEBAPP.SYS
|
|
{
|
|
public class CompanyMaintain_QryService : ServiceBase
|
|
{
|
|
|
|
#region 公司資訊管理(List 公司資訊列表)
|
|
|
|
/// <summary>
|
|
/// 公司資訊管理(List 公司資訊列表)
|
|
/// </summary>
|
|
/// <param name="i_crm"></param>
|
|
/// <returns></returns>
|
|
public List<View_CRM_Company> QueryCompanyList(string sAccount, string sLanguageID)
|
|
{
|
|
|
|
List<View_CRM_Company> rsResultList = new List<View_CRM_Company>();
|
|
|
|
string sMsg = null;
|
|
var db = SugarBase.GetIntance();
|
|
|
|
try
|
|
{
|
|
do
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(sLanguageID)) {
|
|
sLanguageID = WebAppGlobalConstWord.DEFAULT_LANGUAGE;
|
|
}
|
|
|
|
var rsCompanyList = db.Queryable<SETB_CRM_Company>()
|
|
.Where(t1 => t1.Account == sAccount)
|
|
.Select(t1 => new View_CRM_Company {
|
|
|
|
CompanyID = SqlFunc.GetSelfAndAutoFill(t1.CompanyID)
|
|
|
|
})
|
|
.ToList();
|
|
|
|
CountryMaintain_QryService country_qry = new CountryMaintain_QryService();
|
|
|
|
var CountryMap = country_qry.FindAllByIDsAsDictionary(sLanguageID, "", "");
|
|
|
|
foreach (var Company in rsCompanyList) {
|
|
|
|
if (!string.IsNullOrEmpty(Company.CountryID))
|
|
{
|
|
|
|
if (CountryMap.ContainsKey(Company.CountryID))
|
|
{
|
|
var Country = CountryMap[Company.CountryID];
|
|
Company.Country.CountryID = Country.CountryID;
|
|
Company.Country.CountryName = Country.CountryName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rsResultList.Add(Company);
|
|
}
|
|
|
|
} while (false);
|
|
|
|
return rsResultList;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
}
|
|
finally
|
|
{
|
|
|
|
}
|
|
|
|
return rsResultList;
|
|
|
|
}
|
|
|
|
#endregion 公司資訊管理(List 公司資訊列表)
|
|
|
|
#region 公司資訊管理(SETB_CRM_Company 以ID查詢)
|
|
|
|
/// <summary>
|
|
/// 公司資訊管理(SETB_CRM_Company 以ID查詢)
|
|
/// </summary>
|
|
/// <param name="i_crm"></param>
|
|
/// <returns></returns>
|
|
public SETB_CRM_Company FindByIDs(string sCompanyID)
|
|
{
|
|
|
|
SETB_CRM_Company rsCompany = null;
|
|
|
|
string sMsg = null;
|
|
var db = SugarBase.GetIntance();
|
|
|
|
try
|
|
{
|
|
do
|
|
{
|
|
|
|
rsCompany = db.Queryable<SETB_CRM_Company>()
|
|
.Where(t1 => t1.CompanyID == sCompanyID)
|
|
.Single();
|
|
|
|
} while (false);
|
|
|
|
return rsCompany;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
}
|
|
finally
|
|
{
|
|
|
|
}
|
|
|
|
return rsCompany;
|
|
|
|
}
|
|
|
|
#endregion 公司資訊管理(SETB_CRM_Company 以ID查詢)
|
|
|
|
public Dictionary<string, SETB_CRM_Company> FindAllByIDsAsDictionary(string sAccount, string sCompanyID) {
|
|
|
|
string sMsg = null;
|
|
var db = SugarBase.GetIntance();
|
|
|
|
Dictionary<string, SETB_CRM_Company> saCompanyDic = new Dictionary<string, SETB_CRM_Company>();
|
|
|
|
try
|
|
{
|
|
do
|
|
{
|
|
|
|
var saCompanyList = db.Queryable<SETB_CRM_Company>()
|
|
.WhereIF(!string.IsNullOrEmpty(sAccount), t1 => t1.Account == sAccount)
|
|
.WhereIF(!string.IsNullOrEmpty(sCompanyID), t1 => t1.CompanyID == sCompanyID)
|
|
.ToList();
|
|
|
|
foreach (var Company in saCompanyList)
|
|
{
|
|
saCompanyDic[Company.CompanyID] = Company;
|
|
}
|
|
|
|
return saCompanyDic;
|
|
|
|
} while (false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
|
|
}
|
|
|
|
return saCompanyDic;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|