예제 #1
0
 private void TexClear()
 {
     TxtNumber.Clear();
     TxtUsername.Clear();
     txtEmail.Clear();
     txtNoPhone.Clear();
     txtPassword.Clear();
 }
예제 #2
0
 /// <summary>Clears all TextBoxes.</summary>
 private void Clear()
 {
     TxtNumber.Clear();
     TxtName.Clear();
     TxtHours.Clear();
 }
예제 #3
0
        //button register
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            //MessageBox.Show(rezult);

            if (TxtFirstname.Text == "")
            {
                MessageBox.Show("Please enter confirm password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtFirstname.Focus();
                return;
            }
            if (TxtFamilyname.Text == "")
            {
                MessageBox.Show("Please enter username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtFamilyname.Focus();
                return;
            }

            if (TxtData.Text == "")
            {
                MessageBox.Show("Please enter username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtData.Focus();
                return;
            }
            if (TxtNumber.Text == "")
            {
                MessageBox.Show("Please enter username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TxtNumber.Focus();
                return;
            }
            try
            {
                SqlConnection myConnection = default(SqlConnection);
                myConnection = new SqlConnection(@"Data Source=DESKTOP-NP1RDM2\BAZALUIMARIAN;Initial Catalog=task;Persist Security Info=True;User ID=sa; Password = 0299");
                String query = "INSERT INTO dbo.Clientapp (family_name,first_name,clientappdate,number) VALUES (@family_name,@first_name,@clientappdate,@number)";

                using (SqlCommand command = new SqlCommand(query, con))
                {
                    command.Parameters.AddWithValue("@family_name", TxtFamilyname.Text);
                    command.Parameters.AddWithValue("@first_name", TxtFirstname.Text);
                    command.Parameters.AddWithValue("@clientappdate", TxtData.Text);
                    command.Parameters.AddWithValue("@number", TxtNumber.Text);

                    MessageBox.Show("Register successfully !We will call you back today !", "Register Successfully", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    con.Open();
                    int result = command.ExecuteNonQuery();
                    Hide();

                    // Check Error
                    if (result < 0)
                    {
                        MessageBox.Show("Register Denied", "Register Denied", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        TxtNumber.Clear();
                        TxtFirstname.Clear();
                        TxtFamilyname.Clear();
                        TxtData.Clear();
                        TxtFamilyname.Focus();
                        Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }