コード例 #1
0
        private void OnFormLoad(object sender, System.EventArgs e)
        {
            //Initialize controls - set default values
            this.Cursor = Cursors.WaitCursor;
            try {
                //Show early
                this.Visible = true;
                Application.DoEvents();

                //Get selection lists
                this.mScaleTypesDS.Merge(EnterpriseFactory.GetWorkstationScaleTypes());
                this.mPrinterTypesDS.Merge(EnterpriseFactory.GetWorkstationPrinterTypes());
                this.mScalePortsDS.Merge(EnterpriseFactory.GetWorkstationPorts());
                this.mPrinterPortsDS.Merge(EnterpriseFactory.GetWorkstationPorts());

                //Set control services
                this.txtName.MaxLength   = 20;
                this.txtName.Text        = this.mWorkstationDS.TerminalWorkstationTable[0].Name.Trim();
                this.txtNumber.MaxLength = 10;
                this.txtNumber.Text      = "";
                if (!this.mWorkstationDS.TerminalWorkstationTable[0].IsNumberNull())
                {
                    this.txtNumber.Text = this.mWorkstationDS.TerminalWorkstationTable[0].Number.Trim();
                }
                this.txtLocationDescription.MaxLength = 40;
                this.txtLocationDescription.Text      = "";
                if (!this.mWorkstationDS.TerminalWorkstationTable[0].IsDescriptionNull())
                {
                    this.txtLocationDescription.Text = this.mWorkstationDS.TerminalWorkstationTable[0].Description.Trim();
                }
                if (!this.mWorkstationDS.TerminalWorkstationTable[0].IsScaleTypeNull())
                {
                    this.cboScaleTypes.SelectedValue = this.mWorkstationDS.TerminalWorkstationTable[0].ScaleType;
                }
                else
                if (this.cboScaleTypes.Items.Count > 0)
                {
                    this.cboScaleTypes.SelectedIndex = 0;
                }
                this.cboScaleTypes.Enabled = (this.cboScaleTypes.Items.Count > 0);
                if (!this.mWorkstationDS.TerminalWorkstationTable[0].IsScalePortNull())
                {
                    this.cboScalePort.SelectedValue = this.mWorkstationDS.TerminalWorkstationTable[0].ScalePort;
                }
                else
                if (this.cboScalePort.Items.Count > 0)
                {
                    this.cboScalePort.SelectedIndex = 0;
                }
                this.cboScalePort.Enabled = (this.cboScalePort.Items.Count > 0);
                if (!this.mWorkstationDS.TerminalWorkstationTable[0].IsPrinterTypeNull())
                {
                    this.cboPrinterTypes.SelectedValue = this.mWorkstationDS.TerminalWorkstationTable[0].PrinterType;
                }
                else
                if (this.cboPrinterTypes.Items.Count > 0)
                {
                    this.cboPrinterTypes.SelectedIndex = 0;
                }
                this.cboPrinterTypes.Enabled = (this.cboPrinterTypes.Items.Count > 0);
                if (!this.mWorkstationDS.TerminalWorkstationTable[0].IsPrinterPortNull())
                {
                    this.cboPrinterPort.SelectedValue = this.mWorkstationDS.TerminalWorkstationTable[0].PrinterPort;
                }
                else
                if (this.cboPrinterPort.Items.Count > 0)
                {
                    this.cboPrinterPort.SelectedIndex = 0;
                }
                this.cboPrinterPort.Enabled = (this.cboPrinterPort.Items.Count > 0);
                this.chkTrace.Checked       = this.mWorkstationDS.TerminalWorkstationTable[0].IsTraceNull() ? false : this.mWorkstationDS.TerminalWorkstationTable[0].Trace;
            }
            catch (Exception ex) { reportError(ex); }
            finally { this.btnOk.Enabled = false; this.Cursor = Cursors.Default; }
        }