public SearchForm(DataSource userDS) {

    setDataSource(userDS);
    setTop(20);
    setCellPadding(6);
    setNumCols(7);
    setStyleName("defaultBorder");

    findUser = new ButtonItem("Find");
    findUser.setIcon("silk/find.png");
    findUser.setWidth(70);
    findUser.setEndRow(false);

    TextItem searchWord = new TextItem("searchWord", "Search Word");
    searchWord.setEndRow(false);
    searchWord.addKeyPressHandler(
        new KeyPressHandler() {

          public void onKeyPress(KeyPressEvent event) {
            if (event.getKeyName().equals("Enter")) {
              findUser.fireEvent(new ClickEvent(null));
            }
          }
        });

    searchCondition = new ComboBoxItem("searchCondition", "Select");
    LinkedHashMap<String, String> data = new LinkedHashMap<String, String>();
    data.put("userId", "User ID");
    data.put("userName", "User Name");
    searchCondition.setValueMap(data);
    searchCondition.setValue("userId");

    setItems(findUser, searchCondition, searchWord);
  }
Beispiel #2
0
  public ListaVentas(final Sgc_capa_web mainWindow) {

    String PATH_IMG = "/sgc_capa_web/images/";
    VLayout layout = new VLayout(10);
    layout.setBackgroundColor("#006633");
    final ListGrid facturaGrid = new ListGrid();

    facturaGrid.setWidth(500);
    facturaGrid.setHeight(224);
    facturaGrid.setShowAllRecords(true);
    facturaGrid.setAlternateRecordStyles(true);
    facturaGrid.setShowEdges(true);
    facturaGrid.setBorder("0px");
    facturaGrid.setBodyStyleName("normal");
    facturaGrid.setLeaveScrollbarGap(false);
    facturaGrid.setBackgroundColor("#99ffcc");

    /*-Buscar ------------------------------*/
    DynamicForm buscarFields = new DynamicForm();
    // buscarFields.setBackgroundColor("#99ffcc");
    buscarFields.setItemLayout(FormLayoutType.ABSOLUTE);

    final TextItem codigoText = new TextItem("codigo");
    codigoText.setWrapTitle(false);
    codigoText.setLeft(10);
    codigoText.setWidth(43);
    codigoText.addKeyPressHandler(
        new KeyPressHandler() {
          public void onKeyPress(KeyPressEvent event) {
            if ("Enter".equals(event.getKeyName())) {
              /* buscar por el campo correspondiente */
              if (codigoText.getValue() != null) {

                Factura factura = new Factura();
                factura.setId(Integer.parseInt(codigoText.getValue().toString()));
                listar(facturaGrid, factura, "codigo");
              }
            }
          }
        });

    ButtonItem buscarButton = new ButtonItem("find", "");
    buscarButton.setIcon("view.png");
    buscarButton.setWidth(50);
    buscarButton.setLeft(443);
    buscarButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            /* buscar por el campo correspondiente */
            Factura factura = new Factura();

            if (codigoText.getValue() != null)
              factura.setId(Integer.parseInt(codigoText.getValue().toString()));
            /*if(nombreusuarioText.getValue() != null)
            cliente.setNombreusuario(nombreusuarioText.getValue().toString());*/
            listar(facturaGrid, factura, "nombre");
          }
        });

    buscarFields.setFields(codigoText, buscarButton);
    /*--------------------------------------*/

    ListGridField codigoField = new ListGridField("codigo", "Codigo");
    ListGridField fechaField = new ListGridField("fecha", "Fecha");
    ListGridField numeroField = new ListGridField("numero", "Numero");
    ListGridField pendienteField = new ListGridField("pendiente", "Pendiente");
    ListGridField saldoField = new ListGridField("saldo", "Saldo");
    ListGridField editarField = new ListGridField("edit", "Editar");
    ListGridField borrarField = new ListGridField("remove", "Borrar");

    codigoField.setAlign(Alignment.CENTER);
    editarField.setAlign(Alignment.CENTER);
    borrarField.setAlign(Alignment.CENTER);

    editarField.setType(ListGridFieldType.IMAGE);
    borrarField.setType(ListGridFieldType.IMAGE);

    editarField.setImageURLPrefix(PATH_IMG);
    borrarField.setImageURLPrefix(PATH_IMG);

    editarField.setImageURLSuffix(".png");
    borrarField.setImageURLSuffix(".png");

    facturaGrid.addCellClickHandler(
        new CellClickHandler() {
          @Override
          public void onCellClick(CellClickEvent event) {
            ListGridRecord record = event.getRecord();
            int col = event.getColNum();
            if (col > 4) {

              Factura factura = new Factura();
              factura.setId(record.getAttributeAsInt("codigo"));
              factura.setFecha(record.getAttributeAsDate("fecha"));
              factura.setNumero(Integer.parseInt(record.getAttribute("numero")));
              factura.setPendiente(record.getAttribute("pendiente"));
              factura.setSaldo(Double.parseDouble(record.getAttribute("saldo")));

              if (col == 5) {
                /* Editar */

                new VentaDetalle(factura, mainWindow);

              } else {
                /* Borrar */

                FacturaServiceAsync service = GWT.create(FacturaService.class);
                ServiceDefTarget serviceDef = (ServiceDefTarget) service;
                serviceDef.setServiceEntryPoint(GWT.getModuleBaseURL() + "facturaService");
                try {
                  service.eliminar(
                      record.getAttributeAsInt("codigo"),
                      new AsyncCallback<Void>() {

                        @Override
                        public void onFailure(Throwable caught) {
                          Window.alert(
                              "Ocurrio un error y no se puedo eliminar (objeto referenciado)"); // "
                          // +
                          // caught.getClass().getName() + " " + caught.getMessage()) ;
                        }

                        @Override
                        public void onSuccess(Void result) {
                          new ListaVentas(mainWindow);
                        }
                      });
                } catch (NumberFormatException e) {
                  e.printStackTrace();
                } catch (Exception e) {
                  e.printStackTrace();
                }
              }
            }
          }
        });

    codigoField.setWidth(50);
    fechaField.setWidth(180);
    numeroField.setWidth(50);
    pendienteField.setWidth(50);
    saldoField.setWidth(50);
    facturaGrid.setFields(
        codigoField, fechaField, numeroField, pendienteField, saldoField, editarField, borrarField);
    facturaGrid.setCanResizeFields(true);

    ButtonItem button = new ButtonItem("add", "Agregar");
    button.setStartRow(false);
    button.setWidth(80);
    button.setIcon("add.png");
    button.setAlign(Alignment.CENTER);
    button.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            new VentaDetalle(mainWindow);
          }
        });

    listar(facturaGrid, new Factura(), "nombre");

    Label label = new Label();
    label.setBackgroundColor("#99ffcc");
    label.setHeight(30);
    label.setWidth(500);
    label.setPadding(10);
    label.setAlign(Alignment.CENTER);
    label.setValign(VerticalAlignment.CENTER);
    label.setWrap(false);
    label.setShowEdges(true);
    label.setContents("<div style='color:black;font-size:15'><b>Lista de Ventas</b></div>");

    layout.addMember(label);
    layout.addMember(buscarFields);
    layout.addMember(facturaGrid);

    DynamicForm form = new DynamicForm();
    // form.setBackgroundColor("#99ffcc");
    form.setWidth(300);
    form.setItems(button);
    layout.addMember(form);
    mainWindow.showDialog(layout);
  }
  public TabFindAbonent() {
    setTitle(CallCenter.constants.findAbonent());
    setCanClose(true);

    datasource = DataSource.get("AbonentsDS");

    mainLayout = new VLayout(5);
    mainLayout.setWidth100();
    mainLayout.setHeight100();
    mainLayout.setMargin(5);

    searchForm = new DynamicForm();
    searchForm.setAutoFocus(true);
    searchForm.setWidth(750);
    searchForm.setNumCols(3);
    searchForm.setTitleOrientation(TitleOrientation.TOP);
    mainLayout.addMember(searchForm);

    firstNameItem = new TextItem();
    firstNameItem.setTitle(CallCenter.constants.name());
    firstNameItem.setWidth(250);
    firstNameItem.setName("firstNameItem");

    lastNameItem = new TextItem();
    lastNameItem.setTitle(CallCenter.constants.lastName());
    lastNameItem.setWidth(250);
    lastNameItem.setName("lastNameItem");

    phoneItem = new TextItem();
    phoneItem.setTitle(CallCenter.constants.phone());
    phoneItem.setWidth(250);
    phoneItem.setName("phone");

    streetItem = new TextItem();
    streetItem.setTitle(CallCenter.constants.street());
    streetItem.setName("street_name_geo");
    streetItem.setWidth(250);

    citiesItem = new ComboBoxItem();
    citiesItem.setTitle(CallCenter.constants.city());
    citiesItem.setName("city_name_geo");
    citiesItem.setWidth(250);
    citiesItem.setFetchMissingValues(true);
    citiesItem.setFilterLocally(false);
    citiesItem.setAddUnknownValues(false);

    DataSource cityDS = DataSource.get("CityDS");
    citiesItem.setOptionOperationId("searchCitiesFromDBForCombos");
    citiesItem.setOptionDataSource(cityDS);
    citiesItem.setValueField("city_id");
    citiesItem.setDisplayField("city_name_geo");

    citiesItem.setOptionCriteria(new Criteria());
    citiesItem.setAutoFetchData(false);

    citiesItem.addKeyPressHandler(
        new KeyPressHandler() {
          @Override
          public void onKeyPress(KeyPressEvent event) {
            Criteria criteria = citiesItem.getOptionCriteria();
            if (criteria != null) {
              String oldAttr = criteria.getAttribute("city_id");
              if (oldAttr != null) {
                Object nullO = null;
                criteria.setAttribute("city_id", nullO);
              }
            }
          }
        });

    regionItem = new ComboBoxItem();
    regionItem.setTitle(CallCenter.constants.cityRegion());
    regionItem.setName("city_region_name_geo");
    regionItem.setWidth(250);
    regionItem.setFetchMissingValues(true);
    regionItem.setFilterLocally(false);
    regionItem.setAddUnknownValues(false);

    DataSource streetsDS = DataSource.get("CityRegionDS");
    regionItem.setOptionOperationId("searchCityRegsFromDBForCombos");
    regionItem.setOptionDataSource(streetsDS);
    regionItem.setValueField("city_region_id");
    regionItem.setDisplayField("city_region_name_geo");

    Criteria criteria = new Criterion();
    regionItem.setOptionCriteria(criteria);
    regionItem.setAutoFetchData(false);

    regionItem.addKeyPressHandler(
        new KeyPressHandler() {
          @Override
          public void onKeyPress(KeyPressEvent event) {
            Criteria criteria = regionItem.getOptionCriteria();
            if (criteria != null) {
              String oldAttr = criteria.getAttribute("city_region_id");
              if (oldAttr != null) {
                Object nullO = null;
                criteria.setAttribute("city_region_id", nullO);
              }
            }
          }
        });

    searchForm.setFields(
        lastNameItem, firstNameItem, phoneItem, streetItem, citiesItem, regionItem);

    HLayout buttonLayout = new HLayout(5);
    buttonLayout.setWidth(750);
    buttonLayout.setHeight(30);
    buttonLayout.setAlign(Alignment.RIGHT);

    clearButton = new IButton();
    clearButton.setTitle(CallCenter.constants.clear());

    findButton = new IButton();
    findButton.setTitle(CallCenter.constants.find());

    buttonLayout.setMembers(findButton, clearButton);
    mainLayout.addMember(buttonLayout);

    listGrid =
        new ListGrid() {
          protected String getCellCSSText(ListGridRecord record, int rowNum, int colNum) {
            ListGridRecord countryRecord = (ListGridRecord) record;
            if (countryRecord == null) {
              return super.getCellCSSText(record, rowNum, colNum);
            }
            Integer deleted = countryRecord.getAttributeAsInt("deleted");
            if (deleted != null && !deleted.equals(0)) {
              return "color:red;";
            } else {
              return super.getCellCSSText(record, rowNum, colNum);
            }
          };
        };

    listGrid.setWidth(1000);
    listGrid.setHeight100();
    listGrid.setAlternateRecordStyles(true);
    listGrid.setDataSource(datasource);
    listGrid.setAutoFetchData(false);
    listGrid.setShowFilterEditor(false);
    listGrid.setCanEdit(false);
    listGrid.setCanRemoveRecords(false);
    listGrid.setFetchOperation("customSearchForCC");
    listGrid.setCanSort(false);
    listGrid.setCanResizeFields(false);
    listGrid.setCanSelectText(true);
    listGrid.setCanDragSelectText(true);
    listGrid.setShowFilterEditor(true);
    listGrid.setFilterOnKeypress(true);

    ListGridField firstname = new ListGridField("firstname", CallCenter.constants.name(), 120);
    firstname.setCanFilter(true);

    ListGridField lastname = new ListGridField("lastname", CallCenter.constants.lastName(), 150);
    lastname.setCanFilter(true);

    ListGridField city = new ListGridField("city", CallCenter.constants.city(), 140);
    city.setCanFilter(false);

    ListGridField address = new ListGridField("address", CallCenter.constants.address());
    address.setCanFilter(true);

    ListGridField phone = new ListGridField("phone", CallCenter.constants.phone(), 100);
    phone.setCanFilter(true);

    firstname.setAlign(Alignment.LEFT);
    lastname.setAlign(Alignment.LEFT);
    city.setAlign(Alignment.LEFT);
    address.setAlign(Alignment.LEFT);
    phone.setAlign(Alignment.CENTER);

    listGrid.setFields(lastname, firstname, city, address, phone);
    mainLayout.addMember(listGrid);

    clearButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            firstNameItem.clearValue();
            lastNameItem.clearValue();
            phoneItem.clearValue();
            streetItem.clearValue();
            citiesItem.clearValue();
            regionItem.clearValue();
          }
        });

    findButton.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            search();
          }
        });

    citiesItem.addChangedHandler(
        new ChangedHandler() {
          @Override
          public void onChanged(ChangedEvent event) {
            String value = citiesItem.getValueAsString();
            if (value == null) {
              return;
            }
            regionItem.clearValue();
            fillCityRegionCombo(new Integer(value));
          }
        });

    firstNameItem.addKeyPressHandler(
        new KeyPressHandler() {
          @Override
          public void onKeyPress(KeyPressEvent event) {
            if (event.getKeyName().equals("Enter")) {
              search();
            }
          }
        });
    lastNameItem.addKeyPressHandler(
        new KeyPressHandler() {
          @Override
          public void onKeyPress(KeyPressEvent event) {
            if (event.getKeyName().equals("Enter")) {
              search();
            }
          }
        });
    phoneItem.addKeyPressHandler(
        new KeyPressHandler() {
          @Override
          public void onKeyPress(KeyPressEvent event) {
            if (event.getKeyName().equals("Enter")) {
              search();
            }
          }
        });
    streetItem.addKeyPressHandler(
        new KeyPressHandler() {
          @Override
          public void onKeyPress(KeyPressEvent event) {
            if (event.getKeyName().equals("Enter")) {
              search();
            }
          }
        });

    listGrid.addRecordDoubleClickHandler(
        new RecordDoubleClickHandler() {
          @Override
          public void onRecordDoubleClick(RecordDoubleClickEvent event) {
            DlgViewAbonent dlgViewAbonent =
                new DlgViewAbonent(listGrid, datasource, listGrid.getSelectedRecord());
            dlgViewAbonent.show();
          }
        });

    setPane(mainLayout);
  }
Beispiel #4
0
 public void addFiledsKeyPressHandler(KeyPressHandler pressHandler) {
   userItem.addKeyPressHandler(pressHandler);
   passItem.addKeyPressHandler(pressHandler);
 }
Beispiel #5
0
  public PZoneChange() {
    restrictedEdits = DocFlow.user_obj.getZoneConfiguration().getRestricted_edits();
    CHARCOUNT = DocFlow.user_obj.getZoneConfiguration().getCharcount();
    tsMain = new ToolStrip();
    tsMain.setWidth100();
    HashMap<String, String> listSqls = new HashMap<String, String>();
    listSqls.put("" + ClSelection.T_REGION, "" + ClSelection.T_REGION);
    listSqls.put("" + ClSelection.T_CUST_TYPE, "" + ClSelection.T_CUST_TYPE);
    dsZoneDS = DocFlow.getDataSource("ZoneDS");
    dsCustomer = DocFlow.getDataSource("CustomerDS");
    miSearch = new ToolStripButton("Search");
    tiNewZone = new TextItem("newzone", "New Zone");
    biSaveData = new ButtonItem("saveData", "Change Zone");

    tiNewZone.addKeyPressHandler(
        new KeyPressHandler() {

          @Override
          public void onKeyPress(KeyPressEvent event) {
            newZoneKeyPressed(event);
          }
        });
    VLayout vl = new VLayout();

    dmCriteria = new DynamicForm();
    dmCriteria.setNumCols(4);
    dmCriteria.setHeight("8%");
    dmCriteria.setTitleOrientation(TitleOrientation.TOP);
    siCustomerType = new SelectItem("custypeid", "Customer Type");
    siZones = new SelectItem("zones", "Zones");
    siZones.setValueField("zone");
    siZones.setAutoFetchData(false);
    siZones.setDisplayField("zone");
    siZones.setOptionDataSource(dsZoneDS);

    tsMain.setHeight("15");
    vl.addMember(tsMain);
    tsMain.addButton(miSearch);
    vl.addMember(dmCriteria);
    lgCustomers = new ListGrid();
    lgCustomers.setDataSource(dsCustomer);
    lgCustomers.setAutoFetchData(false);
    lgCustomers.setShowResizeBar(false);
    lgCustomers.setCanDragRecordsOut(true);
    lgCustomers.setDragDataAction(DragDataAction.COPY);
    lgCustomers.setHeight100();
    lgCustomers.setHeight100();

    DataSource dsSelectedData = new DataSource();
    dsSelectedData.setClientOnly(true);

    DataSourceIntegerField dsfcusid = new DataSourceIntegerField("cusid", "Customer ID");
    dsfcusid.setPrimaryKey(true);

    DataSourceTextField dsZone = new DataSourceTextField("zone", "Zone");
    dsSelectedData.setFields(dsfcusid, dsZone);

    lgZoneCustomers = new ListGrid();
    lgZoneCustomers.setDataSource(dsSelectedData);
    lgZoneCustomers.setAutoFetchData(false);
    lgZoneCustomers.setCanAcceptDroppedRecords(true);
    lgZoneCustomers.setCanRemoveRecords(true);
    lgZoneCustomers.setAutoFetchData(false);
    lgZoneCustomers.setPreventDuplicates(true);
    lgZoneCustomers.setHeight100();
    lgZoneCustomers.setWidth100();

    HStack hStack = new HStack(10);
    hStack.setWidth100();
    hStack.setHeight100();
    hStack.setShowEdges(true);

    VStack vStack = new VStack();
    vStack.setHeight100();
    vStack.setWidth("60%");
    vStack.addMember(lgCustomers);
    hStack.addMember(vStack);
    TransferImgButton arrowImg = new TransferImgButton(TransferImgButton.RIGHT);
    arrowImg.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            lgZoneCustomers.transferSelectedData(lgCustomers);
          }
        });

    TransferImgButton arrowImgLeft = new TransferImgButton(TransferImgButton.LEFT);
    arrowImgLeft.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            lgZoneCustomers.removeSelectedData();
          }
        });
    hStack.addMember(arrowImg);
    hStack.addMember(arrowImgLeft);
    VStack vStack2 = new VStack();
    vStack2.setHeight100();
    vStack2.setWidth("40%");
    vStack2.addMember(lgZoneCustomers);
    hStack.addMember(vStack2);

    miSearch.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            search();
          }
        });

    lgCustomers.addClickHandler(
        new com.smartgwt.client.widgets.events.ClickHandler() {

          @Override
          public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {}
        });

    vl.addMember(hStack);

    this.addMember(vl);
    DocFlow.docFlowService.getListTypesForDocument(
        listSqls,
        -1,
        new AsyncCallback<HashMap<String, ArrayList<ClSelectionItem>>>() {

          @Override
          public void onFailure(Throwable caught) {
            setResults(null);
          }

          @Override
          public void onSuccess(HashMap<String, ArrayList<ClSelectionItem>> result) {

            setResults(result);
          }
        });
  }
  public TabBillingComps() {
    try {

      setTitle(CallCenterBK.constants.billingComps());
      setCanClose(true);

      billingCompsDS = DataSource.get("BillingCompsDS");

      mainLayout = new VLayout(5);
      mainLayout.setWidth100();
      mainLayout.setHeight100();
      mainLayout.setMargin(5);

      searchForm = new DynamicForm();
      searchForm.setAutoFocus(true);
      searchForm.setWidth(830);
      searchForm.setTitleWidth(250);
      searchForm.setNumCols(4);
      mainLayout.addMember(searchForm);

      billingCompNameItem = new TextItem();
      billingCompNameItem.setTitle(CallCenterBK.constants.companyName());
      billingCompNameItem.setWidth(250);
      billingCompNameItem.setName("billingCompNameItem");

      phoneIndexItem = new TextItem();
      phoneIndexItem.setTitle(CallCenterBK.constants.index());
      phoneIndexItem.setWidth(250);
      phoneIndexItem.setName("phoneIndexItem");

      hasCalcItem = new SelectItem();
      hasCalcItem.setTitle(CallCenterBK.constants.hasCalculation());
      hasCalcItem.setWidth(250);
      hasCalcItem.setName("hasCalcItem");
      hasCalcItem.setDefaultToFirstOption(true);
      hasCalcItem.setValueMap(ClientMapUtil.getInstance().getHasCalculations());

      operatorItem = new SelectItem();
      operatorItem.setTitle(CallCenterBK.constants.operator());
      operatorItem.setWidth(200);
      operatorItem.setName("operator_src");
      operatorItem.setDefaultToFirstOption(true);
      ClientUtils.fillCombo(
          operatorItem, "OperatorsDS", "searchOperators", "operator_src", "operator_src_descr");

      searchForm.setFields(billingCompNameItem, phoneIndexItem, hasCalcItem, operatorItem);

      HLayout buttonLayout = new HLayout(5);
      buttonLayout.setWidth(830);
      buttonLayout.setHeight(30);
      buttonLayout.setAlign(Alignment.RIGHT);

      clearButton = new IButton();
      clearButton.setTitle(CallCenterBK.constants.clear());

      findButton = new IButton();
      findButton.setTitle(CallCenterBK.constants.find());

      buttonLayout.setMembers(findButton, clearButton);
      mainLayout.addMember(buttonLayout);

      ToolStrip toolStrip = new ToolStrip();
      toolStrip.setWidth100();
      toolStrip.setPadding(5);
      mainLayout.addMember(toolStrip);

      addBtn = new ToolStripButton(CallCenterBK.constants.add(), "addIcon.png");
      addBtn.setLayoutAlign(Alignment.LEFT);
      addBtn.setWidth(50);
      toolStrip.addButton(addBtn);

      editBtn = new ToolStripButton(CallCenterBK.constants.modify(), "editIcon.png");
      editBtn.setLayoutAlign(Alignment.LEFT);
      editBtn.setWidth(50);
      toolStrip.addButton(editBtn);

      deleteBtn = new ToolStripButton(CallCenterBK.constants.disable(), "deleteIcon.png");
      deleteBtn.setLayoutAlign(Alignment.LEFT);
      deleteBtn.setWidth(50);
      toolStrip.addButton(deleteBtn);

      toolStrip.addSeparator();

      billingCompBillByDayBtn =
          new ToolStripButton(CallCenterBK.constants.telCombBillByDay(), "billing.png");
      billingCompBillByDayBtn.setLayoutAlign(Alignment.LEFT);
      billingCompBillByDayBtn.setWidth(50);
      toolStrip.addButton(billingCompBillByDayBtn);

      billingCompBillByMonthBtn =
          new ToolStripButton(CallCenterBK.constants.telCombBillByMonth(), "billing.png");
      billingCompBillByMonthBtn.setLayoutAlign(Alignment.LEFT);
      billingCompBillByMonthBtn.setWidth(50);
      toolStrip.addButton(billingCompBillByMonthBtn);

      billingCompsGrid = new ListGrid();

      billingCompsGrid.setWidth100();
      billingCompsGrid.setHeight100();
      billingCompsGrid.setAlternateRecordStyles(true);
      billingCompsGrid.setDataSource(billingCompsDS);
      billingCompsGrid.setAutoFetchData(false);
      billingCompsGrid.setShowFilterEditor(false);
      billingCompsGrid.setCanEdit(false);
      billingCompsGrid.setCanRemoveRecords(false);
      billingCompsGrid.setFetchOperation("searchAllBillingComps");
      billingCompsGrid.setShowRowNumbers(true);
      billingCompsGrid.setCanHover(true);
      billingCompsGrid.setShowHover(true);
      billingCompsGrid.setShowHoverComponents(true);
      billingCompsGrid.setWrapCells(true);
      billingCompsGrid.setFixedRecordHeights(false);
      billingCompsGrid.setCanDragSelectText(true);

      ListGridField billing_company_name =
          new ListGridField("billing_company_name", CallCenterBK.constants.companyName());

      ListGridField our_percent =
          new ListGridField("our_percent", CallCenterBK.constants.ourPercent(), 150);

      ListGridField has_calculation_descr =
          new ListGridField("has_calculation_descr", CallCenterBK.constants.hasCalculation(), 150);

      ListGridField call_price =
          new ListGridField("call_price", CallCenterBK.constants.callPrice(), 150);

      our_percent.setAlign(Alignment.CENTER);
      has_calculation_descr.setAlign(Alignment.CENTER);
      call_price.setAlign(Alignment.CENTER);

      billingCompsGrid.setFields(
          billing_company_name, our_percent, has_calculation_descr, call_price);

      mainLayout.addMember(billingCompsGrid);
      findButton.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              search();
            }
          });

      billingCompNameItem.addKeyPressHandler(
          new KeyPressHandler() {
            @Override
            public void onKeyPress(KeyPressEvent event) {
              if (event.getKeyName().equals("Enter")) {
                search();
              }
            }
          });

      phoneIndexItem.addKeyPressHandler(
          new KeyPressHandler() {
            @Override
            public void onKeyPress(KeyPressEvent event) {
              if (event.getKeyName().equals("Enter")) {
                search();
              }
            }
          });

      clearButton.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              billingCompNameItem.clearValue();
            }
          });

      addBtn.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              DlgAddEditBillingComps dlgAddEditBillingComp =
                  new DlgAddEditBillingComps(billingCompsGrid, null);
              dlgAddEditBillingComp.show();
            }
          });

      editBtn.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              ListGridRecord listGridRecord = billingCompsGrid.getSelectedRecord();

              if (listGridRecord == null) {
                SC.say(CallCenterBK.constants.pleaseSelrecord());
                return;
              }

              DlgAddEditBillingComps dlgAddEditBillingComp =
                  new DlgAddEditBillingComps(billingCompsGrid, listGridRecord);
              dlgAddEditBillingComp.show();
            }
          });
      deleteBtn.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
              final ListGridRecord listGridRecord = billingCompsGrid.getSelectedRecord();
              if (listGridRecord == null) {
                SC.say(CallCenterBK.constants.pleaseSelrecord());
                return;
              }
              SC.ask(
                  CallCenterBK.constants.askForDisable(),
                  new BooleanCallback() {
                    @Override
                    public void execute(Boolean value) {
                      if (value) {
                        delete(listGridRecord);
                      }
                    }
                  });
            }
          });

      billingCompsGrid.addRecordDoubleClickHandler(
          new RecordDoubleClickHandler() {
            @Override
            public void onRecordDoubleClick(RecordDoubleClickEvent event) {
              ListGridRecord listGridRecord = billingCompsGrid.getSelectedRecord();
              DlgAddEditBillingComps dlgAddEditBillingComp =
                  new DlgAddEditBillingComps(billingCompsGrid, listGridRecord);
              dlgAddEditBillingComp.show();
            }
          });

      billingCompBillByDayBtn.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {

              final ListGridRecord listGridRecord = billingCompsGrid.getSelectedRecord();
              if (listGridRecord == null) {
                SC.say(CallCenterBK.constants.pleaseSelrecord());
                return;
              }
              Integer billing_company_id = listGridRecord.getAttributeAsInt("billing_company_id");
              getBillingCompBillByDay(billing_company_id);
            }
          });
      billingCompBillByMonthBtn.addClickHandler(
          new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {

              final ListGridRecord listGridRecord = billingCompsGrid.getSelectedRecord();
              if (listGridRecord == null) {
                SC.say(CallCenterBK.constants.pleaseSelrecord());
                return;
              }
              Integer billing_company_id = listGridRecord.getAttributeAsInt("billing_company_id");
              getBillingCompBillByMonth(billing_company_id);
            }
          });

      setPane(mainLayout);
    } catch (Exception e) {
      SC.say(e.toString());
    }
  }
  private void initNewWindow() {

    this.setAutoSize(true);
    this.setTitle("新书入库");
    this.setCanDragReposition(true);
    this.setCanDragResize(false);
    this.setAutoCenter(true);
    this.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);

    VLayout vLayout;
    HLayout hLayout;
    HLayout buttonLayout;

    vLayout = new VLayout();
    vLayout.setWidth(WINDOW_WIDTH);
    vLayout.setHeight(WINDOW_HEIGHT);
    vLayout.setBorder("2px solid #7598C7");
    vLayout.setMargin(12);
    vLayout.setPadding(14);

    hLayout = new HLayout();
    hLayout.setWidth(WINDOW_WIDTH);

    // HLayout
    // ---------------------------------------------------------------------------------------
    imgVLayout = new VLayout();
    imgVLayout.setWidth(IMG_WIDTH);
    bookPicUrlItem = new Img("/images/upload/" + strBookPicUrl, IMG_WIDTH, IMG_HEIGHT);
    //		bookPicUrlItem = new Img(strBookPicUrl, IMG_WIDTH, IMG_HEIGHT);
    //		bookPicUrlItem.setPrefix("/images/upload/");

    uploadPicButton = new IButton("上传封面");
    uploadPicButton.setIcon("actions/plus.png");
    uploadPicButton.setWidth(IMG_WIDTH);

    imgVLayout.setMembers(bookPicUrlItem, uploadPicButton);
    imgVLayout.setMembersMargin(10);

    // Form
    // 1-----------------------------------------------------------------------------------------

    bookForm1 = new DynamicForm();
    bookForm1.setNumCols(4);
    bookForm1.setWidth("*");
    bookForm1.setColWidths(100, "*", 100, "*");
    bookForm1.setCellPadding(5);

    TextItem bookNameItem = new TextItem("bookName", "书名");
    bookNameItem.setColSpan(4);
    bookNameItem.setWidth("100%");
    bookNameItem.setTitleStyle("alex_bookdisplaywindow_form_text_title");
    bookNameItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content");

    TextItem bookAuthorItem = new TextItem("bookAuthor", "作者");
    bookAuthorItem.setColSpan(4);
    bookAuthorItem.setWidth("100%");
    bookAuthorItem.setTitleStyle("alex_bookdisplaywindow_form_text_title");
    bookAuthorItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content");

    TextItem bookISBNItem = new TextItem("bookISBN", "ISBN");
    bookISBNItem.setColSpan(4);
    bookISBNItem.setWidth("100%");
    bookISBNItem.setTitleStyle("alex_bookdisplaywindow_form_text_title");
    bookISBNItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content");

    bookISBNItem.setShowIcons(true);
    FormItemIcon fetchBookInfoBut = new FormItemIcon();
    fetchBookInfoBut.setSrc("/images/actions/approve.png");
    bookISBNItem.setIcons(fetchBookInfoBut);
    bookISBNItem.addKeyPressHandler(
        new KeyPressHandler() {
          @Override
          public void onKeyPress(KeyPressEvent event) {
            if (event.getKeyName().equals("Enter")) {
              fetchDataFromDouban();
            }
          }
        });
    fetchBookInfoBut.addFormItemClickHandler(
        new FormItemClickHandler() {

          @Override
          public void onFormItemClick(FormItemIconClickEvent event) {
            fetchDataFromDouban();
          }
        });
    bookISBNItem.setIconPrompt("从豆瓣获取书籍信息");

    TextItem bookPublisherItem = new TextItem("bookPublisher", "出版社");
    bookPublisherItem.setTitleStyle("alex_bookdisplaywindow_form_text_title");
    bookPublisherItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content");

    DateItem bookPublishDateItem = new DateItem("bookPublishDate", "出版日期");
    bookPublishDateItem.setTitleStyle("alex_bookdisplaywindow_form_text_title");
    bookPublishDateItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content");
    bookPublishDateItem.setUseTextField(true);
    bookPublishDateItem.setDefaultChooserDate(new Date());

    SelectItem bookClassItem = new SelectItem("bookClass", "类别");
    bookClassItem.setTitleStyle("alex_bookdisplaywindow_form_text_title");
    bookClassItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content");
    bookClassItem.setValueMap(
        "计算机/网络", "小说/文学", "哲学/文化", "经济/管理", "政治/军事", "励志/成长", "儿童/育儿", "心理", "法律", "历史", "其他");
    bookClassItem.setDefaultToFirstOption(true);

    SelectItem bookLanguageItem = new SelectItem("bookLanguage", "语言");
    bookLanguageItem.setTitleStyle("alex_bookdisplaywindow_form_text_title");
    bookLanguageItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content");
    bookLanguageItem.setValueMap("中文", "英语", "法语", "德语", "日语", "俄语", "韩语");
    bookLanguageItem.setDefaultToFirstOption(true);

    TextItem bookContributorItem = new TextItem("bookContributor", "贡献者");
    bookContributorItem.setTitleStyle("alex_bookdisplaywindow_form_text_title");
    bookContributorItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content");

    TextItem bookPriceItem = new TextItem("bookPrice", "价格");
    bookPriceItem.setTitleStyle("alex_bookdisplaywindow_form_text_title");
    bookPriceItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content");

    bookForm1.setFields(
        bookNameItem,
        bookAuthorItem,
        bookISBNItem,
        bookPublisherItem,
        bookPublishDateItem,
        bookClassItem,
        bookLanguageItem,
        bookContributorItem,
        bookPriceItem);

    // Form
    // 2-----------------------------------------------------------------------------------------
    bookForm2 = new DynamicForm();
    bookForm2.setNumCols(3);
    bookForm2.setWidth(WINDOW_WIDTH);
    bookForm2.setColWidths("*", "*", "*");
    bookForm2.setCellPadding(3);
    bookForm2.setCellBorder(1);
    bookForm2.setTitleOrientation(TitleOrientation.TOP);

    StaticTextItem bookTotalQuantityItemTitle = new StaticTextItem("bookTotalQuantityTitle", "");
    bookTotalQuantityItemTitle.setTextBoxStyle("alex_bookdisplaywindow_form_header");
    bookTotalQuantityItemTitle.setShowTitle(false);

    StaticTextItem bookInStoreQuantityitemTitle =
        new StaticTextItem("bookInStoreQuantityTitle", "");
    bookInStoreQuantityitemTitle.setTextBoxStyle("alex_bookdisplaywindow_form_header");
    bookInStoreQuantityitemTitle.setShowTitle(false);

    StaticTextItem bookAvailableQuantityItemTitle =
        new StaticTextItem("bookAvailableQuantityTitle", "");
    bookAvailableQuantityItemTitle.setTextBoxStyle("alex_bookdisplaywindow_form_header");
    bookAvailableQuantityItemTitle.setShowTitle(false);

    TextItem bookTotalQuantityItem = new TextItem("bookTotalQuantity", "");
    bookTotalQuantityItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content");
    bookTotalQuantityItem.setShowTitle(false);

    TextItem bookInStoreQuantityitem = new TextItem("bookInStoreQuantity", "");
    bookInStoreQuantityitem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content");
    bookInStoreQuantityitem.setShowTitle(false);

    TextItem bookAvailableQuantityItem = new TextItem("bookAvailableQuantity", "");
    bookAvailableQuantityItem.setTextBoxStyle("alex_bookdisplaywindow_form_text_content");
    bookAvailableQuantityItem.setShowTitle(false);

    bookForm2.setFields(
        bookTotalQuantityItemTitle,
        bookInStoreQuantityitemTitle,
        bookAvailableQuantityItemTitle,
        bookTotalQuantityItem,
        bookInStoreQuantityitem,
        bookAvailableQuantityItem);

    // Form
    // 3-----------------------------------------------------------------------------------------
    bookForm3 = new DynamicForm();
    bookForm3.setWidth(WINDOW_WIDTH);
    bookForm3.setCellPadding(3);
    // bookForm2.setNumCols(2);
    bookForm3.setTitleOrientation(TitleOrientation.TOP);

    StaticTextItem bookIntroItemTitle = new StaticTextItem("bookIntroTitle", "");
    bookIntroItemTitle.setTextBoxStyle("alex_bookdisplaywindow_form_text_title");
    bookIntroItemTitle.setShowTitle(false);

    TextAreaItem bookIntroItem = new TextAreaItem("bookIntro", "");
    bookIntroItem.setTextBoxStyle("alex_bookdisplaywindow_form_intro_content");
    bookIntroItem.setShowTitle(false);
    bookIntroItem.setColSpan(2);
    bookIntroItem.setWidth("100%");

    bookForm3.setFields(bookIntroItemTitle, bookIntroItem);

    // buttonLayout
    // --------------------------------------------------------------------------------------
    buttonLayout = new HLayout();
    newButton = new IButton("添加图书");
    newButton.setIcon("actions/approve.png");
    buttonLayout.setMembers(newButton);
    buttonLayout.setAlign(Alignment.RIGHT);

    hLayout.setMembers(imgVLayout, bookForm1);
    vLayout.setMembers(hLayout, bookForm2, bookForm3, buttonLayout);
    vLayout.setMembersMargin(20);

    bookForm1.setValue("bookPublishDate", new Date());
    bookForm1.setValue("bookClass", "计算机/网络");
    bookForm1.setValue("bookLanguage", "中文");
    bookForm1.setValue("bookPrice", "0.00");
    bookForm1.setValue("bookContributor", "公司采购");

    bookForm2.setValue("bookTotalQuantity", "1");
    bookForm2.setValue("bookInStoreQuantity", "1");
    bookForm2.setValue("bookAvailableQuantity", "1");

    bookForm2.setValue("bookTotalQuantityTitle", "总数");
    bookForm2.setValue("bookInStoreQuantityTitle", "库中数量");
    bookForm2.setValue("bookAvailableQuantityTitle", "可借数量");
    bookForm3.setValue("bookIntroTitle", "简介:");

    this.addItem(vLayout);

    bind();
  }