コード例 #1
0
 private void ShowFormSetting_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.F3)
     {
         ShowButton.PerformClick();
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: katevaschris/University
        //______________________________________________________
        private void RemoveButton_Click(object sender, EventArgs e)
        {
            //Remove all contacts
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete all your contacts?", "Remove everything?", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                connection.Open();
                string       comand = "DELETE FROM Table1";
                OleDbCommand cmd    = new OleDbCommand(comand, connection);
                cmd.ExecuteNonQuery();
                connection.Close();
                ClearAllTextBoxes();
                ShowButton.PerformClick();
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: katevaschris/University
        //______________________________________________________
        void add()
        {
            //add to database the followinds based on the key
            connection.Open();
            String query = "Insert into Table1(FName,LName,Phone,EMail,Address,City,ZCode,BDay,Photo,Music) " +
                           "values ('" + FNameTextBox.Text + "','" + LNameTextBox.Text + "'," +
                           "'" + Convert.ToInt32(PhoneTextBox.Text) + "', '" + EMailTextBox.Text + "'," +
                           "'" + AddressTextBox.Text + "','" + CityTextBox.Text + "'," +
                           "'" + Convert.ToInt32(ZCodeTextBox.Text) + "'," +
                           "'" + BDay.Value.ToString() + "', '" + photo + "', '" + music + "' )";

            OleDbCommand command = new OleDbCommand(query, connection);
            int          count   = command.ExecuteNonQuery();

            connection.Close();
            MessageBox.Show(count.ToString() + " Contact added successfully!");
            ShowButton.PerformClick();
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: katevaschris/University
 //______________________________________________________
 private void SaveButton_Click(object sender, EventArgs e)
 {
     //Check if requested values are properly seted and procced to add();
     if (FNameTextBox.Text != "")
     {
         if (LNameTextBox.Text != "")
         {
             if (NumberOnly(PhoneTextBox.Text))
             {
                 if (!Existance())
                 {
                     if (CheckEMail(EMailTextBox.Text))
                     {
                         if (NumberOnly(ZCodeTextBox.Text))
                         {
                             add();
                             ShowButton.PerformClick();
                         }
                         else
                         {
                             MessageBox.Show("Provide a valid Zip Code!");
                         }
                     }
                     else
                     {
                         MessageBox.Show("Please provide a valid E-Mail address!");
                     }
                 }
             }
             else
             {
                 MessageBox.Show("Please provide a valid phone number");
             }
         }
         else
         {
             MessageBox.Show("Please provide a Last Name!");
         }
     }
     else
     {
         MessageBox.Show("Please provide a First Name!");
     }
 }