📄 unloadclass.cpp
字号:
// UnloadClass.cpp : implementation file
//
#include "stdafx.h"
#include "CTSClient.h"
#include "UnloadClass.h"
#include "DisrepairRecord.h"
#include "ModifyContainerNo.h"
#include "UnloadModifySealNo.h"
#include "ApplyCheck.h"
#include "SpillDisrepair.h"
#include "UnloadOperationDetail.h"
#include "UnloadArriveCheckNoQuery.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern SOCKET clientSocket;
extern CString voyageNoQuery;
extern CString workDate;
extern CString workOrders;
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
extern BOOL socketconnect;
/////////////////////////////////////////////////////////////////////////////
extern char recvbuf[10240];
extern char recvbuf2[3072];
extern char rectemp[50];
/////////////////////////////////////////////////////////////////////////////
// UnloadClass dialog
UnloadClass::UnloadClass(CWnd* pParent /*=NULL*/)
: CDialog(UnloadClass::IDD, pParent)
{
//{{AFX_DATA_INIT(UnloadClass)
m_containerNo = _T("");
m_shipName = _T("");
m_unload_voyageNo = _T("");
m_containerSize = _T("");
m_containerStatus = _T("");
m_containerType = _T("");
m_cargoWeight = _T("");
m_deliveryPortNameC = _T("");
m_dischargePortNameC = _T("");
arriveCheckNo = _T("");
tallyListObjId = _T("");
tallyListItemObjectId = _T("");
containerNo = _T("");
sealNo = _T("");
containerSize = _T("");
containerStatus = _T("");
objectId = _T("");
//}}AFX_DATA_INIT
}
void UnloadClass::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(UnloadClass)
DDX_Control(pDX, IDC_LIST1, m_list_unload);
DDX_Text(pDX, IDC_EDIT2, m_containerNo);
DDX_Text(pDX, IDC_SHIPNAME, m_shipName);
DDX_Text(pDX, IDC_VOYAGENO, m_unload_voyageNo);
DDX_Text(pDX, IDC_EDIT12, m_containerSize);
DDX_Text(pDX, IDC_EDIT13, m_containerStatus);
DDX_Text(pDX, IDC_EDIT14, m_containerType);
DDX_Text(pDX, IDC_EDIT15, m_cargoWeight);
DDX_Text(pDX, IDC_EDIT1, m_deliveryPortNameC);
DDX_Text(pDX, IDC_EDIT4, m_dischargePortNameC);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(UnloadClass, CDialog)
//{{AFX_MSG_MAP(UnloadClass)
ON_COMMAND(ID_UNLOAD_LIST, OnUnloadList)
ON_WM_CANCELMODE()
ON_BN_CLICKED(IDC_BUTTON2, OnBtnSearch)
ON_BN_CLICKED(IDC_BUTTON3, OnBtnOperation)
ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
ON_NOTIFY(HDN_BEGINDRAG, IDC_LIST1, OnBegindragList1)
ON_BN_CLICKED(IDC_BUTTON9, OnDisrepairRecord)
ON_BN_CLICKED(IDC_BUTTON6, OnModifyContainerNo)
ON_BN_CLICKED(IDC_BUTTON8, OnSpillDisrepair)
ON_BN_CLICKED(IDC_BUTTON10, OnApplyCheck)
ON_BN_CLICKED(IDC_BUTTON11, OnUnloadArriveCheckNoQuery)
ON_BN_CLICKED(IDC_BUTTON7, OnButton7)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// UnloadClass message handlers
void UnloadClass::OnUnloadList()
{
// TODO: Add your command handler code here
}
const char* UnloadClass::newGUID()
{
static char buf[38] = {0};
GUID guid;
if (S_OK == ::CoCreateGuid(&guid))
{
_snprintf(buf, sizeof(buf)
, "{%08X-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}"
, guid.Data1
, guid.Data2
, guid.Data3
, guid.Data4[0], guid.Data4[1]
, guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5]
, guid.Data4[6], guid.Data4[7]
);
}
return (const char*)buf;
}
void UnloadClass::InitUnloadListCaption()
{
DWORD dwStyle=LVS_EX_HEADERDRAGDROP | LVS_EX_TRACKSELECT|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT|LVS_EDITLABELS;
m_list_unload.SetExtendedStyle(dwStyle);
LV_COLUMN lvc;
lvc.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH |LVCF_FMT;
lvc.fmt=LVCFMT_CENTER;
RECT rect;
m_list_unload.GetWindowRect(&rect);
int wid=rect.right-rect.left;
lvc.iSubItem = 0;
lvc.pszText = _T("目的港");
lvc.cx = 1;
m_list_unload.InsertColumn(0,&lvc);
lvc.iSubItem = 1;
lvc.pszText = _T("主表流水号");
lvc.cx = 1;
m_list_unload.InsertColumn(1,&lvc);
lvc.iSubItem = 2;
lvc.pszText = _T("从表流水号");
lvc.cx = 1;
m_list_unload.InsertColumn(2,&lvc);
lvc.iSubItem = 3;
lvc.pszText = _T("箱号");
lvc.cx = wid;
m_list_unload.InsertColumn(3,&lvc);
lvc.iSubItem = 4;
lvc.pszText = _T("箱体尺寸");
lvc.cx = 1;
m_list_unload.InsertColumn(4,&lvc);
lvc.iSubItem = 5;
lvc.pszText = _T("箱型");
lvc.cx = 1;
m_list_unload.InsertColumn(5,&lvc);
lvc.iSubItem = 6;
lvc.pszText = _T("重量");
lvc.cx = 1;
m_list_unload.InsertColumn(6,&lvc);
lvc.iSubItem = 7;
lvc.pszText = _T("中转港");
lvc.cx = 1;
m_list_unload.InsertColumn(7,&lvc);
lvc.iSubItem = 8;
lvc.pszText = _T("铅封号");
lvc.cx = 1;
m_list_unload.InsertColumn(8,&lvc);
lvc.iSubItem = 9;
lvc.pszText = _T("箱类");
lvc.cx = 1;
m_list_unload.InsertColumn(9,&lvc);
lvc.iSubItem = 10;
lvc.pszText = _T("港口类型");
lvc.cx = 1;
m_list_unload.InsertColumn(10,&lvc);
CImageList img;
img.Create(1,25,ILC_MASK,2,2);
m_list_unload.SetImageList(&img,LVSIL_SMALL);
m_list_unload.SetBkColor(RGB(247,247,255));
m_list_unload.SetTextColor(RGB(0,0,255));
m_list_unload.SetTextBkColor(RGB(247,247,255));
}
BOOL UnloadClass::OnInitDialog()
{
CDialog::OnInitDialog();
InitUnloadListCaption();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void UnloadClass::OnCancelMode()
{
CDialog::OnCancelMode();
// TODO: Add your message handler code here
}
void UnloadClass::OnBtnSearch()
{
/////////////////////////////////////////////////////////////////////////////////////
if (!socketconnect)
{
MessageBox(_T("与服务器连接中断,请检查网络后重新登录该系统!"),_T("出错提示"));
return;
}
/////////////////////////////////////////////////////////////////////////////////////
UpdateData(true);
if (m_shipName == VT_EMPTY){
MessageBox(_T("请先查询船舶!"),_T("出错提示"));
return;
}
if (m_containerNo == VT_EMPTY){
MessageBox(_T("请输入箱号!"),_T("出错提示"));
return;
}
if (m_containerNo.GetLength() < 4){
MessageBox(_T("请输入箱号的后4位!!!"),_T("出错提示"));
m_containerNo = _T("");
UpdateData(false);
return;
}
CString ULUCSSQL = _T("");
//ULUCSSQL = "select b.objectId,b.masterObjId,b.containerNo,c.containerSize+c.containerType,b.containerStatus,b.sealNo from tallylist a ,tallylistitem b,isoCode c where a.objectID = b.masterObjId and c.objectId = b.isoCodeObjId and a.isLoad = '0' and a.arriveCheckNo = '"+arriveCheckNo+"'";
//if (m_containerNo != VT_EMPTY){
// ULUCSSQL = ULUCSSQL + " and b.containerNo like \'" + "%" + m_containerNo + "\'" ;
//}
//ULUCSSQL=" "+ULUCSSQL+'\0';
ULUCSSQL = " select f.portNameC,e.* from (select b.objectId, d.portNameC from tallylistitem b,region d where b.placeOfDeliveryObjId = d.objectId) f,(select b.objectId,b.masterObjId,b.containerNo,c.containerSize,b.containerStatus,b.cargoWeight,d.portNameC,b.sealNo,c.containerType,a.deliveryOrdischarge from tallylist a ,tallylistitem b,isoCode c,region d where a.objectID = b.masterObjId and c.objectId = b.isoCodeObjId and (b.portOfDischargeObjId = d.objectId ) and a.isLoad = '0' and a.objectId = '"+objectId+"' and b.containerNo like \'" + "%" + m_containerNo + "\' ) e where e.objectId = f.objectId ";
ULUCSSQL=" "+ULUCSSQL+'\0';
int iSize = 0;
char* pszMultiByte;
iSize = WideCharToMultiByte(CP_ACP, 0, ULUCSSQL, -1, NULL, 0, NULL, NULL);
pszMultiByte = (char*)malloc((iSize+1)*sizeof(char));
WideCharToMultiByte(CP_ACP, 0, ULUCSSQL, -1, pszMultiByte, iSize, NULL, NULL);
*pszMultiByte=3;
pszMultiByte++;
*pszMultiByte=iSize/256;
pszMultiByte++;
*pszMultiByte=iSize%256;
pszMultiByte=pszMultiByte-2;
int i = 0,j = 0;
int retint = 0;
int totalnum = 0;
int itemcount = m_list_unload.GetItemCount();
for (j=0;j<itemcount;j++)
m_list_unload.DeleteItem(itemcount-1-j);
int mint=send(clientSocket,pszMultiByte,iSize,0);
free(pszMultiByte);
delete pszMultiByte;
int temp1 = 0,temp2 = 0,actint = 0;
retint=recv(clientSocket,recvbuf2,sizeof(recvbuf2),0);
if (recvbuf2[0]==8 && retint==1)
{
MessageBox(_T("网络传输出错,请重新点击按钮再试一次!!!"),_T("提示"));
return;
}
if (recvbuf2[0]==27)
{
m_containerNo = _T("");
int itemcount = m_list_unload.GetItemCount();
for (j=0;j<itemcount;j++)
m_list_unload.DeleteItem(itemcount-1-j);
m_containerNo = _T("");
m_deliveryPortNameC= _T("");
m_dischargePortNameC= _T("");
m_containerSize = _T("");
m_containerStatus = _T("");
m_containerType = _T("");
m_cargoWeight = _T("");
UpdateData(false);
MessageBox(_T("数据库中无此记录!"),_T("出错提示"),MB_OK);
return;
}
temp1=recvbuf2[0];
if (temp1<0)
temp1=temp1+256;
temp2=recvbuf2[1];
if (temp2<0)
temp2=temp2+256;
actint=temp1*256+temp2;
totalnum=0;
for (i=0;i<retint;i++)
recvbuf[totalnum+i]=recvbuf2[i];
recvbuf[0]=32;
recvbuf[1]=32;
totalnum+=retint;
while(totalnum!=actint)
{
retint=recv(clientSocket,recvbuf2,sizeof(recvbuf2),0);
for (i=0;i<retint;i++)
recvbuf[totalnum+i]=recvbuf2[i];
totalnum+=retint;
}
CString strtemp = _T("");
int rowcount,colcount;
char* ptch;
j=0;
rowcount=0;
colcount=0;
strtemp = _T("");
m_list_unload.InsertItem(rowcount,(LPCTSTR)strtemp);
for ( i=0;i<totalnum;i++)
{
if (recvbuf[i]!=26 && recvbuf[i]!=27)
{
rectemp[j]=recvbuf[i];
j++;
}
if (recvbuf[i]==26 && j!=0)
{
rectemp[j]='\0';
j=0;
if (colcount==0 && rowcount==0)
ptch=rectemp+2;
else
ptch=rectemp;
strtemp=ptch;
m_list_unload.SetItemText(rowcount,colcount,strtemp);
colcount++;
}
if (recvbuf[i]==27)
{
j=0;
colcount=0;
rowcount++;
if (i!=totalnum-1)
m_list_unload.InsertItem(rowcount,(LPCTSTR)strtemp);
}
}
int nIndex = 0;
m_list_unload.SetItemState(nIndex, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED);
m_deliveryPortNameC=m_list_unload.GetItemText(nIndex,0);
tallyListItemObjectId=m_list_unload.GetItemText(nIndex,1);
tallyListObjId=m_list_unload.GetItemText(nIndex,2);
containerNo=m_list_unload.GetItemText(nIndex,3);
containerSize=m_list_unload.GetItemText(nIndex,4) + m_list_unload.GetItemText(nIndex,9);
m_containerSize=m_list_unload.GetItemText(nIndex,4);
containerStatus=m_list_unload.GetItemText(nIndex,5);
m_containerStatus=m_list_unload.GetItemText(nIndex,5);
m_cargoWeight=m_list_unload.GetItemText(nIndex,6);
m_dischargePortNameC=m_list_unload.GetItemText(nIndex,7);
sealNo=m_list_unload.GetItemText(nIndex,8);
m_containerType=m_list_unload.GetItemText(nIndex,9);
UpdateData(false);
}
void UnloadClass::OnBtnOperation()
{
// TODO: Add your control notification handler code here
UpdateData(true);
/////////////////////////////////////////////////////////////////////////////////////
if (!socketconnect)
{
MessageBox(_T("与服务器连接中断,请检查网络后重新登录该系统!"),_T("出错提示"));
return;
}
/////////////////////////////////////////////////////////////////////////////////////
int sPos=m_list_unload.GetSelectionMark();
if(sPos==-1){
MessageBox(_T("请先选择一条记录!!!"),_T("出错提示"));
}
else{
/////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -