📄 dlgoutlibwhole.cpp
字号:
// DlgOutlibWhole.cpp : implementation file
//
#include "stdafx.h"
#include "Manage_WH.h"
#include "DlgOutlibWhole.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgOutlibWhole dialog
CDlgOutlibWhole::CDlgOutlibWhole(CWnd* pParent /*=NULL*/)
: CDialog(CDlgOutlibWhole::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgOutlibWhole)
m_date = 0;
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDI_MYICON);
}
void CDlgOutlibWhole::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgOutlibWhole)
DDX_Control(pDX, IDC_LIST, m_list);
DDX_DateTimeCtrl(pDX, IDC_DATE, m_date);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgOutlibWhole, CDialog)
//{{AFX_MSG_MAP(CDlgOutlibWhole)
ON_BN_CLICKED(IDC_QUERY, OnQuery)
ON_LBN_SELCHANGE(IDC_LIST, OnSelchangeList)
ON_BN_CLICKED(IDC_OUT, OnOut)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgOutlibWhole message handlers
BOOL CDlgOutlibWhole::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message==WM_KEYDOWN && (pMsg->wParam==13 || pMsg->wParam==27))
return TRUE;
return CDialog::PreTranslateMessage(pMsg);
}
BOOL CDlgOutlibWhole::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon,TRUE);
gFillComboBox(static_cast<CComboBox *>(GetDlgItem(IDC_CUSTOMER)),"T_Customers","F_CompanyName");
gFillComboBox(static_cast<CComboBox *>(GetDlgItem(IDC_PRIORITY)),"T_Task_Level","F_Name");
CTime tm(CTime::GetCurrentTime());
m_date = tm;
UpdateData(FALSE);
static_cast<CEdit *>(GetDlgItem(IDC_ORDER))->SetWindowText(this->GetOrderFormNum());
return TRUE;
}
void CDlgOutlibWhole::OnQuery()
{
CString sIndex;
CAdoConnection cn;
CAdoRecordSet rs;
cn.OpenUDLFile(gstrConSQLSer);
rs.SetAdoConnection(&cn);
rs.Open("select * from T_Goods_Site_Manage where F_SiteState=1 and F_GoodsKind!=100 and F_GoodsKind!=101 and F_GoodsKind!=102 and F_GoodsKind!=103",adCmdText);
m_list.ResetContent();
while (!rs.IsEOF())
{
rs.GetCollect("F_SiteIndex",sIndex);
m_list.AddString(sIndex);
rs.MoveNext();
}
rs.Close();
cn.Close();
}
void CDlgOutlibWhole::OnSelchangeList()
{
if (m_list.GetCurSel() >= 0)
{
CString sIndex,sGoodsName,sGoodsCount;
int iGoodsKind(0),iGoodsCount(0);
m_list.GetText(m_list.GetCurSel(),sIndex);
static_cast<CEdit *>(GetDlgItem(IDC_INDEX))->SetWindowText(sIndex);
static_cast<CEdit *>(GetDlgItem(IDC_STATUS))->SetWindowText("有货");
CAdoConnection cn;
CAdoRecordSet rs;
cn.OpenUDLFile(gstrConSQLSer);
rs.SetAdoConnection(&cn);
rs.Open("select * from T_Goods_Site_Manage where F_SiteIndex = '"+sIndex+"'",adCmdText);
rs.GetCollect("F_GoodsKind",iGoodsKind);
rs.GetCollect("F_GoodsCount",iGoodsCount);
rs.Close();
cn.Close();
sGoodsCount.Format("%d",iGoodsCount);
static_cast<CEdit *>(GetDlgItem(IDC_COUNT))->SetWindowText(sGoodsCount);
sGoodsName = ::gfGetGoodsName(iGoodsKind);
/* if (iGoodsKind == 100) sGoodsName = "杂色商品";
else if (iGoodsKind == 101) sGoodsName = "空箱子";
else if (iGoodsKind == 102) sGoodsName = "单空托盘";
else if (iGoodsKind == 103) sGoodsName = "托盘垛";
else
{
sGoodsName = ::gfGetGoodsName(iGoodsKind);
}*/
static_cast<CEdit *>(GetDlgItem(IDC_GOODS))->SetWindowText(sGoodsName);
static_cast<CButton *>(GetDlgItem(IDC_OUT))->EnableWindow(true);
}
}
void CDlgOutlibWhole::OnOut()
{
UpdateData(TRUE);
CString sIndex,sGoodsName,sGoodsCount,sFormNum,sPriority,sCustomer,sDate,sWarning;
static_cast<CEdit *>(GetDlgItem(IDC_ORDER))->GetWindowText(sFormNum);
static_cast<CEdit *>(GetDlgItem(IDC_INDEX))->GetWindowText(sIndex);
static_cast<CEdit *>(GetDlgItem(IDC_GOODS))->GetWindowText(sGoodsName);
static_cast<CEdit *>(GetDlgItem(IDC_COUNT))->GetWindowText(sGoodsCount);
static_cast<CComboBox *>(GetDlgItem(IDC_PRIORITY))->GetWindowText(sPriority);
static_cast<CComboBox *>(GetDlgItem(IDC_CUSTOMER))->GetWindowText(sCustomer);
if (sPriority.IsEmpty()) sWarning = "任务优先级别不能为空,请选择!";
else if (sCustomer.IsEmpty()) sWarning = "客户名称不能为空,请选择!";
if (!sWarning.IsEmpty())
{
MessageBox(sWarning,"系统提示",MB_ICONSTOP|MB_OK);
return;
}
if (MessageBox("是否对货位["+sIndex+"]执行出库操作?","系统提示",MB_ICONINFORMATION|MB_YESNO) == IDNO)
return;
int iTaskIndex = gfGetTaskIndex();
int iGoodsKind = gfGetGoodsKind(sGoodsName);
int iGoodsCount= atoi(sGoodsCount);
int iPriority = gfGetTaskPriority(sPriority);
CString sSQL,sDateTime,sOrderForm;
sDateTime = GetDate(2);
sDate.Format("%.4d-%.2d-%.2d",m_date.GetYear(),m_date.GetMonth(),m_date.GetDay());
sOrderForm = GetOrderFormNum();
CAdoConnection cn;
cn.OpenUDLFile(gstrConSQLSer);
sSQL.Format("INSERT INTO T_Manager_Task(F_ManagerIndex,F_OrderIndex,F_StartPoint,F_TaskKind,F_TaskLevel,F_TaskState,\
F_GoodsKind,F_FinishCount,F_SortCount,F_CustomerName,F_DeliverDate,F_SendTime)VALUES(%d,'%s','%s',%d,%d,%d,\
%d,%d,%d,'%s','%s','%s')",iTaskIndex,sOrderForm,sIndex,2,iPriority,0,iGoodsKind,iGoodsCount,iGoodsCount,sCustomer,sDate,sDateTime);
cn.Execute(sSQL,adCmdText);
sSQL.Format("INSERT INTO T_Order_History(F_OrderIndex,F_Kind,F_GoodsName,F_Count,F_CompanyName,F_SendTime,F_DeliverDate)\
VALUES('%s',%d,'%s',%d,'%s','%s','%s')",sOrderForm,3,sGoodsName,iGoodsCount,sCustomer,sDateTime,sDate);
cn.Execute(sSQL,adCmdText);
cn.Execute("UPDATE T_Goods_Site_Manage SET F_SiteState = 2 WHERE F_SiteIndex = '"+sIndex+"'",adCmdText);
cn.Close();
SetOrderFormNum();
MessageBox("任务下达成功!","系统提示",MB_ICONINFORMATION|MB_OK);
AddLog("对货位["+sIndex+"]执行出库任务。");
CTime tm(CTime::GetCurrentTime());
m_date = tm;
UpdateData(FALSE);
static_cast<CButton *>(GetDlgItem(IDC_OUT))->EnableWindow(false);
static_cast<CEdit *>(GetDlgItem(IDC_ORDER))->SetWindowText(GetOrderFormNum());
static_cast<CEdit *>(GetDlgItem(IDC_INDEX))->SetWindowText("");
static_cast<CEdit *>(GetDlgItem(IDC_STATUS))->SetWindowText("");
static_cast<CEdit *>(GetDlgItem(IDC_GOODS))->SetWindowText("");
static_cast<CEdit *>(GetDlgItem(IDC_COUNT))->SetWindowText("");
static_cast<CComboBox *>(GetDlgItem(IDC_CUSTOMER))->SetCurSel(-1);
OnQuery();
}
CString CDlgOutlibWhole::GetOrderFormNum()
{
CString sNum,szVal,sYear;
CAdoConnection cn;
if (cn.OpenUDLFile(gstrConSQLSer))
{
CAdoRecordSet rs;
rs.SetAdoConnection(&cn);
rs.Open("select * from T_Order_Form_Index where F_Type = 1",adCmdText);
rs.GetCollect("F_Index",szVal);
rs.GetCollect("F_Year",sYear);
rs.Close();
cn.Close();
sNum = "DH"+sYear+"-"+szVal+"";
}
else
{
AfxMessageBox("数据库连接失败!");
sNum = "";
}
return sNum;
}
void CDlgOutlibWhole::SetOrderFormNum()
{
CString sNum,sOrder;
static_cast<CEdit *>(GetDlgItem(IDC_ORDER))->GetWindowText(sNum);
sOrder.Format("%.5d",atoi(sNum.Mid(sNum.Find('-',0)+1)) + 1);
CAdoConnection cn;
cn.OpenUDLFile(gstrConSQLSer);
cn.Execute("UPDATE T_Order_Form_Index SET F_Index='"+sOrder+"' WHERE F_Type=1",adCmdText);
cn.Close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -