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.3 KiB
210 lines
5.3 KiB
using EasyBL.WebApi.Message;
|
|
using EasyBL.WEBAPP.SYS;
|
|
using Entity.Sugar;
|
|
using SqlSugar.Base;
|
|
using System;
|
|
|
|
namespace EasyBL.WEBAPP.WSM
|
|
{
|
|
public class CompanyMaintain_UpdService : ServiceBase
|
|
{
|
|
|
|
#region 公司資訊維護(儲存)
|
|
|
|
/// <summary>
|
|
/// 公司資訊維護(儲存)
|
|
/// </summary>
|
|
/// <param></param>
|
|
/// <returns></returns>
|
|
///
|
|
public ResponseMessage SaveCompany(SETB_CRM_Company Company)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
|
|
try
|
|
{
|
|
do
|
|
{
|
|
|
|
CompanyMaintain_QryService cm_qry = new CompanyMaintain_QryService();
|
|
|
|
if (cm_qry.FindByIDs(Company.CompanyID) != null)
|
|
{
|
|
|
|
// update
|
|
rm = Update(Company);
|
|
}
|
|
else
|
|
{
|
|
|
|
// insert
|
|
rm = Insert(Company);
|
|
}
|
|
|
|
|
|
} 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></param>
|
|
/// <returns></returns>
|
|
/// Origtek framwork API
|
|
public ResponseMessage Insert(SETB_CRM_Company Company)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
|
|
try
|
|
{
|
|
rm = SugarBase.ExecTran(db =>
|
|
{
|
|
do
|
|
{
|
|
|
|
var sCompanyID = Guid.NewGuid().ToString();
|
|
|
|
Company.CompanyID = sCompanyID;
|
|
|
|
var iRel = db.Insertable(Company).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></param>
|
|
/// <returns></returns>
|
|
///
|
|
public ResponseMessage Update(SETB_CRM_Company Company)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
try
|
|
{
|
|
rm = SugarBase.ExecTran(db =>
|
|
{
|
|
do
|
|
{
|
|
|
|
var iRel = db.Updateable(Company).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></param>
|
|
/// <returns></returns>
|
|
/// Origtek framwork API
|
|
public ResponseMessage Delete(SETB_CRM_Company Company)
|
|
{
|
|
ResponseMessage rm = null;
|
|
string sMsg = null;
|
|
try
|
|
{
|
|
rm = SugarBase.ExecTran(db =>
|
|
{
|
|
do
|
|
{
|
|
|
|
CompanyMaintain_QryService cm_qry = new CompanyMaintain_QryService();
|
|
var rsResult = cm_qry.FindByIDs(Company.CompanyID);
|
|
|
|
var iRel = db.Deleteable(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 公司資訊維護(刪除)
|
|
|
|
|
|
}
|
|
}
|