📄 dlginlibrary.cpp
字号:
// DlgInlibrary.cpp : implementation file
//
#include "stdafx.h"
#include "Manage_WH.h"
#include "DlgInlibrary.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgInlibrary dialog
CDlgInlibrary::CDlgInlibrary(CWnd* pParent /*=NULL*/)
: CDialog(CDlgInlibrary::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgInlibrary)
m_num = 0;
m_date = 0;
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDI_MYICON);
}
void CDlgInlibrary::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgInlibrary)
DDX_Control(pDX, IDC_NUM, m_EdtNum);
DDX_Text(pDX, IDC_NUM, m_num);
DDV_MinMaxInt(pDX, m_num, 1, 9999);
DDX_DateTimeCtrl(pDX, IDC_DATE, m_date);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgInlibrary, CDialog)
//{{AFX_MSG_MAP(CDlgInlibrary)
ON_BN_CLICKED(IDC_INLIBRARY, OnInlibrary)
ON_CBN_SELCHANGE(IDC_GOODS, OnSelchangeGoods)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgInlibrary message handlers
BOOL CDlgInlibrary::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message==WM_KEYDOWN && (pMsg->wParam==13 || pMsg->wParam==27))
return TRUE;
return CDialog::PreTranslateMessage(pMsg);
}
BOOL CDlgInlibrary::OnInitDialog()
{
CDialog::OnInitDialog();
SetIcon(m_hIcon,TRUE);
CTime tm(CTime::GetCurrentTime());
m_date = tm;
UpdateData(FALSE);
gFillComboBox(static_cast<CComboBox *>(GetDlgItem(IDC_GOODS)),"T_Products" ,"F_Name");
gFillComboBox(static_cast<CComboBox *>(GetDlgItem(IDC_PRIORITY)),"T_Task_Level","F_Name");
static_cast<CEdit *>(GetDlgItem(IDC_ORDER))->SetWindowText(GetOrderFormNum());
return TRUE;
}
CString CDlgInlibrary::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 = 2",adCmdText);
rs.GetCollect("F_Index",szVal);
rs.GetCollect("F_Year",sYear);
rs.Close();
cn.Close();
sNum = "RK"+sYear+"-"+szVal+"";
}
else
{
AfxMessageBox("数据库连接失败!");
sNum = "";
}
return sNum;
}
void CDlgInlibrary::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=2",adCmdText);
cn.Close();
}
void CDlgInlibrary::OnSelchangeGoods()
{
static_cast<CEdit *>(GetDlgItem(IDC_NUM))->SetFocus();
}
void CDlgInlibrary::OnInlibrary()
{
UpdateData(TRUE);
CString sGoodsName,sFormNum,sGoodsCount,sPriority,sWarning;
static_cast<CComboBox *>(GetDlgItem(IDC_GOODS))->GetWindowText(sGoodsName);
static_cast<CComboBox *>(GetDlgItem(IDC_PRIORITY))->GetWindowText(sPriority);
static_cast<CEdit *>(GetDlgItem(IDC_ORDER))->GetWindowText(sFormNum);
m_EdtNum.GetWindowText(sGoodsCount);
if (sGoodsName.IsEmpty()) sWarning = "入库商品类型不能为空,请选择!";
else if (sPriority.IsEmpty()) sWarning = "任务优先级别不能为空,请选择!";
else if (sGoodsCount.IsEmpty() || sGoodsCount.Mid(0,1) == "0") sWarning = "入库商品数量不正确,请重新输入!";
if (!sWarning.IsEmpty())
{
MessageBox(sWarning,"系统提示",MB_ICONSTOP|MB_OK);
return;
}
if (MessageBox("请确认是否执行入库操作?","系统提示",MB_ICONINFORMATION|MB_YESNO) == IDNO)
return;
CString sSQL,sTime,sDate,sSupplier;
sTime = GetDate(2);
sDate.Format("%.4d-%.2d-%.2d",m_date.GetYear(),m_date.GetMonth(),m_date.GetDay());
int iGoodsKind = gfGetGoodsKind(sGoodsName);
int iManageIndex = gfGetTaskIndex();
int iPriority = gfGetTaskPriority(sPriority);
int iGoodsCount = atoi(sGoodsCount);
CAdoConnection cn;
CAdoRecordSet rs;
cn.OpenUDLFile(gstrConSQLSer);
rs.SetAdoConnection(&cn);
rs.Open("select * from T_Products where F_Name='"+sGoodsName+"'",adCmdText);
rs.GetCollect("F_Supplier",sSupplier);
rs.Close();
sSQL.Format("INSERT INTO T_Manager_Task(F_ManagerIndex,F_OrderIndex,F_TaskKind,F_TaskLevel,F_TaskState,F_GoodsKind,F_SortCount,F_CustomerName,F_DeliverDate,F_SendTime)VALUES(%d,'%s',1,%d,0,%d,%d,'%s','%s','%s')",iManageIndex,sFormNum,iPriority,iGoodsKind,iGoodsCount,m_supplier,sDate,sTime);
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',2,'%s',%d,'%s','%s','%s')",sFormNum,sGoodsName,iGoodsCount,sSupplier,sTime,sDate);
cn.Execute(sSQL,adCmdText);
cn.Close();
AddLog("执行入库操作。入库单编号:"+sFormNum+";商品名称:"+sGoodsName+";入库数量:"+sGoodsCount+";");
MessageBox("数据添加成功!","系统提示",MB_ICONINFORMATION|MB_OK);
SetOrderFormNum();
static_cast<CEdit *>(GetDlgItem(IDC_ORDER))->SetWindowText(GetOrderFormNum());
static_cast<CComboBox *>(GetDlgItem(IDC_GOODS))->SetCurSel(-1);
static_cast<CEdit *>(GetDlgItem(IDC_NUM))->SetWindowText("0");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -