Beispiel #1
0
        /********************************* General Form Events *****************************/
        public void ClientOptions(bool isShown)
        {
            if (isShown)
            {
                linkableClientBox.Visible = true;
                DataTable clients = MClient.GetList();

                DataTable dt = new DataTable();
                dt = clients.Clone();
                dt.Rows.Add(new String[] { null, "<Select Client>" });
                foreach (DataRow r in clients.Rows)
                {
                    dt.ImportRow(r);
                }

                linkableClientBox.DataSource    = dt;
                linkableClientBox.DisplayMember = dt.Columns[1].ToString();
                linkableClientBox.ValueMember   = dt.Columns[0].ToString();
                new_Client_Button.Visible       = true;
            }
            else
            {
                linkableClientBox.Visible = false;
                new_Client_Button.Visible = false;
            }
        }
Beispiel #2
0
        public AddEditClientForm(MaintainClientController parent, bool edit, int id)
        {
            InitializeComponent();
            my_controller = parent;
            isEdit        = edit;
            userid        = id;
            noChanges     = true;

            #region Form Event Handlers

            /* this.Back_Button.Click += new System.EventHandler(my_controller.Client_Cancel_Button_Click);
             * this.Back_Button.MouseEnter += new EventHandler(button1_MouseEnter);
             * this.Back_Button.MouseLeave += new EventHandler(button1_MouseLeave);
             * this.Back_Button.Location = new Point(65, 38);
             * this.Back_Button.BackgroundImage = ((System.Drawing.Image)(Properties.Resources.Back2));
             * Back_Button.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent;
             * Back_Button.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent;
             */
            // this.contract_Button.Click += new EventHandler(my_controller.Client_Contract_Button_Click);
            this.Ok_Button.Click += new System.EventHandler(my_controller.Client_Ok_Button_Click);
            // this.Cancel_Button.Click += new System.EventHandler(my_controller.Client_Cancel_Button_Click);
            this.delete_Button.Click               += new EventHandler(my_controller.Client_Delete_Button_Click);
            this.CountryBox.SelectedValueChanged   += new System.EventHandler(my_controller.Country_Changed);
            this.ProvStateBox.SelectedValueChanged += new EventHandler(my_controller.Province_Changed);
            this.CityBox.SelectedValueChanged      += new EventHandler(my_controller.City_Changed);

            this.nameTxtBox.TextChanged         += new EventHandler(my_controller.Client_Text_Changed);
            this.typeTextBox.TextChanged        += new EventHandler(my_controller.Client_Text_Changed);
            this.addrTextBox.TextChanged        += new EventHandler(my_controller.Client_Text_Changed);
            this.postalCodeTextBox.TextChanged  += new EventHandler(my_controller.Client_Text_Changed);
            this.PoBoxTextBox.TextChanged       += new EventHandler(my_controller.Client_Text_Changed);
            this.EmailTextBox.TextChanged       += new EventHandler(my_controller.Client_Text_Changed);
            this.mainPhoneTxtBox.TextChanged    += new EventHandler(my_controller.Client_Text_Changed);
            this.SecondPhoneTextBox.TextChanged += new EventHandler(my_controller.Client_Text_Changed);
            this.FaxTextBox.TextChanged         += new EventHandler(my_controller.Client_Text_Changed);
            this.PrimContactTextBox.TextChanged += new EventHandler(my_controller.Client_Text_Changed);
            #endregion

            if (isEdit)
            {
                #region Create and set a combo selection box
                DataTable clients = MClient.GetList();
                nameComboBox          = new ComboBox();
                nameComboBox.Location = new Point(300, 31);
                nameComboBox.Font     = new Font(nameComboBox.Font.FontFamily, 10);
                nameComboBox.Size     = new Size(195, 28);

                DataTable dt = new DataTable();
                dt = clients.Clone();
                dt.Rows.Add(new String[] { null, "<Select Client>" });
                foreach (DataRow r in clients.Rows)
                {
                    dt.ImportRow(r);
                }

                nameComboBox.DataSource    = dt;
                nameComboBox.DisplayMember = dt.Columns[1].ToString();
                nameComboBox.ValueMember   = dt.Columns[0].ToString();

                nameComboBox.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
                nameComboBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
                for (int i = 0; i < clients.Rows.Count; i++)
                {
                    nameComboBox.AutoCompleteCustomSource.Add(clients.Rows[i][1].ToString());
                }

                nameComboBox.TextChanged          += new EventHandler(my_controller.Client_Text_Changed);
                nameComboBox.SelectedValueChanged += new EventHandler(my_controller.Edit_Client_Populate);
                this.Controls.Add(nameComboBox);

                Label nameSelection = new Label();
                nameSelection.Text     = "Select Client:";
                nameSelection.Font     = new Font(nameComboBox.Font.FontFamily, 10);
                nameSelection.Location = new Point(490, 166);
                this.Controls.Add(nameSelection);
                #endregion
            }

            here : try { SetCountryBox(MCountry.GetList(), "0"); }
            catch (Exception)
            {
                if (MessageBox.Show("Error connecting to Database\nDo you want to retry?", "Connection Problems", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    goto here;
                }
            }

            //User label
            user   = new Users();
            userid = id;
            setup(userid.ToString(), "FAFOS Client Form");
        }