#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"
|
|
#include "SysUser.hpp"
|
|
using xml = KXMLDOMDocument;
|
class __declspec(dllexport) AddUser : public xwin
|
{
|
|
public:
|
|
xstring note;
|
int hitem;
|
int row;
|
int wid;
|
xtreeview tv;
|
xdwgrid dw;
|
xwin pwin;
|
pa p;
|
public:
|
AddUser(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd) {}
|
public:
|
static AddUser* CreateInstance(void* implPtr, void* hWnd)
|
{
|
AddUser* pWin = new AddUser(implPtr, (HWND)hWnd);
|
return pWin;
|
}
|
|
int SetAgent()
|
{
|
return 1;
|
}
|
//½¹µã¼¤»î´¦Àíº¯Êý
|
int OnSetFocus(TEvent* evt, LPARAM param)
|
{
|
int SetAgent();
|
|
//ÖØÖù¤¾ßÌõ
|
return 1;
|
}
|
int AppendItem(xml x, KXMLDOMElement r, xstring item) {
|
var e = x.createElement(item);
|
//xcontrol xc = GetControl(item);
|
xcontrol xc = GetControl(item);
|
e.text() = xc.GetText();
|
r.appendChild(e);
|
return 1;
|
}
|
|
int OnSave()
|
{
|
xcontrol xc = GetControl(L"UserName");
|
/*xc=GetControl(L"EmployeeNo");
|
if (xc.GetText()==L"")
|
{
|
alert(L"Óû§´úÂë²»ÄÜΪ¿Õ£¡");
|
return 0;
|
}*/
|
|
if (xc.GetText() == L"")
|
{
|
alert(L"Óû§Ãû³Æ²»ÄÜΪ¿Õ£¡");
|
return 0;
|
}
|
xml x;
|
|
xaserverarg arg;
|
|
x.loadXML(L"<SysUser/>");
|
var r = x.documentElement();
|
xstring guid;
|
xstring guid1;
|
if (p.note == L"ÐÞ¸Ä")
|
{
|
KXMLDOMElement ele = xdwgrid::GetRowElement(p.row);
|
guid = ele.selectSingleNode(L"UserID").text();
|
//guid=ele.getAttribute(L"guid");
|
//if (ele.selectSingleNode(L"empid"))
|
// r.appendChild(ele.selectSingleNode(L"empid"));
|
}
|
else
|
guid = GetGuid();
|
//guid1=win32::GetGuid();
|
r.setAttribute(L"guid", guid);
|
//r.setAttribute(L"guid1",guid1);
|
//AppendItem(x,r,L"EmployeeNo");
|
AppendItem(x, r, L"UserName");
|
AppendItem(x, r, L"PassWord");
|
AppendItem(x, r, L"Status");
|
//trace(x.xml());
|
//return 1;
|
arg.AddArg(L"content", x.xml());
|
int ls_item = treeview::GetSelectedItem(p.wid);
|
KXMLDOMElement e = treeview::GetItemData(p.wid, ls_item);
|
xstring gpguid = e.selectSingleNode(L"@guid").text();
|
arg.AddArg(L"gpguid", gpguid);
|
if (xaserver::ExecXAction(GetServerUrl(), L"[update.User.xa]", arg.GetString()) == 1)
|
{
|
alert(L"ok");
|
if (p.note == L"ÐÞ¸Ä")
|
{
|
xdwgrid dw = new xdwgrid;
|
//dw.setNativePointer(p.dw_user);
|
int row = dw.GetNextSelectRow(0);
|
//dw.SetItemString(row,L"UserName",L"");
|
KXMLDOMElement e;
|
e = x.documentElement();
|
xstring ls_pass = e.selectSingleNode(L"PassWord").text();
|
xstring ls_status = e.selectSingleNode(L"Status").text();
|
dw.SetItemString(row, L"PassWord", ls_pass);
|
dw.SetItemString(row, L"Status", ls_status);
|
dw.Redraw();
|
}
|
else
|
{
|
//----------
|
//p.pwin.OnTreeSelChanged();
|
}
|
}
|
else
|
{
|
alert(L"±£´æ³ö´í!");
|
return 0;
|
}
|
return 1;
|
}
|
|
int ClearItem(xstring item)
|
{
|
xcontrol xc =GetControl(item);
|
xc.SetText(L"");
|
return 1;
|
}
|
//ÃüÁî·¢²¼º¯Êý
|
int OnCmdDispatch(xstring comdid)
|
{
|
if (comdid == L"cb_cancel")
|
CloseWindow();
|
else if (comdid == L"cb_ok")
|
{
|
int r = OnSave();
|
if (r == 1)
|
CloseWindow();
|
}
|
else if (comdid == L"cb_save")
|
{
|
OnSave();
|
p.note = L"ÐÂÔö";
|
SetWindowText(GetHWND(), p.note + L"Óû§");
|
ClearItem(L"userno");
|
ClearItem(L"username");
|
ClearItem(L"pwd");
|
}
|
return 0;
|
}
|
|
//ÃüÁî´¦Àíʼþ
|
int OnXCommand(TEvent* evt, LPARAM param)
|
{
|
return OnCmdDispatch(evt->xcommand.pStrID);
|
}
|
|
int OnAttachEvent()
|
{
|
//°ó¶¨¹¤¾ßÌõµã»÷ʼþ
|
AttachEvent(L"WM_XCOMMAND", (FEvent)&AddUser::OnXCommand);
|
//»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ
|
AttachEvent(L"WM_SETFOCUS", (FEvent)&AddUser::OnSetFocus);
|
return 1;
|
}
|
|
int OnInitial()
|
{
|
SetAgent();
|
|
OnAttachEvent();
|
|
return 1;
|
}
|
|
int SetItem(xstring value, xstring item) {
|
xcontrol xc = GetControl(item);
|
xc.SetText(value);
|
return 1;
|
}
|
int onload()
|
{
|
SetArg();
|
OnInitial();
|
p = new pa;
|
|
if (GetWinParam())
|
{
|
p = GetArg();
|
SetWindowText(GetHWND(), p.note + L"Óû§");
|
if (p.note == L"ÐÞ¸Ä")
|
{
|
xdwgrid dw = new xdwgrid;
|
dw.setNativePointer(p.dw);
|
KXMLDOMElement ele = dw.GetRowElement(p.row);
|
//if(ele.selectSingleNode(L"EmployeeNo"))
|
//SetItem(ele.selectSingleNode(L"EmployeeNo").text(),L"EmployeeNo");
|
if (ele.selectSingleNode(L"UserName"))
|
SetItem(ele.selectSingleNode(L"UserName").text(), L"UserName");
|
if (ele.selectSingleNode(L"PassWord"))
|
SetItem(ele.selectSingleNode(L"PassWord").text(), L"PassWord");
|
if (ele.selectSingleNode(L"Status"))
|
SetItem(ele.selectSingleNode(L"Status").text(), L"Status");
|
trace(L"Aa");
|
return 1;
|
}
|
}
|
return 1;
|
}
|
};
|