Пример #1
0
        private void OnFormLoad(object sender, System.EventArgs e)
        {
            //Initialize controls - set default values
            this.Cursor = Cursors.WaitCursor;
            try {
                //Set initial service states
                this.Visible = true;
                Application.DoEvents();

                //Get selection lists
                this.mPaymentServicesDS.Merge(EnterpriseFactory.GetAvailablePaymentServices(this.mEntityID));

                //Set control services
                if (this.mPaymentServiceID == 0)
                {
                    //User selects vendor for a new association
                    if (this.mAssociationDS.CompanyPaymentServiceTable[0].PaymentServiceID == 0)
                    {
                        if (this.cboPaymentServices.Items.Count > 0)
                        {
                            this.cboPaymentServices.SelectedIndex = 0;
                        }
                    }
                    else
                    {
                        this.cboPaymentServices.SelectedValue = this.mAssociationDS.CompanyPaymentServiceTable[0].PaymentServiceID;
                    }
                    this.cboPaymentServices.Enabled = (this.cboPaymentServices.Items.Count > 0);
                }
                else
                {
                    //Vendor cannot be changed on association updates
                    this.mPaymentServicesDS.Clear();
                    this.mPaymentServicesDS.SelectionListTable.AddSelectionListTableRow(this.mAssociationDS.CompanyPaymentServiceTable[0].PaymentServiceID.ToString(), "Payment Service");
                    this.cboPaymentServices.Enabled = false;
                }
                this.txtComments.MaxLength = 30;
                if (!this.mAssociationDS.CompanyPaymentServiceTable[0].IsCommentsNull())
                {
                    this.txtComments.Text = this.mAssociationDS.CompanyPaymentServiceTable[0].Comments;
                }

                this.chkStatus.Checked = this.mAssociationDS.CompanyPaymentServiceTable[0].IsActive;
                if (!mParentIsActive)
                {
                    //If parent is inactive: 1. Status MUST be inactive for new
                    //					     2. Status cannot be changed for new or existing
                    if (this.mPaymentServiceID == 0)
                    {
                        this.chkStatus.Checked = false;
                    }
                    this.chkStatus.Enabled = false;
                }
            }
            catch (Exception ex) { reportError(ex); }
            finally { this.btnOk.Enabled = false; this.Cursor = Cursors.Default; }
        }