Subversion Repositories SmartDukaan

Rev

Rev 2427 | Rev 12435 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2427 Rev 6759
Line 28... Line 28...
28
 
28
 
29
    /**
29
    /**
30
     * Listener for update button click.
30
     * Listener for update button click.
31
     */
31
     */
32
    public interface VendorPriceUpdateListener{
32
    public interface VendorPriceUpdateListener{
33
        boolean onUpdate(double mop, double dp, double tp, long vendorId);
33
        boolean onUpdate(double mop, double dp, double tp, double nlc, long vendorId);
34
    }
34
    }
35
 
35
 
36
    private VendorPriceUpdateListener vendorPriceUpdateListener;
36
    private VendorPriceUpdateListener vendorPriceUpdateListener;
37
 
37
 
38
    @UiField Button closeButton, updateButton;
38
    @UiField Button closeButton, updateButton;
39
    @UiField TextBox mop, dealerPrice, transferPrice;
39
    @UiField TextBox mop, dealerPrice, transferPrice, nlc;
40
    @UiField ListBox vendor;
40
    @UiField ListBox vendor;
41
 
41
 
42
    public VendorPricesDialog() {
42
    public VendorPricesDialog() {
43
        setText("Vendor Prices");
43
        setText("Vendor Prices");
44
        setWidget(binder.createAndBindUi(this));
44
        setWidget(binder.createAndBindUi(this));
Line 47... Line 47...
47
        for(Entry<Long, String> e : Utils.getAllVendors().entrySet()){
47
        for(Entry<Long, String> e : Utils.getAllVendors().entrySet()){
48
            vendor.addItem(e.getValue());
48
            vendor.addItem(e.getValue());
49
        }
49
        }
50
    }
50
    }
51
 
51
 
52
    public VendorPricesDialog(String mop, String dp, String tp) {
52
    public VendorPricesDialog(String mop, String dp, String tp, String nlc) {
53
        this();
53
        this();
54
        setPrices(mop, dp, tp);
54
        setPrices(mop, dp, tp, nlc);
55
    }
55
    }
56
 
56
 
57
    public void setPrices(String mop, String dp, String tp) {
57
    public void setPrices(String mop, String dp, String tp, String nlc) {
58
        this.mop.setText(mop);
58
        this.mop.setText(mop);
59
        this.dealerPrice.setText(dp);
59
        this.dealerPrice.setText(dp);
60
        this.transferPrice.setText(tp);
60
        this.transferPrice.setText(tp);
-
 
61
        this.nlc.setText(nlc);
61
        this.vendor.setEnabled(false);
62
        this.vendor.setEnabled(false);
62
    }
63
    }
63
 
64
 
64
    /**
65
    /**
65
     * listener for click on update button is set in ItemDetails and ItemForm
66
     * listener for click on update button is set in ItemDetails and ItemForm
Line 74... Line 75...
74
        hide();
75
        hide();
75
    }
76
    }
76
 
77
 
77
    @UiHandler("updateButton")
78
    @UiHandler("updateButton")
78
    void onEditClicked(ClickEvent event) {
79
    void onEditClicked(ClickEvent event) {
79
        double mop, dp, tp;
80
        double mop, dp, tp, nlc;
80
        try {
81
        try {
81
            mop = Double.parseDouble(this.mop.getText());
82
            mop = Double.parseDouble(this.mop.getText());
82
            dp = Double.parseDouble(this.dealerPrice.getText());
83
            dp = Double.parseDouble(this.dealerPrice.getText());
83
            tp = Double.parseDouble(this.transferPrice.getText());
84
            tp = Double.parseDouble(this.transferPrice.getText());
-
 
85
            nlc = Double.parseDouble(this.nlc.getText());
84
        } catch(NumberFormatException ex) {
86
        } catch(NumberFormatException ex) {
85
            Window.alert("Price format is not valid.");
87
            Window.alert("Price format is not valid.");
86
            return;
88
            return;
87
        }
89
        }
88
        long vendorId = Utils.getVendorId(this.vendor.getItemText(this.vendor.getSelectedIndex()));
90
        long vendorId = Utils.getVendorId(this.vendor.getItemText(this.vendor.getSelectedIndex()));
89
        if(vendorPriceUpdateListener.onUpdate(mop, dp, tp, vendorId)) {
91
        if(vendorPriceUpdateListener.onUpdate(mop, dp, tp, nlc, vendorId)) {
90
            hide();
92
            hide();
91
        }
93
        }
92
    }
94
    }
93
}
95
}