Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //button_add_pay.DialogResult = DialogResult.No;
            MoneyForms moneyForms = new MoneyForms();

            moneyForms.ShowDialog();
            DisplayData();
        }
Ejemplo n.º 2
0
        private void button_reg_Click(object sender, EventArgs e)
        {
            if (CheckUsers())
            {
                return;
            }

            DB db = new DB();

            try
            {
                SqlCommand command = new SqlCommand("INSERT INTO Users ( UsersName, UsersPhone, UsersLogin, UsersPass ) VALUES (@Name, @Phone, @Login, @Pass)", db.GetConnection());
                if (NameFild.Text != "Введите имя")
                {
                    command.Parameters.Add("@Name", SqlDbType.NVarChar).Value = NameFild.Text;
                }
                else
                {
                    MessageBox.Show("Некоректно введено имя");
                    return;
                }
                if (PhoneFild.Text != "Введите телефон")
                {
                    command.Parameters.Add("@Phone", SqlDbType.NVarChar).Value = PhoneFild.Text;
                }
                else
                {
                    MessageBox.Show("Некоректно введен телефон");
                    return;
                }
                if (LogFild.Text != "")
                {
                    command.Parameters.Add("@Login", SqlDbType.NVarChar).Value = LogFild.Text;
                }
                else
                {
                    MessageBox.Show("Некоректно введена почта");
                    return;
                }
                if (PassFild.Text == PassFild1.Text)
                {
                    command.Parameters.Add("@Pass", SqlDbType.NVarChar).Value = PassFild.Text;
                }
                else
                {
                    MessageBox.Show("Введены разные пароли");
                    return;
                }

                db.OpenConection();

                if (command.ExecuteNonQuery() == 1)
                {
                    //MessageBox.Show("вы успешно зарегестрированы");
                    //this.Hide();
                    MoneyForms moneyForms = new MoneyForms();
                    moneyForms.ShowDialog();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("вы не зарегестрированы");
                }

                db.CloseConection();
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.ToString());
                this.Close();
            }
        }