Exemple #1
0
        void OnButtonRemoveSelfClick(object sender, EventArgs e)
        {
            var tableLayout = Parent as TableLayout;

            Debug.Assert(tableLayout != null, "tableLayout != null");

            var tableLayoutRows = tableLayout.Rows;

            if (tableLayoutRows.Count == 2)
            {
                Clear();
                TextBoxAddress.Focus();
                return;
            }

            for (var i = tableLayoutRows.Count - 2; i >= 0; i--)
            {
                if (tableLayoutRows[i].Cells[0].Control == this)
                {
                    tableLayout.Remove(this);
                    tableLayoutRows.RemoveAt(i);
                    return;
                }
            }
        }
Exemple #2
0
        private void metroTileEnter_Click(object sender, EventArgs e)
        {
            SimsOracle db   = new SimsOracle();
            int        rows = 0;

            if (TextBoxName.Text == "")
            {
                MessageBox.Show("You should enter centre name");
                TextBoxName.Focus();
            }
            else if (TextBoxAddress.Text == "")
            {
                MessageBox.Show("You should enter centre address");
                TextBoxAddress.Focus();
            }
            else if (TextBoxClasses.Text == "")
            {
                MessageBox.Show("You should enter number of classes");
                TextBoxClasses.Focus();
            }
            else if (!checkValue.isValidInteger(TextBoxClasses.Text))
            {
                MessageBox.Show("The number format is not valid");
                TextBoxClasses.Focus();
            }
            else
            {
                try
                {
                    string sql = "INSERT INTO CENTRE " +
                                 "(NAME, ADDRESS, CLASSES) " +
                                 " VALUES " +
                                 "(:NAME, :ADDRESS, :CLASSES)";
                    OracleCommand cmd = new OracleCommand(sql, db.Connection);
                    cmd.Parameters.Add("NAME", TextBoxName.Text);
                    cmd.Parameters.Add("ADDRESS", TextBoxAddress.Text);
                    cmd.Parameters.Add("CLASSES", TextBoxClasses.Text);

                    rows = cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error adding a centre:\n" + ex.Message.ToString());
                }
                if (rows > 0)
                {
                    MessageBox.Show("Centre added successfully");
                    ClearControls();
                }
                else
                {
                    MessageBox.Show("Centre was not added, there might have been unexpected error");
                }
            }
        }
Exemple #3
0
        private void ButtonOK_Click(object sender, System.EventArgs e)
        {
            TextBoxName.Text    = TextBoxName.Text.Trim();
            TextBoxAddress.Text = TextBoxAddress.Text.Trim();
            if (TextBoxAddress.Text.Length == 0)
            {
                MessageBox.Show(this, "Please input a valid email address!");
                TextBoxAddress.Focus();
                return;
            }

            ButtonOK.DialogResult = DialogResult.OK;
            this.DialogResult     = DialogResult.OK;
            this.Close();
        }
Exemple #4
0
        private bool IsValidData()
        {
            if (ButtonRegister.Text == "Update")
            {
                if (string.IsNullOrEmpty(TextBoxSupId.Text))
                {
                    Globals.MessageBoxShow(this, "Please Choose a Customer to Edit");
                    TextBoxSupId.Focus();
                    return(false);
                }
            }

            if (string.IsNullOrEmpty(TextBoxSupName.Text))
            {
                Globals.MessageBoxShow(this, "Please Enter Customer Name");
                TextBoxSupName.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(TextBoxZipCode.Text))
            {
                Globals.MessageBoxShow(this, "Please Enter Zip Code");
                TextBoxZipCode.Focus();
                return(false);
            }
            else
            {
                string zipCodePattern = @"[0-9]{6}";
                bool   isZipValid     = true;
                isZipValid = Regex.IsMatch(TextBoxZipCode.Text, zipCodePattern);
                if (!isZipValid)
                {
                    Globals.MessageBoxShow(this, "Please Enter Valid Zip Code");
                    TextBoxZipCode.Focus();
                    return(false);
                }
            }
            if (string.IsNullOrEmpty(TextBoxSupPhno.Text))
            {
                Globals.MessageBoxShow(this, "Please Enter Phone Number");
                TextBoxSupPhno.Focus();
                return(false);
            }
            else
            {
                string phnoPattern = @"[0-9]{10}";
                bool   isphnoValid = true;
                isphnoValid = Regex.IsMatch(TextBoxSupPhno.Text, phnoPattern);
                if (!isphnoValid)
                {
                    Globals.MessageBoxShow(this, "Please Enter Valid Phone Number");
                    TextBoxSupPhno.Focus();
                    return(false);
                }
            }
            if (string.IsNullOrEmpty(TextBoxEmail.Text))
            {
                Globals.MessageBoxShow(this, "Please Enter Email");
                TextBoxEmail.Focus();
                return(false);
            }
            else
            {
                string emailPattern = @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
                bool   isemailValid = true;
                isemailValid = Regex.IsMatch(TextBoxEmail.Text, emailPattern);
                if (!isemailValid)
                {
                    Globals.MessageBoxShow(this, "Please Enter Valid Email");
                    TextBoxEmail.Focus();
                    return(false);
                }
            }
            if (string.IsNullOrEmpty(TextBoxGSTNo.Text))
            {
                Globals.MessageBoxShow(this, "Please Enter GST No");
                TextBoxGSTNo.Focus();
                return(false);
            }
            else
            {
                string gstPattern = @"^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$";
                bool   isgstValid = true;
                isgstValid = Regex.IsMatch(TextBoxGSTNo.Text, gstPattern);
                if (!isgstValid)
                {
                    Globals.MessageBoxShow(this, "Please Enter Valid GST No");
                    TextBoxGSTNo.Focus();
                    return(false);
                }
            }
            if (string.IsNullOrEmpty(TextBoxState.Text))
            {
                Globals.MessageBoxShow(this, "Please Enter State");
                TextBoxState.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(TextBoxCity.Text))
            {
                Globals.MessageBoxShow(this, "Please Enter City");
                TextBoxCity.Focus();
                return(false);
            }
            if (string.IsNullOrEmpty(TextBoxAddress.Text))
            {
                Globals.MessageBoxShow(this, "Please Enter Address");
                TextBoxAddress.Focus();
                return(false);
            }
            if (DropDownListCountry.SelectedItem.Text == "Select Country")
            {
                Globals.MessageBoxShow(this, "Please Select Country");
                DropDownListCountry.Focus();
                return(false);
            }
            if (DropDownListGender.SelectedItem.Text == "Gender")
            {
                Globals.MessageBoxShow(this, "Please Select Gender");
                DropDownListGender.Focus();
                return(false);
            }
            return(true);
        }