private void ClearForm() { TitleTextBox.Clear(); FileNameTextBox.Clear(); AuthorTextBox.Clear(); AlbumTextBox.Clear(); }
private void Clear() { TitleTextBox.ResetText(); AuthorTextBox.ResetText(); Author2TextBox.ResetText(); Author3TextBox.ResetText(); tKodK.ResetText(); }
private void SaveButton_Click(object sender, EventArgs e) { new LogController().AddLogEntry(TitleTextBox.Text, DateTimePicker.Value, StartTimeTimePicker.Value, EndTimeTimePicker.Value, HoursWorkedTimePicker.Value, DescriptionTextBox.Text, AuthorTextBox.Text); TitleTextBox.Clear(); DescriptionTextBox.Clear(); AuthorTextBox.Clear(); MessageBox.Show("New log entry added!", "Log added!"); }
/// <summary> /// Clears fields and sets necessary fields to prepare for /// save. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NewBookButton_Click(object sender, EventArgs e) { AuthorTextBox.Clear(); TitleTextBox.Clear(); ISBNTextBox.Clear(); PriceTextBox.Clear(); BookSelectBox.Enabled = false; SaveButton.Enabled = true; CancelButton.Enabled = true; }
private void SaveButton_Click(object sender, EventArgs e) { // Check for empty boxes. if (AuthorTextBox.Text == "" || TitleTextBox.Text == "" || ISBNTextBox.Text == "" || PriceTextBox.Text == "" || !Regex.IsMatch(AuthorTextBox.Text, author) || !Regex.IsMatch(TitleTextBox.Text, title) || !Regex.IsMatch(ISBNTextBox.Text, isbn) || !Regex.IsMatch(PriceTextBox.Text, price)) { MessageBox.Show("Invalid Entry:\nAuthor must be First Last\nISBN must be digits only\nPrice must be $xxx.xx format"); return; } // Display messagebox -> If user clicks no, cancel database update. if (MessageBox.Show("Confirm Update?", "", MessageBoxButtons.YesNo) == DialogResult.No) { return; } string ConnectionString = "server=localhost;user=root;database=book store;password="******"Insert into books values(null,'{TitleTextBox.Text}','{AuthorTextBox.Text}','{ISBNTextBox.Text}','{PriceTextBox.Text}')"; cmd.Connection = DBConnect; cmd.ExecuteNonQuery(); DBConnect.Close(); AuthorTextBox.Clear(); TitleTextBox.Clear(); ISBNTextBox.Clear(); PriceTextBox.Clear(); // Call function to update the combobox with new book added. BookSelectComboBox_Click(sender, e); BookSelectBox.Enabled = true; SaveButton.Enabled = false; MessageBox.Show("Book added to database."); return; } // Else update the currently selected book cmd.CommandText = $"Update books set title='{TitleTextBox.Text}', author='{AuthorTextBox.Text}',isbn='{ISBNTextBox.Text}',price='{PriceTextBox.Text}' where title='{BookSelectBox.Text}'"; cmd.Connection = DBConnect; cmd.ExecuteNonQuery(); DBConnect.Close(); MessageBox.Show("Book successfully updated."); }
/// <summary> /// Event handler for EditAuthorButton click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EditAuthorButton_Click(object sender, RoutedEventArgs e) { //Opens a new EditAuthorDialog dialog window. EditAuthorDialog ead = new EditAuthorDialog(this, controller); if ((bool)ead.ShowDialog()) //if dialog returns true (changes confirmed) { changedAuthor = ead.Result; //set changed author to the result of dialog window //reflect change in control AuthorTextBox.Clear(); AuthorTextBox.Text = String.Format("{0} {1}", changedAuthor.FirstName, changedAuthor.LastName); } }
private void AboutForm_Load(object sender, EventArgs e) { LabelVersion.Text = "Version " + Application.ProductVersion; AuthorTextBox.Text = @"Created by Dan Hickok Source for this program is available at: https://github.com/danhickok/timecards NewtonSoft JSON library by James Newton-King SQLite CodeFirst library by Marc Sallin SQLite database engine, EF, and LINQ interfaces by SQLite Development Team Entity Framework and other .NET components by Microsoft"; AuthorTextBox.Select(0, 0); OKButton.Focus(); }
private void CleanUp() { TitleTextBox.Clear(); AuthorTextBox.Clear(); DescTextBox.Clear(); ShortcutTextBox.Clear(); IdTextBox.Clear(); ToolTipTextBox.Clear(); DefaultTextBox.Clear(); CodeRichTextBox.Clear(); LiteralListBox.Items.Clear(); LiteralList.Clear(); foreach (TreeNode tn in DllAndNamespaceTreeView.Nodes) { tn.Checked = false; } }
// save button clicked private void SaveButton_Click(object sender, EventArgs e) { if (TitleTextBox.ForeColor != Color.Red && AuthorTextBox.ForeColor != Color.Red && ISBNTextBox.ForeColor != Color.Red && PriceTextBox.ForeColor != Color.Red) { // adding new book if (addNewBookMode) { DialogResult save = MessageBox.Show("Do you want to save the book?", "Add New Book", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (save == DialogResult.Yes) { scmd = new SqlCommand("select count(*) from Books where (ISBN = @isbn)", connection); scmd.Parameters.AddWithValue("@isbn", ISBNTextBox.Text); connection.Open(); int exists = (int)scmd.ExecuteScalar(); // check if entered isnb is unique connection.Close(); if (exists == 0) { scmd = new SqlCommand("insert into Books(Title, Author, ISBN, Price) Values(@title, @author, @isbn, @price)", connection); connection.Open(); scmd.Parameters.AddWithValue("@title", TitleTextBox.Text); scmd.Parameters.AddWithValue("@author", AuthorTextBox.Text); scmd.Parameters.AddWithValue("@isbn", ISBNTextBox.Text); scmd.Parameters.AddWithValue("@price", PriceTextBox.Text); scmd.ExecuteNonQuery(); connection.Close(); MessageBox.Show("The Book Was Added Successfully."); DisplayBooks(); // refresh combobox values ResetAll(); BooksComboBox.Enabled = true; } else { MessageBox.Show("Provided ISBN code already exists in the database.", "Invalid ISBN Code", MessageBoxButtons.OK, MessageBoxIcon.Error); ISBNTextBox.Focus(); } } } // updating existing book if (updateBookMode) { DialogResult update = MessageBox.Show("Do you want to update the book?", "Update Existing Book", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (update == DialogResult.Yes) { string cmdText = "UPDATE Books SET Title = @title, Author = @author, Price = @price WHERE ISBN = @isbn"; scmd = new SqlCommand(cmdText, connection); connection.Open(); scmd.Parameters.AddWithValue("@title", TitleTextBox.Text); scmd.Parameters.AddWithValue("@author", AuthorTextBox.Text); scmd.Parameters.AddWithValue("@isbn", ISBNTextBox.Text); scmd.Parameters.AddWithValue("@price", PriceTextBox.Text); scmd.ExecuteNonQuery(); connection.Close(); MessageBox.Show("The Book Was Updated Successfully."); DisplayBooks(); // refresh combobox values ResetAll(); } } } else { MessageBox.Show("Make sure you have provided valid inputs for all the fields", "Invalid Input Provided", MessageBoxButtons.OK, MessageBoxIcon.Error); if (TitleTextBox.ForeColor == Color.Red) { TitleTextBox.Focus(); } if (AuthorTextBox.ForeColor == Color.Red) { AuthorTextBox.Focus(); } if (ISBNTextBox.ForeColor == Color.Red) { ISBNTextBox.Focus(); } if (PriceTextBox.ForeColor == Color.Red) { PriceTextBox.Focus(); } } }