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.
210 lines
5.5 KiB
210 lines
5.5 KiB
using EasyBL.WebApi.Message;
|
|
using EasyBL.WEBAPP.SYS;
|
|
using Entity.Sugar;
|
|
using SqlSugar.Base;
|
|
using System;
|
|
|
|
namespace EasyBL.WEBAPP.WSM
|
|
{
|
|
public class ContactMaintain_UpdService : ServiceBase
|
|
{
|
|
|
|
#region 聯繫方式維護(儲存)
|
|
|
|
/// <summary>
|
|
/// 聯繫方式維護(儲存)
|
|
/// </summary>
|
|
/// <param SETB_CRM_Contact="Contact"></param>
|
|
/// <returns></returns>
|
|
///
|
|
public ResponseMessage SaveContact(SETB_CRM_Contact Contact)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
|
|
try
|
|
{
|
|
do
|
|
{
|
|
|
|
ContactMaintain_QryService cm_qry = new ContactMaintain_QryService();
|
|
|
|
if (cm_qry.FindByIDs(Contact.ContactID, Contact.Account) != null)
|
|
{
|
|
|
|
// update
|
|
rm = Update(Contact);
|
|
}
|
|
else
|
|
{
|
|
|
|
// insert
|
|
rm = Insert(Contact);
|
|
}
|
|
|
|
|
|
} while (false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
}
|
|
finally
|
|
{
|
|
if (null != sMsg)
|
|
{
|
|
rm = new ErrorResponseMessage(sMsg, null);
|
|
}
|
|
}
|
|
return rm;
|
|
}
|
|
|
|
#endregion 聯繫方式維護(儲存)
|
|
|
|
#region 聯繫方式維護(新增)
|
|
|
|
/// <summary>
|
|
/// 聯繫方式維護(新增)
|
|
/// </summary>
|
|
/// <param SETB_CRM_Contact="Contact"></param>
|
|
/// <returns></returns>
|
|
/// Origtek framwork API
|
|
public ResponseMessage Insert(SETB_CRM_Contact Contact)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
|
|
try
|
|
{
|
|
rm = SugarBase.ExecTran(db =>
|
|
{
|
|
do
|
|
{
|
|
|
|
var sContactID = Guid.NewGuid().ToString();
|
|
|
|
Contact.ContactID = sContactID;
|
|
|
|
var iRel = db.Insertable(Contact).ExecuteCommand();
|
|
|
|
rm = new SuccessResponseMessage(null, null);
|
|
rm.DATA.Add(BLWording.REL, iRel);
|
|
|
|
} while (false);
|
|
|
|
return rm;
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
|
|
System.Diagnostics.Debug.WriteLine("sMsg" + ": " + sMsg);
|
|
|
|
}
|
|
finally
|
|
{
|
|
if (null != sMsg)
|
|
{
|
|
rm = new ErrorResponseMessage(sMsg, null);
|
|
}
|
|
}
|
|
return rm;
|
|
}
|
|
|
|
#endregion 聯繫方式維護(新增)
|
|
|
|
#region 聯繫方式維護(修改)
|
|
|
|
/// <summary>
|
|
/// 聯繫方式維護(修改)
|
|
/// </summary>
|
|
/// <param SETB_CRM_Contact="Contact"></param>
|
|
/// <returns></returns>
|
|
/// Origtek framwork API
|
|
public ResponseMessage Update(SETB_CRM_Contact Contact)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
try
|
|
{
|
|
rm = SugarBase.ExecTran(db =>
|
|
{
|
|
do
|
|
{
|
|
|
|
var iRel = db.Updateable(Contact).ExecuteCommand();
|
|
|
|
rm = new SuccessResponseMessage(null, null);
|
|
rm.DATA.Add(BLWording.REL, iRel);
|
|
} while (false);
|
|
|
|
return rm;
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
}
|
|
finally
|
|
{
|
|
if (null != sMsg)
|
|
{
|
|
rm = new ErrorResponseMessage(sMsg, null);
|
|
}
|
|
}
|
|
return rm;
|
|
}
|
|
|
|
#endregion 聯繫方式維護(修改)
|
|
|
|
#region 聯繫方式維護(刪除)
|
|
|
|
/// <summary>
|
|
/// 聯繫方式維護(刪除)
|
|
/// </summary>
|
|
/// <param SETB_CRM_Contact="Contact"></param>
|
|
/// <returns></returns>
|
|
/// Origtek framwork API
|
|
public ResponseMessage Delete(SETB_CRM_Contact Contact)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
try
|
|
{
|
|
rm = SugarBase.ExecTran(db =>
|
|
{
|
|
do
|
|
{
|
|
|
|
ContactMaintain_QryService fm_qry = new ContactMaintain_QryService();
|
|
var rsResult = fm_qry.FindByIDs(Contact.ContactID, Contact.Account);
|
|
|
|
var iRel = db.Deleteable<SETB_CRM_Contact>(rsResult).ExecuteCommand();
|
|
|
|
rm = new SuccessResponseMessage(null, null);
|
|
rm.DATA.Add(BLWording.REL, iRel);
|
|
} while (false);
|
|
|
|
return rm;
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
sMsg = Util.GetLastExceptionMsg(ex);
|
|
}
|
|
finally
|
|
{
|
|
if (null != sMsg)
|
|
{
|
|
rm = new ErrorResponseMessage(sMsg, null);
|
|
}
|
|
}
|
|
return rm;
|
|
}
|
|
|
|
#endregion 聯繫方式維護(刪除)
|
|
|
|
|
|
}
|
|
}
|