dojo.provide("parus.designerIndexGroupPartDialog");

dojo.require("dijit.Dialog");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.ValidationTextBox");
dojo.require("dijit.form.SimpleTextarea");

dojo.require("parus.parus8");
dojo.require("parus.dialog");
dojo.require("parus.dictEdit");
dojo.require("parus.formats");

dojo.require("parus.editDictionaryDialog");
dojo.require("parus.designerIndexInputPatternDialog");

dojo.declare("parus.designerIndexGroupPartDialog", [parus.editDictionaryDialog], {

  onLoadParams: function(store, item, editMode) {
    this.inherited(arguments);

    if (store && item) {
      this.indexEdit.attr("value", store.getValue(item, "BALANCEINDEX"));
    }
  },

  executeInsert: function() {
    var response = parus.database.execute("designer.BalanceIndexes.GroupsParts.Insert", {
      PRN: this.prn,
      BALANCEINDEX: this.indexEdit.attr("value")
    });

    if (response) return parus.parus8.nodeField(parus.parus8.rowNodes(response)[0], "NRN");
  },

  executeUpdate: function() {
    var response = parus.database.execute("designer.BalanceIndexes.GroupsParts.Update", {
      RN: this.rn,
      BALANCEINDEX: this.indexEdit.attr("value")
    });

    return !!response;
  },

  executeDelete: function(store, item) {
    var response = parus.database.execute("designer.BalanceIndexes.GroupsParts.Delete", {
      RN: store.getValue(item, "RN")
    });

    return !!response;
  },

  //static
  executeInsertList: function(prn, selectedList) {
    var response = parus.database.execute("designer.BalanceIndexes.GroupsParts.InsertList", {
      PRN: prn,
      RN: selectedList
    });

    return response;
  }

});