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.
 
 
 
 
 

168 lines
4.7 KiB

using Entity.Sugar;
using Entity.ViewModels;
using SqlSugar;
using SqlSugar.Base;
using System;
using System.Collections.Generic;
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();
RegionMaintain_QryService region_qry = new RegionMaintain_QryService();
CountryMaintain_QryService country_qry = new CountryMaintain_QryService();
CityMaintain_QryService city_qry = new CityMaintain_QryService();
var RegionMap = region_qry.FindAllByIDsAsDictionary(sLanguageID, "");
var CountryMap = country_qry.FindAllByIDsAsDictionary(sLanguageID, "", "");
var CityMap = city_qry.FindAllByIDsAsDictionary(sLanguageID, "", "", "");
foreach (var Company in rsCompanyList) {
if (!string.IsNullOrEmpty(Company.RegionID))
{
if (RegionMap.ContainsKey(Company.RegionID))
{
var Region = RegionMap[Company.RegionID];
Company.Region.RegionID = Region.RegionID;
Company.Region.RegionName = Region.RegionName;
}
}
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;
}
}
if (!string.IsNullOrEmpty(Company.CityID))
{
if (CityMap.ContainsKey(Company.CityID))
{
var City = CityMap[Company.CityID];
Company.City.CityID = City.CityID;
Company.City.CityName = City.CityName;
}
}
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查詢)
}
}