use "win.vl"
|
use "treeview.vm"
|
use "dev:vm[xdwgrid.vm]"
|
use "dev:vm[xdwtable.vm]"
|
use "pref.vl"
|
use "dev:vm[xml.vm]"
|
use "dev:vm[xaserverarg.vm]"
|
use "dev:vm[xaserver.vm]"
|
use "dev:vm[xutil.vm]"
|
use "list.vl"
|
unit vbusiness.xpage
|
[
|
HrOrgMaint is extend list;
|
about HrOrgMaint
|
[
|
control:
|
|
method:
|
[
|
xdwtable__ dw_detail;
|
string m_operate;
|
string m_sguid;
|
string m_tvOrgID;
|
string m_tvOrgName;
|
string m_tvRootOrgID;
|
string m_tvRootOrgName;
|
|
xnode__ m_agentNode; //Agent Condition
|
string m_agentCond; //Agent Node
|
int SetAgent()
|
{
|
string xfNodeAgentArea = "agentarea";
|
xnode__ anode = new xnode__;
|
anode.setNativePointer(GetAgentNode(xfNodeAgentArea));
|
var xframeElement = GetElement();
|
var agent = xframeElement.selectSingleNode("agent/" + xfNodeAgentArea + "[1]/*");
|
if (agent)
|
{
|
string s = agent.xml;
|
SetAgentNodeContent(anode, s);
|
}
|
return 1;
|
}
|
|
//½¹µã¼¤»î´¦Àíº¯Êý
|
int OnSetFocus(ref TEvent evt, int p)
|
{
|
SetAgent();
|
|
//ÖØÖù¤¾ßÌõ
|
return 1;
|
}
|
|
int OnRetrieve()
|
{
|
xml__ x = new xml__;
|
x.setNativePointer(x.CreateInstance());
|
xaserverarg__ arg = new xaserverarg__;
|
arg.setNativePointer(arg.CreateInstance());
|
arg.AddArg("guid", m_sguid);
|
if (url::get("OrganizationStruct/detail.HrOrg", arg.GetString(), x) != 1)
|
{
|
trace(x.GetXmlDoc().text);
|
return -1;
|
}
|
else
|
{
|
trace(x.GetXml());
|
dw_detail.Retrieve(x);
|
dw_detail.Redraw();
|
}
|
return 1;
|
}
|
|
int OnSave()
|
{
|
int hIcon = xutil__::SetCursorWait();
|
//dw_detail.AcceptText();
|
string val;
|
xml__ x = new xml__;
|
x.setNativePointer(x.CreateInstance());
|
var xdoc = x.GetXmlDoc();
|
dw_detail.DwUpdateAllTo(xdoc);
|
val = xdoc.xml;
|
//trace(val);
|
//return 1;
|
xaserverarg__ args = new xaserverarg__;
|
args.setNativePointer(args.CreateInstance());
|
args.AddArg("content", val);
|
//trace(val);
|
xml__ x1 = new xml__;
|
x1.setNativePointer(x1.CreateInstance());
|
if (url::post("OrganizationStruct/update.HrOrg", args.GetString(), x1) != 1)
|
{
|
string error = x1.GetXmlDoc().text;
|
trace(error);
|
}
|
else
|
{
|
win__::MessageBox(GetHWND(), "±£´æ³É¹¦£¡", "Ìáʾ", 0);
|
}
|
dw_detail.ResetUpdateStatus();
|
xutil__::RestoreCursor(hIcon);
|
return 1;
|
}
|
|
int OnNew()
|
{
|
dw_detail.openUrl("×éÖ¯¼Ü¹¹.vface/template/HrOrg/detail");
|
if (m_operate == "new0")
|
{
|
dw_detail.SetItemString(1, "ParentOrgID", m_tvOrgID);
|
dw_detail.SetItemDisplayString(1, "ParentOrgID", m_tvOrgName);
|
}
|
dw_detail.SetItemString(1, "Status", "Y");
|
//dw_detail.SetItemDisplayString(1,"Status","ÓÐЧ");
|
return 1;
|
}
|
|
//ÃüÁî·¢²¼º¯Êý
|
int OnCmdDispatch(string comdid)
|
{
|
if (comdid == "New") OnNew();
|
if (comdid == "Save") OnSave();
|
if (comdid == "xmOk") OnSave();
|
if (comdid == "xmCancel") CloseWindow();
|
return 0;
|
}
|
|
//ÃüÁî´¦Àíʼþ
|
int OnXCommand(ref TXCommandEvent evt, int p)
|
{
|
return OnCmdDispatch(evt.pStrID);
|
}
|
|
int OnChildContent(ref TNotifyEvent evt, int p)
|
{
|
ref DWNMHDR dwhdr = evt.pnmh;
|
string col = dwhdr.colname;
|
if (col != "") {
|
xml__ x = new xml__;
|
x.setNativePointer(x.CreateInstance());
|
xaserverarg__ arg = new xaserverarg__;
|
arg.setNativePointer(arg.CreateInstance());
|
string query;
|
query = "[IResourceMSSql.xq]";
|
if (col == "OrgTypeID") {
|
arg.AddArg("ResourceType", "HrOrgType");//×éÖ¯ÀàÐÍ
|
}
|
else if (col == "OrgAddress000") {
|
arg.AddArg("ResourceType", "HR_Address");//×éÖ¯µØÖ·
|
}
|
else if (col == "CompanyID") {
|
arg.AddArg("ResourceType", "CompanyInfo");//ËùÊô·¨ÈË
|
}
|
else if (col == "OrgProLine") {
|
arg.AddArg("ResourceType", "OrgProLine");//²úÆ·Ïß
|
}
|
if (xaserver__::ExecXQuery(GetServerUrl(), query, arg.GetString(), x) == 1)
|
dwhdr.data = x.GetXml();
|
//trace(x.GetXml());
|
}
|
return 1;
|
}
|
int OnClicked(ref TNotifyEvent evt, int p)
|
{
|
ref DWNMHDR hdr = evt.pnmh;
|
|
xaserverarg__ arg = new xaserverarg__;
|
arg.setNativePointer(arg.CreateInstance());
|
|
string colname = hdr.colname;
|
if (colname == "ParentOrgID")
|
{
|
openUrl("×éÖ¯¼Ü¹¹.vface/xpage/HrOrg/Chart", arg);
|
//trace(arg.GetString());
|
string comdid = arg.GetArgString("comdid");
|
if (comdid == "xmOk")
|
{
|
string OrgName = arg.GetArgString("OrgName");
|
string OrgID = arg.GetArgString("OrgId");
|
dw_detail.SetItemDisplayString(1, "ParentOrgID", OrgName);
|
dw_detail.SetItemString(1, "ParentOrgID", OrgID);
|
dw_detail.Redraw();
|
}
|
}
|
if (colname == "LeaderID")
|
{
|
openUrl("×éÖ¯¼Ü¹¹.vface/xpage/hremployee/select", arg);
|
comdid = arg.GetArgString("comdid");
|
if (comdid == "xmOk")
|
{
|
string sPersonID = arg.GetArgString("sPersonID");
|
//trace(sPersonID);
|
string sPersonName = arg.GetArgString("sPersonName");
|
dw_detail.SetItemDisplayString(1, colname, sPersonName);
|
dw_detail.SetItemString(1, colname, sPersonID);
|
dw_detail.Redraw();
|
}
|
}
|
return 1;
|
}
|
|
int OnAttachEvent()
|
{
|
//°ó¶¨¹¤¾ßÌõµã»÷ʼþ
|
AttachEvent("WM_XCOMMAND", OnXCommand);
|
//»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ
|
AttachEvent("WM_SETFOCUS", OnSetFocus);
|
//ÏÂÀ¿ò ÌṩÄÚÈÝ
|
AttachEvent("dw_detail", "DWV_CHILDCONTENT", OnChildContent);
|
AttachEvent("dw_detail", "DWV_ITEMFOCUSCHANGED", OnClicked);
|
}
|
|
|
int OnInitial()
|
{
|
SetAgent();
|
OnAttachEvent();
|
return 1;
|
}
|
|
int onload()
|
{
|
dw_detail = new xdwtable__;
|
dw_detail.setNativePointer(this.GetControl("dw_detail"));
|
dw_detail.openUrl("×éÖ¯¼Ü¹¹.vface/template/HrOrg/detail");
|
OnInitial();
|
|
xaserverarg__ arg = new xaserverarg__;
|
arg.setNativePointer(arg.CreateInstance());
|
arg = this.GetParam();
|
if (arg)
|
{
|
m_operate = arg.GetArgString("operate");
|
m_sguid = arg.GetArgString("guid");
|
m_tvOrgID = arg.GetArgString("tvOrgID");//×éÖ¯Ê÷µÄID
|
m_tvOrgName = arg.GetArgString("tvOrgName");//×éÖ¯Ê÷µÄName
|
m_tvRootOrgID = arg.GetArgString("tvRootOrgID");//×éÖ¯Ê÷µÄID
|
m_tvRootOrgName = arg.GetArgString("tvRootOrgName");//×éÖ¯Ê÷µÄName
|
//alert(m_tvRootOrgName);
|
}
|
/*if ( m_sguid == "" || m_sguid == nil)
|
{
|
m_sguid = win__::GetGuid();//´íÎó
|
trace(m_sguid);
|
}*/
|
if (m_sguid != "") {
|
OnRetrieve();
|
};
|
if (m_operate == "new0")
|
{
|
//trace(m_tvOrgID);
|
dw_detail.SetItemString(1, "ParentOrgID", m_tvOrgID);
|
dw_detail.SetItemDisplayString(1, "ParentOrgID", m_tvOrgName);
|
dw_detail.SetItemString(1, "CompanyID", m_tvRootOrgID);
|
dw_detail.SetItemDisplayString(1, "CompanyID", m_tvRootOrgName);
|
dw_detail.SetItemString(1, "Status", "Y");
|
//dw_detail.SetItemDisplayString(1,"Status","ÓÐЧ");
|
}
|
return 1;
|
}
|
]
|
|
]
|
]
|