private void BtnCancel_Click(object sender, RoutedEventArgs e) { TextTitle.Clear(); TextAuthor.Clear(); TextSummary.Clear(); preview = null; manager = null; extension = null; compiler = null; StackResult.Visibility = Visibility.Collapsed; StackOpen.Visibility = Visibility.Visible; }
private void btnSave_Click(object sender, EventArgs e) { Book b = new Book(); if (string.IsNullOrEmpty(TextDescription.Text) || string.IsNullOrEmpty(TextAuthor.Text) || string.IsNullOrEmpty(TextName.Text) || string.IsNullOrEmpty(ComboCategory.Text)) { MetroFramework.MetroMessageBox.Show(this, "All field should be filled up.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); TextName.Focus(); return; } else { if (TextName.Text.Length <= 50) { b.name = TextName.Text; } else { MetroFramework.MetroMessageBox.Show(this, "Book Name Too Big.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (TextAuthor.Text.Length <= 50) { b.author = TextAuthor.Text; } else { MetroFramework.MetroMessageBox.Show(this, "Author Name Too Big.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (TextDescription.Text.Length <= 500) { b.description = TextDescription.Text; } else { MetroFramework.MetroMessageBox.Show(this, "Description Too Big.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (pictureBox.Image != null) { b.picture = imageToByteArray(pictureBox.Image); //return; } if (!string.IsNullOrEmpty(TextLink.Text)) { b.link = TextLink.Text; } b.category = ComboCategory.Text; b.rating = 0; BookServices.Insert(b); MetroFramework.MetroMessageBox.Show(this, "Added successfully.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Refresh(); TextDescription.Clear(); TextAuthor.Clear(); TextName.Clear(); ComboCategory.SelectedIndex = 0; TextLink.Clear(); pictureBox.Image = null; } }