Janie 2 years ago
parent
commit
a76ae556e3
  1. 120
      EuroTran/EasyBL.WEBAPP/ShowEasy/ONSiteMaintain_UpdService.cs

120
EuroTran/EasyBL.WEBAPP/ShowEasy/ONSiteMaintain_UpdService.cs

@ -1054,34 +1054,28 @@ namespace EasyBL.WEBAPP.ShowEasy
}
// UpdMinPrice(i_crm.ORIGID, oEntity.ServiceID, oEntity.LangID);
int? MinPrice = int.MaxValue;
var saONSiteBaseInfo = db.Queryable<SETB_PDT_ONSiteItem>().Where(x => x.OrgID == i_crm.ORIGID && x.ServiceID == oEntity.ServiceID && x.LangID == oEntity.LangID).Select(x => x.Guid).ToList();
if (saONSiteBaseInfo.Count > 0)
{
var ServiceCostRulesPrice = db.Queryable<SETB_PDT_ServiceCostRules>().Where(x => saONSiteBaseInfo.Contains(x.QSID)).Min(x => x.Price);
if (ServiceCostRulesPrice < MinPrice)
var ServiceCostRulesPrice = db.Queryable<SETB_PDT_ServiceCostRules>().Where(x => saONSiteBaseInfo.Contains(x.QSID)).Min(x => x.Price * SqlFunc.IIF(x.PricingMode == "N", 1, SqlFunc.ToDouble(x.Weight_Min)));
if (ServiceCostRulesPrice != null)
{
if (Convert.ToInt32(ServiceCostRulesPrice) < MinPrice)
{
MinPrice = ServiceCostRulesPrice;
MinPrice = Convert.ToInt32(ServiceCostRulesPrice);
}
}
var ServiceTruckCostRulesPrice = db.Queryable<SETB_PDT_ServiceTruckCostRules>().Where(x => saONSiteBaseInfo.Contains(x.QSID)).Min(x => x.Price);
if (ServiceTruckCostRulesPrice < MinPrice)
{
MinPrice = ServiceTruckCostRulesPrice;
}
var ONSiteOtherCostRulesPrice = db.Queryable<SETB_PDT_ONSiteOtherCostRules>().Where(x => saONSiteBaseInfo.Contains(x.ONSiteItemID)).Min(x => x.Price);
if (ONSiteOtherCostRulesPrice < MinPrice)
{
MinPrice = ONSiteOtherCostRulesPrice;
}
}
else
{
@ -1124,72 +1118,7 @@ namespace EasyBL.WEBAPP.ShowEasy
#endregion Onsite管理編輯(新增)
/// <summary>
/// 更新最低金額
/// </summary>
/// <param name="i_crm"></param>
/// <returns></returns>
private void UpdMinPrice(string sOrgID,string sServiceID,string sLangID)
{
int? MinPrice = int.MaxValue;
var db = SugarBase.GetIntance();
try
{
var saONSiteBaseInfo = db.Queryable<SETB_PDT_ONSiteItem>().Where(x => x.OrgID == sOrgID && x.ServiceID == sServiceID && x.LangID == sLangID).Select(x => x.Guid).ToList();
if (saONSiteBaseInfo.Count > 0)
{
var ServiceCostRulesPrice = db.Queryable<SETB_PDT_ServiceCostRules>().Where(x => saONSiteBaseInfo.Contains(x.QSID)).Min(x => x.Price);
if (ServiceCostRulesPrice < MinPrice)
{
MinPrice = ServiceCostRulesPrice;
}
var ServiceTruckCostRulesPrice = db.Queryable<SETB_PDT_ServiceTruckCostRules>().Where(x => saONSiteBaseInfo.Contains(x.QSID)).Min(x => x.Price);
if (ServiceTruckCostRulesPrice < MinPrice)
{
MinPrice = ServiceTruckCostRulesPrice;
}
var ONSiteOtherCostRulesPrice = db.Queryable<SETB_PDT_ONSiteOtherCostRules>().Where(x => saONSiteBaseInfo.Contains(x.ONSiteItemID)).Min(x => x.Price);
if (ONSiteOtherCostRulesPrice < MinPrice)
{
MinPrice = ONSiteOtherCostRulesPrice;
}
}
else
{
MinPrice = 0;
}
//更新最低金額
var oONSiteBaseInfo = db.Queryable<SETB_PDT_ONSiteBaseInfo>().Single(x => x.OrgID == sOrgID && x.ServiceID == sServiceID && x.LangID == sLangID);
oONSiteBaseInfo.MinPrice = MinPrice;
var iRel = db.Updateable(oONSiteBaseInfo)
.UpdateColumns(x => new
{
x.MinPrice
}).ExecuteCommand();
}
catch (Exception ex)
{
var sMsg = Util.GetLastExceptionMsg(ex);
}
}
#region Plan(修改)
@ -1379,11 +1308,13 @@ namespace EasyBL.WEBAPP.ShowEasy
var saONSiteBaseInfo = db.Queryable<SETB_PDT_ONSiteItem>().Where(x => x.OrgID == i_crm.ORIGID && x.ServiceID == oEntity.ServiceID && x.LangID == oEntity.LangID).Select(x => x.Guid).ToList();
if (saONSiteBaseInfo.Count > 0)
{
var ServiceCostRulesPrice = db.Queryable<SETB_PDT_ServiceCostRules>().Where(x => saONSiteBaseInfo.Contains(x.QSID)).Min(x => x.Price);
if (ServiceCostRulesPrice < MinPrice)
var ServiceCostRulesPrice = db.Queryable<SETB_PDT_ServiceCostRules>().Where(x => saONSiteBaseInfo.Contains(x.QSID)).Min(x => x.Price * SqlFunc.IIF(x.PricingMode == "N", 1, SqlFunc.ToDouble(x.Weight_Min)));
if (ServiceCostRulesPrice != null)
{
MinPrice = ServiceCostRulesPrice;
if (Convert.ToInt32(ServiceCostRulesPrice) < MinPrice)
{
MinPrice = Convert.ToInt32(ServiceCostRulesPrice);
}
}
var ServiceTruckCostRulesPrice = db.Queryable<SETB_PDT_ServiceTruckCostRules>().Where(x => saONSiteBaseInfo.Contains(x.QSID)).Min(x => x.Price);
@ -1398,10 +1329,6 @@ namespace EasyBL.WEBAPP.ShowEasy
{
MinPrice = ONSiteOtherCostRulesPrice;
}
}
else
{
@ -1780,11 +1707,7 @@ namespace EasyBL.WEBAPP.ShowEasy
var sServiceID = _fetchString(i_crm, @"ServiceID");
var sLangID = _fetchString(i_crm, @"LangID");
var sPlanID = _fetchString(i_crm, @"PlanID");
var iRel = db.Deleteable<SETB_PDT_ONSiteItem>().Where(x => x.Guid == sPlanID && x.ServiceID == sServiceID && x.LangID == sLangID).ExecuteCommand();
var iRel1 = db.Deleteable<SETB_PDT_ServiceCostRules>().Where(x => x.QSID == sPlanID).ExecuteCommand();
iRel1 = db.Deleteable<SETB_PDT_ServiceTruckCostRules>().Where(x => x.QSID == sPlanID).ExecuteCommand();
iRel1 = db.Deleteable<SETB_PDT_ServiceTruckOtherCost>().Where(x => x.QSID == sPlanID).ExecuteCommand();
@ -1795,12 +1718,15 @@ namespace EasyBL.WEBAPP.ShowEasy
int? MinPrice = int.MaxValue;
var saONSiteBaseInfo = db.Queryable<SETB_PDT_ONSiteItem>().Where(x => x.OrgID == i_crm.ORIGID && x.ServiceID == sServiceID && x.LangID == sLangID).Select(x => x.Guid).ToList();
if (saONSiteBaseInfo.Count > 0)
{
var ServiceCostRulesPrice = db.Queryable<SETB_PDT_ServiceCostRules>().Where(x => saONSiteBaseInfo.Contains(x.QSID)).Min(x => x.Price * SqlFunc.IIF(x.PricingMode == "N", 1, SqlFunc.ToDouble(x.Weight_Min)));
if (ServiceCostRulesPrice != null)
{
var ServiceCostRulesPrice = db.Queryable<SETB_PDT_ServiceCostRules>().Where(x => saONSiteBaseInfo.Contains(x.QSID)).Min(x => x.Price);
if (ServiceCostRulesPrice < MinPrice)
if (Convert.ToInt32(ServiceCostRulesPrice) < MinPrice)
{
MinPrice = ServiceCostRulesPrice;
MinPrice = Convert.ToInt32(ServiceCostRulesPrice);
}
}
var ServiceTruckCostRulesPrice = db.Queryable<SETB_PDT_ServiceTruckCostRules>().Where(x => saONSiteBaseInfo.Contains(x.QSID)).Min(x => x.Price);
@ -1815,10 +1741,6 @@ namespace EasyBL.WEBAPP.ShowEasy
{
MinPrice = ONSiteOtherCostRulesPrice;
}
}
else
{
@ -1878,14 +1800,9 @@ namespace EasyBL.WEBAPP.ShowEasy
var sServiceID = _fetchString(i_crm, @"ServiceID");
var iRel = db.Deleteable<SETB_PDT_ONSiteBaseInfo>().Where(x => x.ServiceID == sServiceID).ExecuteCommand();
var iRel1 = db.Deleteable<SETB_PDT_ServiceByPPTime>().Where(x => x.ServiceID == sServiceID).ExecuteCommand();
iRel1 = db.Deleteable<SETB_PDT_ServiceByFQA>().Where(x => x.ServiceID == sServiceID).ExecuteCommand();
iRel1 = db.Deleteable<SETB_PDT_ServiceByOther>().Where(x => x.ServiceID == sServiceID).ExecuteCommand();
iRel1 = db.Deleteable<SETB_PDT_ServiceBySuitPlace>().Where(x => x.ServiceID == sServiceID).ExecuteCommand();
var saONSiteBaseInfo = db.Queryable<SETB_PDT_ONSiteItem>().Where(x => x.ServiceID == sServiceID).Select(x => x.Guid).ToList();
if (saONSiteBaseInfo.Count > 0)
{
@ -1896,7 +1813,6 @@ namespace EasyBL.WEBAPP.ShowEasy
iRel1 = db.Deleteable<SETB_PDT_ServiceTruckOtherCost>().Where(x => x.QSID == ONSiteItemGuid).ExecuteCommand();
iRel1 = db.Deleteable<SETB_PDT_ServiceTruckOtherCost>().Where(x => x.QSID == ONSiteItemGuid).ExecuteCommand();
iRel1 = db.Deleteable<SETB_PDT_ONSiteOtherCostRules>().Where(x => x.ONSiteItemID == ONSiteItemGuid).ExecuteCommand();
}
}
iRel1 = db.Deleteable<SETB_PDT_ONSiteItem>().Where(x => x.ServiceID == sServiceID).ExecuteCommand();

Loading…
Cancel
Save