123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- // InputGoods.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "InputGoods.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // InputGoods dialog
- InputGoods::InputGoods(CWnd* pParent /*=NULL*/)
- : CDialog(InputGoods::IDD, pParent)
- {
- //{{AFX_DATA_INIT(InputGoods)
- m_id = _T("");
- m_count = _T("");
- m_clerk = g_user.name;
- m_date = g_date;
- m_remark = _T("");
- //}}AFX_DATA_INIT
- m_mode = 0;
- }
- void InputGoods::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(InputGoods)
- DDX_Control(pDX, IDC_EDITcount, m_editnum);
- DDX_Control(pDX, IDC_COMBOname, m_comboname);
- DDX_Control(pDX, IDC_COMBOtype, m_combotype);
- DDX_Text(pDX, IDC_EDITid, m_id);
- DDX_Text(pDX, IDC_EDITcount, m_count);
- DDX_Text(pDX, IDC_EDITclerk, m_clerk);
- DDX_Text(pDX, IDC_EDITdate, m_date);
- DDX_Text(pDX, IDC_EDITremark, m_remark);
- DDV_MaxChars(pDX, m_remark, 1000);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(InputGoods, CDialog)
- //{{AFX_MSG_MAP(InputGoods)
- ON_CBN_SELCHANGE(IDC_COMBOtype, OnSelchangeCOMBOtype)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // InputGoods message handlers
- BOOL InputGoods::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- CString sql = "select max(id) as cot from storeinfo where [date]='" + g_date + "'";
- if (m_mode)
- sql = "select max(id) as cot from storeinfo2 where [date]='" + g_date + "'";
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- if (g_bSendOK == 0)
- {
- CDialog::OnCancel();
- return false;
- }
- CString date = g_date;
- date.Replace("-", "");
- if (m_mode == 0)
- m_id.Format("%s-(rk)%03d", date, g_ncount + 1);
- else
- {
- m_id.Format("%s-(ck)%03d", date, g_ncount + 1);
- GetDlgItem(IDC_STATIC1)->SetWindowText("出库资料");
- SetWindowText("出库单");
- }
- UpdateData(false);
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 8;
- g_sendhead.code[1] = 2;
- g_sendhead.tabcount = 2;
- CString filter = "hide<>'下架' or hide is null;";
- g_pMainWnd->ProcessChatMessageRequest2(filter);
- if (g_bSendOK == 0)
- {
- CDialog::OnCancel();
- return false;
- }
- DataToArray(&m_List1array, &m_List2array);
- for (int i = 0; i < m_List2array.GetSize(); i++)
- m_combotype.AddString(m_List2array.ElementAt(i).ElementAt(0));
- CenterWindow();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void InputGoods::OnSelchangeCOMBOtype()
- {
- // TODO: Add your control notification handler code here
- int pos = m_combotype.GetCurSel();
- if (pos == -1)return;
- CString str;
- m_combotype.GetLBText(pos, str);
- m_comboname.ResetContent();
- for (int ii = 0; ii < m_List1array.GetSize(); ii++)
- {
- if (m_List1array.ElementAt(ii).ElementAt(4) == str)
- {
- m_comboname.AddString(m_List1array.ElementAt(ii).ElementAt(1));
- }
- }
- }
- void InputGoods::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData();
- CString type, name;
- int pos;
- pos = m_combotype.GetCurSel();
- if (pos != -1)
- m_combotype.GetLBText(pos, type);
- pos = m_comboname.GetCurSel();
- if (pos != -1)
- m_comboname.GetLBText(pos, name);
- m_count.TrimLeft(); m_count.TrimRight();
- if (m_count.IsEmpty() || type.IsEmpty() || name.IsEmpty())
- {
- AfxMessageBox("资料不全, 打*号的项目为必填项目!");
- return;
- }
- CString sql;
- if (m_mode == 0)
- {
- sql.Format("insert into [storeinfo]([id],[type],[name],[count],[date],[clerk],[remark])values('%s','%s','%s','%s','%s','%s','%s')", m_id, type, name, m_count, m_date, m_clerk, m_remark);
- }
- else
- {
- sql.Format("insert into [storeinfo2]([id],[type],[name],[count],[date],[clerk],[remark])values('%s','%s','%s','%s','%s','%s','%s')", m_id, type, name, m_count, m_date, m_clerk, m_remark);
- }
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
- AfxMessageBox("保存成功!", MB_ICONINFORMATION);
- ////////////////////
- sql = "select max(id) as cot from storeinfo where [date]='" + g_date + "'";
- if (m_mode)
- sql = "select max(id) as cot from storeinfo2 where [date]='" + g_date + "'";
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- if (g_bSendOK == 0)
- {
- CDialog::OnCancel();
- return;
- }
- CString date = g_date;
- date.Replace("-", "");
- if (m_mode == 0)
- m_id.Format("%s-(rk)%03d", date, g_ncount + 1);
- else
- {
- m_id.Format("%s-(ck)%03d", date, g_ncount + 1);
- }
- m_comboname.SetCurSel(-1);
- m_count = _T("");
- m_remark = _T("");
- UpdateData(false);
- // CDialog::OnOK();
- }
|