¶Ô±ÈÐÂÎļþ |
| | |
| | | #include <wobject/xstring.hpp> |
| | | #include <xcontrol/xtreeview.hpp> |
| | | #include <xcontrol/xdwgrid.hpp> |
| | | #include <wobject/xdouble.hpp> |
| | | #include <xcontrol/xlayersheet.hpp> |
| | | |
| | | #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" |
| | | #include "viewobject/view.base.hpp" |
| | | |
| | | using xml = KXMLDOMDocument; |
| | | class __declspec(dllexport) ForwarderMaint : public xframe |
| | | { |
| | | public: |
| | | KXMLDOMDocument m_configDoc; |
| | | |
| | | xdwtable dw_base; |
| | | xstring m_userid; |
| | | xstring m_username; |
| | | xstring ContactID; |
| | | xcell dw_cell; |
| | | |
| | | public: |
| | | ForwarderMaint(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {} |
| | | public: |
| | | static ForwarderMaint* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | ForwarderMaint* pWin = new ForwarderMaint(implPtr, (HWND)hWnd); |
| | | return pWin; |
| | | } |
| | | int alert(xstring str) |
| | | { |
| | | //win::MessageBox(GetHWND(),str,L"æç¤º22:",0); |
| | | TApp::alert(this, str); |
| | | return 0; |
| | | } |
| | | int setCellReadOnly() |
| | | { |
| | | dw_base = new xdwtable; |
| | | dw_base.setNativePointer(GetControl(L"dw_base")); |
| | | dw_cell = new xcell; |
| | | dw_cell.setNativePointer(dw_base.QueryItem(L"ixcell")); |
| | | xstring strnew = L"<cellprop celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='ä¿æ¤' cellvisibleex='' cellvisible='' cellvalid='' cellinitial=''/>"; |
| | | //dw_cell.SetCellProps(2,2,strnew); |
| | | return 0; |
| | | } |
| | | |
| | | xstring GetGuid() { |
| | | return publiccode::GetGuid(); |
| | | } |
| | | int OnClear() { |
| | | if (m_EntityID == L"") { |
| | | trace(1); |
| | | m_userid = publiccode::GetUser().id; |
| | | m_username = publiccode::GetUser().name; |
| | | dw_base = new xdwtable; |
| | | dw_base.setNativePointer(GetControl(L"dw_base")); |
| | | dw_base.SetItemString(1, L"ForwarderID", GetGuid()); |
| | | dw_base.SetItemString(1, L"PartyID", GetGuid()); |
| | | dw_base.SetItemString(1, L"PStatus", L"1"); |
| | | dw_base.SetItemDisplayString(1, L"PStatus", L"æ®é"); |
| | | dw_base.SetItemString(1, L"CreatorID", m_userid); |
| | | dw_base.SetItemString(1, L"PADStatus", L"1"); |
| | | dw_base.SetItemString(1, L"AddressID", GetGuid()); |
| | | dw_base.SetItemString(1, L"PADIdentifyAddressFlag", L"Y"); |
| | | dw_base.SetItemString(1, L"PADPrimaryFlag", L"Y"); |
| | | //dw_base.SetItemString(1,L"BankAccountID",GetGuid()); |
| | | dw_base.SetItemString(1, L"Type", L"5"); |
| | | dw_base.SetItemString(1, L"EnterName", m_userid); |
| | | dw_base.SetItemDisplayString(1, L"EnterName", m_username); |
| | | dw_base.SetItemString(1, L"CreateDate", publiccode::GetCurrentDate()); |
| | | /*xdwtable dw = new xdwtable; |
| | | dw.setNativePointer(dw_base.GetCurTable()); |
| | | xdwtable dwcon = new xdwtable; |
| | | dwcon.setNativePointer(dw.FindDwTable(L"Contacters",0)); |
| | | dwcon.SetItemString(1,L"ContactID",GetGuid()); |
| | | dwcon.SetItemString(1,L"PCStatus",L"1");*/ |
| | | //dw_base.SetItemString(1,L"EBankAccountID",GetGuid()); |
| | | //dw_base.SetItemString(1,L"CBankAccountID",GetGuid()); |
| | | /*xdwtable dweon = new xdwtable; |
| | | dweon.setNativePointer(dw_base.FindDwTable(L"item1",0)); |
| | | xdwtable dwcon = new xdwtable; |
| | | dwcon.setNativePointer(dw_base.FindDwTable(L"item2",0)); |
| | | dweon.SetItemString(1,L"EPBAStatus",L"Y"); |
| | | dwcon.SetItemString(1,L"CPBAStatus",L"Y"); |
| | | dweon.SetItemString(1,L"ECurrencyCode",L"USD"); |
| | | dwcon.SetItemString(1,L"CCurrencyCode",L"RMB");*/ |
| | | dw_base.SetItemString(1, L"ForwarderType", L"1"); |
| | | dw_base.SetItemDisplayString(1, L"ForwarderType", L"é¢ä»è´§"); |
| | | //dw_base.SetItemString(1,L"PrimaryContactID",dwcon.GetItemString(1,L"ContactID")); |
| | | |
| | | } |
| | | else |
| | | { |
| | | setCellReadOnly(); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | int OnAddrow() |
| | | { |
| | | dw_base = new xdwtable; |
| | | dw_base.setNativePointer(GetControl(L"dw_base")); |
| | | xdwtable dw = new xdwtable; |
| | | dw.setNativePointer(dw_base.GetCurTable()); |
| | | xstring dw_n = dw.GetDwName(); |
| | | if (dw_n == L"item") |
| | | { |
| | | dw.InsertRow(0); |
| | | int rows = dw.GetRowCount(); |
| | | dw.SetRow(rows); |
| | | } |
| | | return 1; |
| | | } |
| | | int OnInsertRow() |
| | | { |
| | | dw_base = new xdwtable; |
| | | dw_base.setNativePointer(GetControl(L"dw_base")); |
| | | xdwtable dw = new xdwtable; |
| | | dw.setNativePointer(dw_base.GetCurTable()); |
| | | xstring dw_n = dw.GetDwName(); |
| | | if (dw_n == L"item") |
| | | { |
| | | int row = dw.GetRow(); |
| | | if (row < 1) return 0; |
| | | dw.InsertRow(row); |
| | | dw.SetRow(row); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnDeleteRow() |
| | | { |
| | | dw_base = new xdwtable; |
| | | dw_base.setNativePointer(GetControl(L"dw_base")); |
| | | xdwtable dw = new xdwtable; |
| | | dw.setNativePointer(dw_base.GetCurTable()); |
| | | xstring dw_n = dw.GetDwName(); |
| | | if (dw_n == L"item") |
| | | { |
| | | int row = dw.GetRow(); |
| | | if (row < 1) return 0; |
| | | /*xstring del = dw.GetItemString(row,8); |
| | | if(del!=L"") |
| | | { |
| | | if(m_dels==L"") |
| | | { |
| | | m_dels=del; |
| | | } |
| | | else |
| | | { |
| | | xstring temp=m_dels; |
| | | m_dels=del + L"|" + temp; |
| | | //+= L"|"+del; |
| | | } |
| | | |
| | | }*/ |
| | | dw.DeleteRow(row); |
| | | dw.SetRow(row - 1); |
| | | } |
| | | //trace(m_dels); |
| | | return 1; |
| | | } |
| | | xstring getGoodsNo() |
| | | { |
| | | xml x; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | if (getUrl(L"/sale/data/LogisticsCode/pref/PartyNo", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.xml()); |
| | | return L""; |
| | | } |
| | | KXMLDOMElement e = x.documentElement(); |
| | | if (e) |
| | | { |
| | | xstring code = e.text(); |
| | | trace(code); |
| | | return L"F" + code; |
| | | } |
| | | return L"F1000"; |
| | | } |
| | | int OnPreSave() |
| | | { |
| | | dw_base.AcceptText(); |
| | | dw_base = new xdwtable; |
| | | dw_base.setNativePointer(GetControl(L"dw_base")); |
| | | xstring ForwarderNo = dw_base.GetItemString(1, L"ForwarderNo"); |
| | | if (ForwarderNo == L"") |
| | | { |
| | | dw_base.SetItemString(1, L"ForwarderNo", getGoodsNo()); |
| | | } |
| | | xdwtable dwcon = new xdwtable; |
| | | dwcon.setNativePointer(dw_base.FindDwTable(L"item", 0)); |
| | | int i; |
| | | for (i = 1; i <= dwcon.GetRowCount(); i++) |
| | | { |
| | | xstring aTemp; |
| | | xstring aName = dwcon.GetItemString(i, L"ContacterName"); |
| | | trace(aName); |
| | | if (aName == L"") |
| | | { |
| | | aTemp = dwcon.GetItemString(i, L"Mobile") + dwcon.GetItemString(i, L"TEL") + dwcon.GetItemString(i, L"Fax") + dwcon.GetItemString(i, L"Email") + dwcon.GetItemString(i, L"PCRemark") + dwcon.GetItemString(i, L"fz"); |
| | | trace(aTemp); |
| | | if (aTemp != L"") |
| | | { |
| | | alert(L"è系人åç§°å¿
å¡«ï¼"); |
| | | return -1; |
| | | } |
| | | } |
| | | else { |
| | | xstring ContactID = dwcon.GetItemString(i, L"ContactID"); |
| | | if (ContactID == L"") |
| | | { |
| | | dwcon.SetItemString(i, L"ContactID", GetGuid()); |
| | | dwcon.SetItemString(i, L"PCStatus", L"Y"); |
| | | dw_base.SetItemString(1, L"PrimaryContactID", dwcon.GetItemString(1, L"ContactID")); |
| | | } |
| | | } |
| | | } |
| | | xdwtable dwcon2 = new xdwtable; |
| | | dwcon2.setNativePointer(dw_base.FindDwTable(L"item2", 0)); |
| | | int k; |
| | | xstring sPBABankName2 = L""; |
| | | xstring sPBABankAccountNo2 = L""; |
| | | for (k = 1; k <= dwcon2.GetRowCount(); k++) |
| | | { |
| | | sPBABankName2 = dwcon2.GetItemString(k, L"CBank"); |
| | | sPBABankAccountNo2 = dwcon2.GetItemString(k, L"CBankNo"); |
| | | |
| | | xstring sPBAAll2 = sPBABankName2 + sPBABankAccountNo2; |
| | | |
| | | if (sPBAAll2 != L"") |
| | | { |
| | | if (sPBABankName2 == L"") |
| | | { |
| | | alert(L"人æ°å¸é¶è¡åç§°ä¸è½ä¸ºç©º"); |
| | | return -1; |
| | | } |
| | | if (sPBABankAccountNo2 == L"") |
| | | { |
| | | alert(L"人æ°å¸é¶è¡è´¦æ·ä¸è½ä¸ºç©º"); |
| | | return -1; |
| | | } |
| | | dwcon2.SetItemString(k, L"CPBAStatus", L"Y"); |
| | | dwcon2.SetItemString(k, L"CCurrencyCode", L"RMB"); |
| | | dwcon2.SetItemString(k, L"CBankAccountID", GetGuid()); |
| | | |
| | | if (dwcon2.GetItemString(k, L"CBankAccountID") != L"" && m_EntityID == L"") |
| | | { |
| | | dw_base.SetItemString(1, L"CBkAccountID", dwcon2.GetItemString(k, L"CBankAccountID")); |
| | | } |
| | | } |
| | | } |
| | | xdwtable dwcon1 = new xdwtable; |
| | | dwcon1.setNativePointer(dw_base.FindDwTable(L"item1", 0)); |
| | | int j; |
| | | xstring sPBABankName1 = L""; |
| | | xstring sPBABankAccountNo1 = L""; |
| | | for (j = 1; j <= dwcon1.GetRowCount(); j++) |
| | | { |
| | | xstring sPBABankName1 = dwcon1.GetItemString(j, L"EBank"); |
| | | xstring sPBABankAccountNo1 = dwcon1.GetItemString(j, L"EBankNo"); |
| | | |
| | | xstring sPBAAll1 = sPBABankName1 + sPBABankAccountNo1; |
| | | if (sPBAAll1 != L"") |
| | | { |
| | | if (sPBABankName1 == L"") |
| | | { |
| | | alert(L"ç¾éé¶è¡åç§°ä¸è½ä¸ºç©º"); |
| | | return -1; |
| | | } |
| | | if (sPBABankAccountNo1 == L"") |
| | | { |
| | | alert(L"ç¾éé¶è¡è´¦æ·ä¸è½ä¸ºç©º"); |
| | | return -1; |
| | | } |
| | | dwcon1.SetItemString(j, L"EPBAStatus", L"Y"); |
| | | dwcon1.SetItemString(j, L"ECurrencyCode", L"USD"); |
| | | dwcon1.SetItemString(j, L"EBankAccountID", GetGuid()); |
| | | if (dwcon1.GetItemString(j, L"EBankAccountID") != L"" && m_EntityID == L"") |
| | | { |
| | | dw_base.SetItemString(1, L"EBkAccountID", dwcon1.GetItemString(j, L"EBankAccountID")); |
| | | } |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | int OnPostSave() |
| | | { |
| | | dw_base = new xdwtable; |
| | | dw_base.setNativePointer(GetControl(L"dw_base")); |
| | | xaserverarg args; |
| | | |
| | | xml x; |
| | | |
| | | dw_base.DwUpdateAllTo(x); |
| | | //trace(x.xml()); |
| | | |
| | | //主è系人 |
| | | xstring spGuid; |
| | | KXMLDOMElement e; |
| | | var list = x.selectNodes(L"//item"); |
| | | int nlen = list.length; |
| | | int i; |
| | | for (i = 0; i < nlen; i++) |
| | | { |
| | | e = list.item(i); |
| | | if (i == 0) spGuid = e.selectSingleNode(L"@guid").text(); |
| | | xstring sP = e.selectSingleNode(L"PPrimaryFlag").text(); |
| | | if (sP == L"Y") |
| | | { |
| | | spGuid = e.selectSingleNode(L"@guid").text(); |
| | | break; |
| | | } |
| | | } |
| | | if (spGuid == L"") |
| | | { |
| | | trace(L"error"); |
| | | return 0; |
| | | } |
| | | args.AddArg(L"contact", spGuid); |
| | | //trace(L"<---->"); |
| | | //trace(spGuid); |
| | | xml x1; |
| | | |
| | | if (getUrl(L"/sale/data/SupplierSubmit/pref/primarycontact", args.GetString(), x) != 1) |
| | | { |
| | | xstring error = x1.text(); |
| | | trace(error); |
| | | return 0; |
| | | } |
| | | |
| | | |
| | | return 1; |
| | | } |
| | | int OnSave() |
| | | { |
| | | dw_base = new xdwtable; |
| | | dw_base.setNativePointer(GetControl(L"dw_base")); |
| | | xstring SName = dw_base.GetItemString(1, L"Name"); |
| | | if (SName == L"") { |
| | | alert(L"请è¾å
¥è´§ä»£åç§°ï¼"); |
| | | return -1; |
| | | } |
| | | int rec = OnPreSave(); |
| | | if (rec == -1) return -1; |
| | | xml x; |
| | | |
| | | dw_base.DwUpdateAllTo(x); |
| | | trace(x.xml()); |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"content", x.xml()); |
| | | arg.AddArg(L"dbmap", L"Forwarder.dbmap"); |
| | | //arg.AddArg(L"m_dels",m_dels); |
| | | if (getUrl(L"/sale/data/LogisticsCode/entity/save", arg.GetString(), x) != 1) |
| | | { |
| | | trace(L"error:" + (xstring)x.xml()); |
| | | alert(L"ä¿å失败!"); |
| | | return 0; |
| | | } |
| | | else |
| | | { |
| | | trace(x.xml()); |
| | | if (x.selectSingleNode(L"error")) |
| | | { |
| | | alert(L"ä¿ååºé2!"); |
| | | return 0; |
| | | } |
| | | alert(L"ä¿åæå!"); |
| | | dw_base.ResetUpdateStatus(); |
| | | OnPostSave(); |
| | | } |
| | | dw_base.Redraw(); |
| | | //m_dels=L""; |
| | | return 0; |
| | | } |
| | | int OnCmdDispatch(xstring comdid) |
| | | { |
| | | if (comdid.find(L"action:bill.row.add", 0) >= 0) { |
| | | OnAddrow(); |
| | | } |
| | | else if (comdid.find(L"bill.row.insert", 0) >= 0) { |
| | | OnInsertRow(); |
| | | } |
| | | else if (comdid.find(L"bill.row.delete", 0) >= 0) { |
| | | OnDeleteRow(); |
| | | } |
| | | else if (comdid.find(L"bill.save", 0) >= 0) { |
| | | //trace(1); |
| | | OnSave(); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | int OnXCommand(TEvent* evt, LPARAM param) |
| | | { |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | | int OnCellChanged(TEvent* evt, LPARAM p) |
| | | { |
| | | dw_base = new xdwtable; |
| | | dw_base.setNativePointer(GetControl(L"dw_base")); |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | xstring colname = hdr.colname; |
| | | xstring coldata = hdr.data; |
| | | trace(colname); |
| | | if (colname == L"ForwarderNo") |
| | | { |
| | | xstring cspec = dw_base.GetItemString(1, 1); |
| | | trace(cspec); |
| | | xstring SpecRule = L"^\\d*$"; |
| | | xaserverarg args; |
| | | |
| | | args.AddArg(L"CSpec", cspec); |
| | | args.AddArg(L"SpecRule", SpecRule); |
| | | xml x; |
| | | |
| | | getUrl(L"/sale/data/LogisticsCode/pref/forwarderno/check", args.GetString(), x); |
| | | |
| | | if (x.selectSingleNode(L"root/spec")) |
| | | { |
| | | alert(L"请è¾å
¥æ°åï¼"); |
| | | return 0; |
| | | } |
| | | |
| | | } |
| | | //åªè½éä¸ä¸ªä¸»è系人 |
| | | else if (colname == L"PPrimaryFlag" && coldata == L"Y") |
| | | { |
| | | xdwtable dw_pc; |
| | | dw_pc = new xdwtable; |
| | | dw_pc.setNativePointer(dw_base.FindDwTable(L"item")); |
| | | if (dw_pc) |
| | | { |
| | | int i; |
| | | for (i = 1; i <= dw_pc.GetRowCount(); i++) |
| | | { |
| | | if (i != hdr.row) |
| | | dw_pc.SetItemString(i, L"PPrimaryFlag", L"N"); |
| | | } |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | int OnAttachEvent() |
| | | { |
| | | AttachEvent(L"WM_XCOMMAND", (FEvent)&ForwarderMaint::OnXCommand); |
| | | //AttachEvent(L"WM_SETFOCUS",OnSetFocus); |
| | | AttachEvent(L"dw_base", L"DWV_ITEMCHANGED", (FEvent)&ForwarderMaint::OnCellChanged); |
| | | return 1; |
| | | } |
| | | int onload() |
| | | { |
| | | dw_base = new xdwtable; |
| | | dw_base.setNativePointer(GetControl(L"dw_base")); |
| | | |
| | | OnAttachEvent(); |
| | | //if(!m_configDoc) return -1; |
| | | |
| | | maint::onload(); |
| | | |
| | | OnClear(); |
| | | } |
| | | |
| | | }; |