dojo.provide("parus.designerIndexDialog");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.designerIndexDialog",[parus.editDictionaryDialog],{onLoadParams:function(c,b,a){this.inherited(arguments);if(c&&b){this.codeEdit.attr("value",c.getValue(b,"CODE"));this.nameEdit.attr("value",c.getValue(b,"NAME"));this.dataTypeSelect.attr("value",c.getValue(b,"BITYPE"));if(c.getValue(b,"BITYPE")=="0"){this.strLenEdit.attr("value",c.getValue(b,"STRLEN"));this.begStrValueEdit.attr("value",c.getValue(b,"BEGSTRVAL"));this.patternEdit.attr("value",c.getValue(b,"PATTERN_CODE"));this.trimStrCheckBox.attr("checked",c.getValue(b,"TRIMSTRVAL")=="1")}else{if(c.getValue(b,"BITYPE")=="1"){this.intPartEdit.attr("value",c.getValue(b,"INTPART"));this.fracPartEdit.attr("value",c.getValue(b,"FRACPART"));this.begNumValueEdit.attr("value",c.getValue(b,"BEGNUMVAL"));this.minNumValueEdit.attr("value",c.getValue(b,"MINNUMVAL"));this.maxNumValueEdit.attr("value",c.getValue(b,"MAXNUMVAL"))}else{if(c.getValue(b,"BITYPE")=="2"){this.begDateValueEdit.attr("value",parus.formats.stringToDate(c.getValue(b,"BEGDATEVAL")));this.minDateValueEdit.attr("value",parus.formats.stringToDate(c.getValue(b,"MINDATEVAL")));this.maxDateValueEdit.attr("value",parus.formats.stringToDate(c.getValue(b,"MAXDATEVAL")))}}}}this.dataTypeChanged()},dataTypeChanged:function(){var a=this.dataTypeSelect.attr("value");this.checkValuePane(this.strValuePane,a=="0");this.checkValuePane(this.numValuePane,a=="1");this.checkValuePane(this.dateValuePane,a=="2")},checkValuePane:function(b,a){b.domNode.style.display=a?"":"none";dojo.forEach(b.getChildren(),function(c){c.attr("disabled",!a)})},strLenChanged:function(){var a=parseInt(this.strLenEdit.attr("value"));if(a){this.begStrValueEdit.maxLength=a}},intPartChanged:function(){if(!isNaN(this.intPartEdit.attr("value"))){var a=parseInt(this.intPartEdit.attr("value"));var c=a-1;if(!isNaN(this.fracPartEdit.attr("value"))){var b=parseInt(this.fracPartEdit.attr("value"));if(b>c){this.fracPartEdit.attr("value",c)}}this.setControlsMaxNumber()}},fracPartChanged:function(){var a=parseInt(this.fracPartEdit.attr("value"));this.begNumValueEdit.constraints.fractional=!isNaN(a)&&(a>0);this.minNumValueEdit.constraints.fractional=!isNaN(a)&&(a>0);this.maxNumValueEdit.constraints.fractional=!isNaN(a)&&(a>0);if(!isNaN(a)){this.begNumValueEdit.constraints.places=a;this.minNumValueEdit.constraints.places=a;this.maxNumValueEdit.constraints.places=a;this.setControlsMaxNumber()}},setControlsMaxNumber:function(){var a=this.getMaxNumber();this.begNumValueEdit.constraints.max=a;this.minNumValueEdit.constraints.max=a;this.maxNumValueEdit.constraints.max=a},getMaxNumber:function(){var a=parseInt(this.intPartEdit.attr("value"));if(!isNaN(a)){var d=parseInt(this.fracPartEdit.attr("value"));if(!isNaN(d)){a-=d}var c=parus.formats.stringOfChar("9",a);if(!isNaN(d)){var b=parus.formats.stringOfChar("9",d);return parseFloat(c+"."+b)}else{return parseInt(c)}}},getExecParams:function(){var b=this.dataTypeSelect.attr("value");var a={CODE:this.codeEdit.attr("value"),NAME:this.nameEdit.attr("value"),BITYPE:this.dataTypeSelect.attr("value")};if(b=="0"){dojo.mixin(a,{STRLEN:this.strLenEdit.attr("value"),BEGSTRVAL:this.begStrValueEdit.attr("value"),PATTERN:this.patternEdit.attr("value"),TRIMSTRVAL:(this.trimStrCheckBox.attr("checked")?"1":"0")})}if(b=="1"){dojo.mixin(a,{INTPART:this.intPartEdit.attr("value"),FRACPART:this.fracPartEdit.attr("value"),BEGNUMVAL:!isNaN(this.begNumValueEdit.attr("value"))?this.begNumValueEdit.attr("value"):null,MINNUMVAL:!isNaN(this.minNumValueEdit.attr("value"))?this.minNumValueEdit.attr("value"):null,MAXNUMVAL:!isNaN(this.maxNumValueEdit.attr("value"))?this.maxNumValueEdit.attr("value"):null,TRIMSTRVAL:(this.trimStrCheckBox.attr("checked")?"1":"0")})}if(b=="2"){dojo.mixin(a,{BEGDATEVAL:parus.formats.dateToString(this.begDateValueEdit.attr("value")),MINDATEVAL:parus.formats.dateToString(this.minDateValueEdit.attr("value")),MAXDATEVAL:parus.formats.dateToString(this.maxDateValueEdit.attr("value")),TRIMSTRVAL:(this.trimStrCheckBox.attr("checked")?"1":"0")})}return a},executeInsert:function(){var a=parus.database.execute("designer.BalanceIndexes.Insert",dojo.mixin(this.getExecParams(),{CRN:this.crn}));if(a){return parus.parus8.nodeField(parus.parus8.rowNodes(a)[0],"NRN")}},executeUpdate:function(){var a=parus.database.execute("designer.BalanceIndexes.Update",dojo.mixin(this.getExecParams(),{RN:this.rn}));return !!a},executeDelete:function(c,b){var a=parus.database.execute("designer.BalanceIndexes.Delete",{RN:c.getValue(b,"RN")});return !!a}});