xj qian
2024-07-16 7a91c3a1ed37b0332d4ff0ebeae60bd6da3665c0
jrj/project/business/BasicCode/SKUTemplate.select.cpp
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,120 @@
use "dev:code[SKUTemplate.vx]"
unit vbusiness.vpage
[
   SKUTemplateImport is extend SKUTemplate;
   about SKUTemplateImport
   [
      field:
         xdwgrid   dw_list;
         xdwtable  dw_other;
         xdwtable  dw_prop;
      method:
      [
         xstring jxParam(xstring p, xstring n)
         {
            if(p != L"")
            {
               int i = 1;
               while (p.find(L"=L",0)>0)
               {
                  xstring name = p.mid(0, p.find(L"=L",0));
                  xstring value = p.mid(p.find(L"=L",0) + 1, p.find(L"=L",0) - 1);
                  return ""+value;
                  i += 1;
               }
            }
            return "";
         }
         int OnSelectAll()
         {
            if(this.dw_list.GetRowCount() > 0 )
               this.dw_list.SelectRow(1,true);
            this.dw_list.SelectRow(0,true);
            this.dw_list.Redraw();
            return 1;
         }
         int OnSelectNo()
         {
            this.dw_list.SelectRow(0,false);
            this.dw_list.Redraw();
            return 1;
         }
         int OnOk()
         {
            dw_other.openUrl(L"/sale/view/CustomerGoods/template/CustomerGoods/itemother");
            dw_other.SetColHeaderHeight(0);
            dw_other.SetRowSelectorWidth(0);
            int row = SKUTemplate::dw_list.GetNextSelectRow(1);
            if (row<1)
            {
               alert(L"请选择模板!");
               return 1;
            }
            msxml::IXMLDOMElement e =SKUTemplate::dw_list.GetRowElement(row);
            xstring TemplateContent = e.selectSingleNode(L"TemplateContent").text+L"";
            xstring TemplateID = e.selectSingleNode(L"TemplateID").text+L"";
            //trace(ItemName);
            xml x = new xml;
            x.setNativePointer(x.CreateInstance());
            x.LoadXml(TemplateContent);
            dw_other.Retrieve(x);
            dw_prop.SetItemString(1,L"TemplateID",TemplateID);
            CloseWindow();
            return 1;
         }
         int OnCancel()
         {
            CloseWindow();
            return 1;
         }
         int OnDoubleClicked(ref TNotifyEvent evt,int p)
         {
            OnOk();
            return 1;
         }
         int OnCmdDispatch(xstring comdid)
         {
            if (comdid==L"SelectAll") OnSelectAll();
            else if (comdid==L"SelectNo") OnSelectNo();
            else if (comdid==L"cb_import") OnOk();
            else if (comdid==L"cb_close") OnCancel();
            //else if (comdid==L"query") GridSearch();
            return 0;
         }
         int OnXCommand(ref TXCommandEvent evt,int p)
         {
            return OnCmdDispatch(evt.pStrID);
         }
         int onload()
         {
            if (GetParam())
            {
               int iArgs = GetParam();
               xaserverarg arg1 = new xaserverarg;
               arg1.setNativePointer(iArgs);
               dw_other = new xdwtable;
               dw_other.setNativePointer(arg1.GetArgString(L"dw_other").toInt());
               dw_prop = new xdwtable;
               dw_prop.setNativePointer(arg1.GetArgString(L"dw_prop").toInt());
            }
            //trace(dw_other.nativept);
            SKUTemplate::onload();
            SKUTemplate::dw_list.SetSelectionMode(1); //3
            SKUTemplate::dw_list.SetReadOnly(true);
            AttachEvent(L"WM_XCOMMAND",OnXCommand);
              AttachEvent(L"dw_list",L"DWV_DOUBLECLICKED",OnDoubleClicked);//行双击
         }
      ]
   ]
]