612 lines
18 KiB
C++
612 lines
18 KiB
C++
// DLG_Corp_Transfer.cpp: 实现文件
|
||
//
|
||
|
||
#include "stdafx.h"
|
||
#include "SmsManager.h"
|
||
#include "afxdialogex.h"
|
||
#include "DLG_Corp_Transfer.h"
|
||
#include "MainFrm.h"
|
||
|
||
// DLG_Corp_Transfer 对话框
|
||
|
||
IMPLEMENT_DYNAMIC(DLG_Corp_Transfer, CDialogEx)
|
||
|
||
DLG_Corp_Transfer::DLG_Corp_Transfer(CWnd* pParent /*=nullptr*/)
|
||
: CDialogEx(IDD_CORP_TRANSFER, pParent)
|
||
, m_strBZ(_T(""))
|
||
, m_strSCorpID(_T(""))
|
||
, m_strSCorpID2(_T(""))
|
||
, m_strSCorpName2(_T(""))
|
||
, m_strSKHType2(_T(""))
|
||
, m_strSPriceOne2(_T(""))
|
||
, m_strSProduct2(_T(""))
|
||
, m_strSQuantity(_T(""))
|
||
, m_strSQuantity2(_T(""))
|
||
, m_strSYWY2(_T(""))
|
||
, m_strTCorpID(_T(""))
|
||
, m_strTCorpID2(_T(""))
|
||
, m_strTCorpName2(_T(""))
|
||
, m_strTKHType2(_T(""))
|
||
, m_strTPriceOne2(_T(""))
|
||
, m_strTProduct2(_T(""))
|
||
, m_strTQuantity(_T(""))
|
||
, m_strTQuantity2(_T(""))
|
||
, m_strTYWY2(_T(""))
|
||
{
|
||
m_pMainFrame = NULL;
|
||
m_pSCorpData = new ANS_Corp_Assist_GetCorpData;
|
||
m_pSAgentData = new ANS_Corp_Assist_GetCorpData;
|
||
m_pTCorpData = new ANS_Corp_Assist_GetCorpData;
|
||
m_pTAgentData = new ANS_Corp_Assist_GetCorpData;
|
||
m_pSData = NULL;
|
||
m_pTData = NULL;
|
||
|
||
m_lItem = 0;
|
||
m_lDefaultCorpID = 0; //默认企业ID
|
||
m_lDefaultKHType = 0; //默认客户类型
|
||
m_lDefaultSProduct = 0; //转出产品类型
|
||
m_lDefaultTProduct = 0; //转入产品类型
|
||
}
|
||
|
||
DLG_Corp_Transfer::~DLG_Corp_Transfer()
|
||
{
|
||
CloseData();
|
||
}
|
||
|
||
void DLG_Corp_Transfer::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CDialogEx::DoDataExchange(pDX);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_BZ, m_strBZ);
|
||
DDV_MaxChars(pDX, m_strBZ, 150);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_S_CORPID, m_strSCorpID);
|
||
DDV_MaxChars(pDX, m_strSCorpID, 6);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_S_CORPID2, m_strSCorpID2);
|
||
DDV_MaxChars(pDX, m_strSCorpID2, 6);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_S_CORPNAME2, m_strSCorpName2);
|
||
DDX_Control(pDX, IDC_CORP_TRANSFER_S_KHTYPE, m_L_SKHType);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_S_KHTYPE2, m_strSKHType2);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_S_PRICEONE2, m_strSPriceOne2);
|
||
DDX_Control(pDX, IDC_CORP_TRANSFER_S_PRODUCT, m_L_SProduct);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_S_PRODUCT2, m_strSProduct2);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_S_QUANTITY, m_strSQuantity);
|
||
DDV_MaxChars(pDX, m_strSQuantity, 8);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_S_QUANTITY2, m_strSQuantity2);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_S_YWY2, m_strSYWY2);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_T_CORPID, m_strTCorpID);
|
||
DDV_MaxChars(pDX, m_strTCorpID, 6);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_T_CORPID2, m_strTCorpID2);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_T_CORPNAME2, m_strTCorpName2);
|
||
DDX_Control(pDX, IDC_CORP_TRANSFER_T_KHTYPE, m_L_TKHType);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_T_KHTYPE2, m_strTKHType2);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_T_PRICEONE2, m_strTPriceOne2);
|
||
DDX_Control(pDX, IDC_CORP_TRANSFER_T_PRODUCT, m_L_TProduct);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_T_PRODUCT2, m_strTProduct2);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_T_QUANTITY, m_strTQuantity);
|
||
DDV_MaxChars(pDX, m_strTQuantity, 8);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_T_QUANTITY2, m_strTQuantity2);
|
||
DDX_Text(pDX, IDC_CORP_TRANSFER_T_YWY2, m_strTYWY2);
|
||
DDX_Control(pDX, IDC_CORP_TRANSFER_S_CORPID, m_E_SCorpID);
|
||
DDX_Control(pDX, IDC_CORP_TRANSFER_T_CORPID, m_E_TCorpID);
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(DLG_Corp_Transfer, CDialogEx)
|
||
ON_BN_CLICKED(IDOK, &DLG_Corp_Transfer::OnBnClickedOk)
|
||
ON_EN_CHANGE(IDC_CORP_TRANSFER_S_CORPID, &DLG_Corp_Transfer::OnChangeCorpTransferSCorpid)
|
||
ON_EN_CHANGE(IDC_CORP_TRANSFER_T_CORPID, &DLG_Corp_Transfer::OnChangeCorpTransferTCorpid)
|
||
ON_CBN_SELCHANGE(IDC_CORP_TRANSFER_S_KHTYPE, &DLG_Corp_Transfer::OnSelchangeCorpTransferSKhtype)
|
||
ON_CBN_SELCHANGE(IDC_CORP_TRANSFER_S_PRODUCT, &DLG_Corp_Transfer::OnSelchangeCorpTransferSProduct)
|
||
ON_CBN_SELCHANGE(IDC_CORP_TRANSFER_T_KHTYPE, &DLG_Corp_Transfer::OnSelchangeCorpTransferTKhtype)
|
||
ON_CBN_SELCHANGE(IDC_CORP_TRANSFER_T_PRODUCT, &DLG_Corp_Transfer::OnSelchangeCorpTransferTProduct)
|
||
ON_EN_CHANGE(IDC_CORP_TRANSFER_S_QUANTITY, &DLG_Corp_Transfer::OnChangeCorpTransferSQuantity)
|
||
END_MESSAGE_MAP()
|
||
|
||
|
||
// DLG_Corp_Transfer 消息处理程序
|
||
|
||
|
||
void DLG_Corp_Transfer::OnBnClickedOk()
|
||
{
|
||
|
||
if (m_pSData==NULL || m_pTData ==NULL || !ReCalculation(0))
|
||
{
|
||
MessageBox(_T("转移数量无法计算,请检查录入数据!"), _T("警告"), MB_ICONWARNING);
|
||
return;
|
||
}
|
||
|
||
long lTransferQuantity = _ttol(m_strSQuantity2);
|
||
if (lTransferQuantity <= 0)
|
||
{
|
||
MessageBox(_T("转移数量不能为0,请检查录入数据!"), _T("警告"), MB_ICONWARNING);
|
||
GetDlgItem(IDC_CORP_TRANSFER_S_QUANTITY)->SetFocus();
|
||
return;
|
||
}
|
||
if (m_strSYWY2 != m_strTYWY2)
|
||
{
|
||
MessageBox(_T("两家企业的客户经理不相同,不允许互转!"), _T("警告"), MB_ICONWARNING);
|
||
return;
|
||
}
|
||
if (m_L_SProduct.GetCurSel() == m_L_TProduct.GetCurSel() && m_strSPriceOne2 != m_strTPriceOne2)
|
||
{
|
||
if ( MessageBox(_T("两家企业的单价不相同,互转后短信量会有差异,请确认!"), _T("爱情头发"), MB_ICONWARNING|MB_YESNO|MB_DEFBUTTON2) != IDYES )
|
||
return;
|
||
}
|
||
|
||
long lUsed = m_pSData->lSMSUsed;
|
||
if (m_L_SProduct.GetCurSel()==1)
|
||
lUsed = m_pSData->lMmsUsed;
|
||
if (lTransferQuantity > lUsed)
|
||
{
|
||
MessageBox(_T("转移数量比余额大,请检查录入数据!"), _T("警告"), MB_ICONWARNING);
|
||
GetDlgItem(IDC_CORP_TRANSFER_S_QUANTITY)->SetFocus();
|
||
return;
|
||
}
|
||
if (m_strSCorpID2 == m_strTCorpID2 &&
|
||
m_L_SKHType.GetItemData(m_L_SKHType.GetCurSel()) == m_L_TKHType.GetItemData(m_L_TKHType.GetCurSel()) &&
|
||
m_L_SProduct.GetCurSel() == m_L_TProduct.GetCurSel())
|
||
{
|
||
MessageBox(_T("相同企业ID,同一类型产品不能互转短/彩信量!"), _T("警告"), MB_ICONWARNING);
|
||
//GetDlgItem(IDC_CORP_TRANSFER_S_QUANTITY)->SetFocus();
|
||
return;
|
||
}
|
||
if (m_strBZ.GetLength() < 4)
|
||
{
|
||
MessageBox(_T("互转短信,请录入原因!"), _T("警告"), MB_ICONWARNING);
|
||
GetDlgItem(IDC_CORP_TRANSFER_BZ)->SetFocus();
|
||
return;
|
||
}
|
||
|
||
|
||
REQ_Corp_Assist_Transfer* pTransfer = new REQ_Corp_Assist_Transfer;
|
||
memset(pTransfer, 0, sizeof(REQ_Corp_Assist_Transfer));
|
||
pTransfer->lItem = m_lItem;
|
||
pTransfer->lSCorpID = _ttol(m_strSCorpID2);
|
||
pTransfer->lSKHType = m_L_SKHType.GetItemData(m_L_SKHType.GetCurSel());
|
||
pTransfer->lSProduct = m_L_SProduct.GetCurSel();
|
||
pTransfer->lSQuantity = _ttol(m_strSQuantity);
|
||
|
||
pTransfer->lTCorpID = _ttol(m_strTCorpID2);
|
||
pTransfer->lTKHType = m_L_TKHType.GetItemData(m_L_TKHType.GetCurSel());
|
||
pTransfer->lTProduct = m_L_TProduct.GetCurSel();
|
||
pTransfer->lTQuantity = _ttol(m_strTQuantity2);
|
||
|
||
//生成备注信息
|
||
CString str;
|
||
str.Format(_T("互转:%s%d -> %s%d %s:%d -> %s:%d \r\n%s"),
|
||
pTransfer->lSKHType == 1 ? _T("A-") : _T(""), pTransfer->lSCorpID,
|
||
pTransfer->lTKHType == 1 ? _T("A-") : _T(""), pTransfer->lTCorpID,
|
||
pTransfer->lSProduct == 0 ? _T("短信易") : _T("彩信易"), pTransfer->lSQuantity,
|
||
pTransfer->lTProduct == 0 ? _T("短信易") : _T("彩信易"), pTransfer->lTQuantity,
|
||
m_strBZ);
|
||
_tcscpy(pTransfer->szBZ, str);
|
||
|
||
|
||
GetLocalTime(&pTransfer->tLocalTime);
|
||
|
||
m_pMainFrame->SendFrame(SMSFUNC_CORP_ASSIST_TRANSFER, (BYTE*)pTransfer, sizeof(REQ_Corp_Assist_Transfer)); //取联系人信息
|
||
|
||
|
||
CDialogEx::OnOK();
|
||
}
|
||
|
||
|
||
BOOL DLG_Corp_Transfer::OnInitDialog()
|
||
{
|
||
CDialogEx::OnInitDialog();
|
||
|
||
// TODO: 在此添加额外的初始化
|
||
m_L_SProduct.SetCurSel(m_lDefaultSProduct);
|
||
m_L_TProduct.SetCurSel(m_lDefaultTProduct);
|
||
|
||
if (m_lDefaultCorpID > 0)
|
||
{
|
||
m_strSCorpID.Format(_T("%d"),m_lDefaultCorpID);
|
||
if (m_lDefaultSProduct != m_lDefaultTProduct) //短彩互转
|
||
{
|
||
m_strTCorpID = m_strSCorpID; //同一个ID
|
||
}
|
||
UpdateData(false);
|
||
QueryCorpDetail(0);
|
||
QueryCorpDetail(1);
|
||
GetDlgItem(IDC_CORP_TRANSFER_S_QUANTITY)->SetFocus();
|
||
}
|
||
|
||
return TRUE; // return TRUE unless you set the focus to a control
|
||
// 异常: OCX 属性页应返回 FALSE
|
||
}
|
||
|
||
|
||
BOOL DLG_Corp_Transfer::PreTranslateMessage(MSG* pMsg)
|
||
{
|
||
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == 13 ) //按了回车键
|
||
{
|
||
if (pMsg->hwnd == m_E_SCorpID ) //查询源企业ID
|
||
{
|
||
QueryCorpDetail(0); //查询转出企业信息
|
||
return true;
|
||
}
|
||
if (pMsg->hwnd == m_E_TCorpID) //查询目标企业ID
|
||
{
|
||
QueryCorpDetail(1); //查询转入企业信息
|
||
return true;
|
||
}
|
||
}
|
||
|
||
return CDialogEx::PreTranslateMessage(pMsg);
|
||
}
|
||
|
||
|
||
int DLG_Corp_Transfer::QueryCorpDetail(long lQueryType)
|
||
{
|
||
UpdateData(true);
|
||
|
||
CString strCorpID;
|
||
if (lQueryType == 0)
|
||
strCorpID = m_strSCorpID; //查询转出企业ID
|
||
else
|
||
strCorpID = m_strTCorpID; //查询转入企业ID
|
||
|
||
//发出新查询,将旧数据清零
|
||
if (lQueryType == 0)
|
||
{
|
||
m_strSCorpID2 = _T("");
|
||
m_strSKHType2 = _T("");
|
||
m_strSYWY2 = _T("");
|
||
m_strSCorpName2 = _T("");
|
||
m_strSProduct2 = _T("");
|
||
m_strSPriceOne2 = _T("");
|
||
m_strSQuantity2 = _T("");
|
||
|
||
m_strTQuantity = _T("");
|
||
m_strTQuantity2 = _T("");
|
||
}
|
||
if (lQueryType == 1)
|
||
{
|
||
m_strTCorpID2 = _T("");
|
||
m_strTKHType2 = _T("");
|
||
m_strTYWY2 = _T("");
|
||
m_strTCorpName2 = _T("");
|
||
m_strTProduct2 = _T("");
|
||
m_strTPriceOne2 = _T("");
|
||
m_strTQuantity = _T("");
|
||
m_strTQuantity2 = _T("");
|
||
}
|
||
|
||
UpdateData(false);
|
||
|
||
if (strCorpID.GetLength() != 6) //企业ID为6位,不满6位的不处理
|
||
return -1;
|
||
|
||
|
||
REQ_Corp_Assist_GetCorp* pGetCorp = new REQ_Corp_Assist_GetCorp;
|
||
memset(pGetCorp, 0, sizeof(REQ_Corp_Assist_GetCorp));
|
||
pGetCorp->lItem = 0;
|
||
pGetCorp->lCorpID = _ttol(strCorpID);
|
||
pGetCorp->lGetType = 0; //0-取所有,1-终端,2-代理商
|
||
pGetCorp->lGetTarget = lQueryType; //查询目的
|
||
pGetCorp->lOnlyZYKH = 1; //仅查询自有客户,转移短信不允许转移到代理商客户下面
|
||
GetLocalTime(&pGetCorp->tLocalTime);
|
||
|
||
m_pMainFrame->SendFrame(SMSFUNC_CORP_ASSIST_GETCORP, (BYTE*)pGetCorp, sizeof(REQ_Corp_Assist_GetCorp)); //取联系人信息
|
||
|
||
|
||
|
||
return 0;
|
||
}
|
||
|
||
|
||
void DLG_Corp_Transfer::OnChangeCorpTransferSCorpid()
|
||
{
|
||
QueryCorpDetail(0); //查询转出企业信息
|
||
}
|
||
|
||
|
||
void DLG_Corp_Transfer::OnChangeCorpTransferTCorpid()
|
||
{
|
||
QueryCorpDetail(1); //查询转入企业信息
|
||
}
|
||
|
||
void DLG_Corp_Transfer::SetParam(CMainFrame* pFrame, long lItem,long lCorpID, long lKHType, long lSProduct, long lTProduct)
|
||
{
|
||
m_pMainFrame = pFrame;
|
||
|
||
m_lItem = lItem;
|
||
m_lDefaultCorpID = lCorpID; //默认企业ID
|
||
m_lDefaultKHType = lKHType; //默认客户类型,0-终端客户,1-代理商
|
||
m_lDefaultSProduct = lSProduct; //默认转出产品类型,0-短信易,1-彩信易
|
||
m_lDefaultTProduct = lTProduct; //默认转入产品类型,0-短信易,1-彩信易
|
||
}
|
||
|
||
|
||
BOOL DLG_Corp_Transfer::ProcessSocket(Socket_Head_Add* pHead, BYTE* pFrame)
|
||
{
|
||
CString str;
|
||
//取企业详细信息
|
||
if (pHead->lFuncType == SMSFUNC_CORP_ASSIST_GETCORP)
|
||
{
|
||
ANS_Corp_Assist_GetCorp* pGet = (ANS_Corp_Assist_GetCorp*)pFrame;
|
||
ANS_Corp_Assist_GetCorpData* pCorpData = (ANS_Corp_Assist_GetCorpData*)(pFrame + sizeof(ANS_Corp_Assist_GetCorp));
|
||
ANS_Corp_Assist_GetCorpData* pAgentData = (ANS_Corp_Assist_GetCorpData*)(pFrame + sizeof(ANS_Corp_Assist_GetCorp) + sizeof(ANS_Corp_Assist_GetCorpData) * pGet->lCorpQuantity);
|
||
if (pGet->iErrCode!=0) //权限不足,返回错误
|
||
{
|
||
str.Format(_T("查询企业/代理商失败:%s"), pGet->szErrMsg);
|
||
MessageBox(str, _T("错误"), MB_ICONERROR);
|
||
return true;
|
||
}
|
||
if (pGet->req.lGetTarget == 0)
|
||
{
|
||
m_L_SKHType.ResetContent();
|
||
m_pSCorpData->lCorpID = 0;
|
||
m_pSAgentData->lCorpID = 0;
|
||
int iSel = 0;
|
||
if (pGet->lCorpQuantity > 0 ) //存在企业客户
|
||
{
|
||
int iItem = m_L_SKHType.AddString(_T("终端客户"));
|
||
m_L_SKHType.SetItemData(iItem, 0);
|
||
*m_pSCorpData = *pCorpData;
|
||
if (m_lDefaultKHType == 0) //默认终端客户
|
||
iSel = iItem;
|
||
}
|
||
if (pGet->lAgentQuantity > 0) //存在代理商客户
|
||
{
|
||
int iItem = m_L_SKHType.AddString(_T("代理商"));
|
||
m_L_SKHType.SetItemData(iItem,1);
|
||
*m_pSAgentData = *pAgentData;
|
||
if (m_lDefaultKHType == 1) //默认代理商客户
|
||
iSel = iItem;
|
||
}
|
||
m_L_SKHType.SetCurSel(iSel);
|
||
if (m_L_SKHType.GetCount() > 1)
|
||
m_L_SKHType.EnableWindow(true);
|
||
else
|
||
m_L_SKHType.EnableWindow(false);
|
||
}
|
||
if (pGet->req.lGetTarget == 1)
|
||
{
|
||
m_L_TKHType.ResetContent();
|
||
m_pTCorpData->lCorpID = 0;
|
||
m_pTAgentData->lCorpID = 0;
|
||
int iSel = 0;
|
||
if (pGet->lCorpQuantity > 0) //存在企业客户
|
||
{
|
||
int iItem = m_L_TKHType.AddString(_T("终端客户"));
|
||
m_L_TKHType.SetItemData(iItem, 0);
|
||
*m_pTCorpData = *pCorpData;
|
||
if (m_lDefaultKHType == 0) //默认终端客户
|
||
iSel = iItem;
|
||
}
|
||
if (pGet->lAgentQuantity > 0) //存在代理商客户
|
||
{
|
||
int iItem = m_L_TKHType.AddString(_T("代理商"));
|
||
m_L_TKHType.SetItemData(iItem, 1);
|
||
*m_pTAgentData = *pAgentData;
|
||
if (m_lDefaultKHType == 1) //默认代理商客户
|
||
iSel = iItem;
|
||
}
|
||
m_L_TKHType.SetCurSel(iSel);
|
||
if (m_L_TKHType.GetCount() > 1)
|
||
m_L_TKHType.EnableWindow(true);
|
||
else
|
||
m_L_TKHType.EnableWindow(false);
|
||
}
|
||
ReShowCorpDetail(pGet->req.lGetTarget);
|
||
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
void DLG_Corp_Transfer::CloseData()
|
||
{
|
||
if (m_pSCorpData)
|
||
{
|
||
delete m_pSCorpData;
|
||
m_pSCorpData = NULL;
|
||
}
|
||
|
||
if (m_pSAgentData)
|
||
{
|
||
delete m_pSAgentData;
|
||
m_pSAgentData = NULL;
|
||
}
|
||
|
||
if (m_pTCorpData)
|
||
{
|
||
delete m_pTCorpData;
|
||
m_pTCorpData = NULL;
|
||
}
|
||
if (m_pTAgentData)
|
||
{
|
||
delete m_pTAgentData;
|
||
m_pTAgentData = NULL;
|
||
}
|
||
}
|
||
|
||
|
||
void DLG_Corp_Transfer::OnSelchangeCorpTransferSKhtype()
|
||
{
|
||
ReShowCorpDetail(0);
|
||
}
|
||
|
||
|
||
void DLG_Corp_Transfer::OnSelchangeCorpTransferSProduct()
|
||
{
|
||
ReShowCorpDetail(0);
|
||
}
|
||
|
||
|
||
void DLG_Corp_Transfer::OnSelchangeCorpTransferTKhtype()
|
||
{
|
||
ReShowCorpDetail(1);
|
||
}
|
||
|
||
|
||
void DLG_Corp_Transfer::OnSelchangeCorpTransferTProduct()
|
||
{
|
||
ReShowCorpDetail(1);
|
||
}
|
||
|
||
void DLG_Corp_Transfer::ReShowCorpDetail(long lType)
|
||
{
|
||
UpdateData(true);
|
||
|
||
if (lType == 0) //转出
|
||
{
|
||
int iSKHType = -1;
|
||
int iItem = m_L_SKHType.GetCurSel();
|
||
if (iItem >= 0)
|
||
iSKHType = m_L_SKHType.GetItemData(iItem);
|
||
|
||
ANS_Corp_Assist_GetCorpData* pData = m_pSCorpData;
|
||
if (iSKHType == 1)
|
||
pData = m_pSAgentData;
|
||
if (iSKHType == -1 || pData->lCorpID<=0 ) //没客户类型,说明没查询到客户,清空所有源客户资料
|
||
{
|
||
m_strSCorpID2 = _T("");
|
||
m_strSKHType2 = _T("");
|
||
m_strSYWY2 = _T("");
|
||
m_strSCorpName2 = _T("");
|
||
m_strSProduct2 = _T("");
|
||
m_strSPriceOne2 = _T("");
|
||
m_strSQuantity2 = _T("");
|
||
|
||
m_strTQuantity2 = _T(""); //因为没有转出客户,转入短信量也置为0
|
||
|
||
UpdateData(false);
|
||
return;
|
||
}
|
||
|
||
//显示新的数据
|
||
m_strSCorpID2.Format(_T("%d"), pData->lCorpID);
|
||
m_strSKHType2 = pData->lUserType == 0 ? _T("终端客户") : _T("代理商");
|
||
m_strSYWY2 = pData->szYWYName;
|
||
m_strSCorpName2 = pData->szCorpName;
|
||
m_strSProduct2 = m_L_SProduct.GetCurSel() == 0 ? _T("短信易") : _T("彩信易");
|
||
m_strSPriceOne2.Format(_T("%.4f"), m_L_SProduct.GetCurSel() == 0 ? pData->fPriceOne : pData->fMmsPriceOne);
|
||
|
||
//m_strSQuantity2 = _T(""); //转出短信量需要重新计算
|
||
|
||
UpdateData(false);
|
||
ReCalculation(0); //重新计算短信量
|
||
return;
|
||
}
|
||
if (lType == 1) //转入
|
||
{
|
||
int iTKHType = -1;
|
||
int iItem = m_L_TKHType.GetCurSel();
|
||
if (iItem >= 0)
|
||
iTKHType = m_L_TKHType.GetItemData(iItem);
|
||
|
||
ANS_Corp_Assist_GetCorpData* pData = m_pTCorpData;
|
||
if (iTKHType == 1)
|
||
pData = m_pTAgentData;
|
||
if (iTKHType == -1 || pData->lCorpID <= 0) //没客户类型,说明没查询到客户,清空所有源客户资料
|
||
{
|
||
m_strTCorpID2 = _T("");
|
||
m_strTKHType2 = _T("");
|
||
m_strTYWY2 = _T("");
|
||
m_strTCorpName2 = _T("");
|
||
m_strTProduct2 = _T("");
|
||
m_strTPriceOne2 = _T("");
|
||
m_strTQuantity2 = _T("");
|
||
|
||
//m_strTQuantity2 = _T(""); //因为没有转出客户,转入短信量也置为0
|
||
|
||
UpdateData(false);
|
||
return;
|
||
}
|
||
|
||
//显示新的数据
|
||
m_strTCorpID2.Format(_T("%d"), pData->lCorpID);
|
||
m_strTKHType2 = pData->lUserType == 0 ? _T("终端客户") : _T("代理商");
|
||
m_strTYWY2 = pData->szYWYName;
|
||
m_strTCorpName2 = pData->szCorpName;
|
||
m_strTProduct2 = m_L_TProduct.GetCurSel() == 0 ? _T("短信易") : _T("彩信易");;
|
||
m_strTPriceOne2.Format(_T("%.4f"), m_L_TProduct.GetCurSel() == 0 ? pData->fPriceOne : pData->fMmsPriceOne);
|
||
|
||
//m_strTQuantity2 = _T(""); //转出短信量需要重新计算
|
||
|
||
UpdateData(false);
|
||
ReCalculation(1); //重新计算短信量
|
||
return;
|
||
}
|
||
|
||
return;
|
||
|
||
|
||
}
|
||
|
||
BOOL DLG_Corp_Transfer::ReCalculation(long lType)
|
||
{
|
||
UpdateData(true);
|
||
m_strTQuantity = _T(""); //默认置数据为空
|
||
m_strTQuantity2 = _T("");
|
||
m_strSQuantity2 = _T("");
|
||
UpdateData(false);
|
||
|
||
if (m_strSCorpID2.GetLength() != 6 || m_strTCorpID2.GetLength() != 6)
|
||
return false;
|
||
long lSKHType = m_L_SKHType.GetItemData(m_L_SKHType.GetCurSel());
|
||
long lTKHType = m_L_TKHType.GetItemData(m_L_TKHType.GetCurSel());
|
||
|
||
long lSProduct = m_L_SProduct.GetCurSel();
|
||
long lTProduct = m_L_TProduct.GetCurSel();;
|
||
|
||
m_pSData = NULL;
|
||
m_pTData = NULL;
|
||
|
||
//根据客户类型取客户数据
|
||
if (lSKHType == 0) //终端客户
|
||
m_pSData = m_pSCorpData;
|
||
else
|
||
m_pSData = m_pSAgentData;
|
||
if (lTKHType == 0) //终端客户
|
||
m_pTData = m_pTCorpData;
|
||
else
|
||
m_pTData = m_pTAgentData;
|
||
|
||
if (m_pSData == NULL || m_pTData == NULL) //没取取数据
|
||
return false;
|
||
if (m_pSData->lCorpID < 100000 || m_pTData->lCorpID < 100000) //数据为空
|
||
return false;
|
||
|
||
double fSPriceOne = 0.0f;
|
||
double fTPriceOne = 0.0f;
|
||
|
||
if (lSProduct == 0)//短信易
|
||
fSPriceOne = m_pSData->fPriceOne;
|
||
else
|
||
fSPriceOne = m_pSData->fMmsPriceOne;
|
||
if (lTProduct == 0)//短信易
|
||
fTPriceOne = m_pTData->fPriceOne;
|
||
else
|
||
fTPriceOne = m_pTData->fMmsPriceOne;
|
||
|
||
if (fSPriceOne < 0.02f || fSPriceOne > 1.0f || //单价有误
|
||
fTPriceOne < 0.02f || fTPriceOne > 1.0f)
|
||
return false;
|
||
|
||
|
||
|
||
long lSQuantity = _ttol(m_strSQuantity);
|
||
if (lSQuantity <= 0)
|
||
return false;
|
||
|
||
m_strSQuantity2.Format(_T("%d"), lSQuantity);
|
||
long lTQuantity = int(((double)lSQuantity * fSPriceOne / fTPriceOne)+0.5f);
|
||
|
||
|
||
m_strTQuantity2.Format(_T("%d"), lTQuantity);
|
||
m_strTQuantity = m_strTQuantity2;
|
||
|
||
UpdateData(false);
|
||
|
||
return true;
|
||
}
|
||
|
||
void DLG_Corp_Transfer::OnChangeCorpTransferSQuantity()
|
||
{
|
||
ReCalculation(0); //重新计算短信量
|
||
}
|