private void ClearAllRecords() { NewCategoryTextBox.Clear(); ItemNameTextBox.Clear(); PriceTextBox.Clear(); CategoryComboBox.SelectedIndex = -1; }
private void AddPhoneButton_Click(object sender, EventArgs e) { // create a cellphone object CellPhoneInventory myphone = new CellPhoneInventory(); // get the phone data getdata(myphone); //Add the cell phone object to the list phoneList.Add(myphone); // add the entry to the list box PhoneListBox.Items.Add(myphone.Brand + " " + myphone.Model); // clear the contents of the textbox BrandTextBox.Clear(); ModelTextBox.Clear(); PriceTextBox.Clear(); BrandTextBox.Focus(); }
private void EditProductButton_Clickk(object sender, EventArgs e) { if (edit == -1) { AddProductButton.Hide(); DeleteProductButton.Hide(); } else { AddProductButton.Show(); DeleteProductButton.Show(); } if (edit == 1) { try { Products[ProductsGridView.CurrentCell.RowIndex].Size = ToInt64(SizeTextBox.Text); Products[ProductsGridView.CurrentCell.RowIndex].Name = NameTextBox.Text; Products[ProductsGridView.CurrentCell.RowIndex].Price = ToDouble(PriceTextBox.Text); Products[ProductsGridView.CurrentCell.RowIndex].Date = Convert.ToString(DateTimePickerOfProduct.Value); ProductsGridView.CurrentRow.SetValues(Products[ProductsGridView.CurrentCell.RowIndex].Id, Products[ProductsGridView.CurrentCell.RowIndex].Size, Products[ProductsGridView.CurrentCell.RowIndex].Date, Products[ProductsGridView.CurrentCell.RowIndex].Name, Products[ProductsGridView.CurrentCell.RowIndex].Price); SizeTextBox.Clear(); NameTextBox.Clear(); PriceTextBox.Clear(); } catch (Exception) { MessageBox.Show("Ошибка"); } } edit *= -1; }
private void SaveButton_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection("Data Source=DESKTOP-P024OII\\TARIQULPC;Initial Catalog=Library_Management_System;Integrated Security=True"); try { con.Open(); SqlCommand cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "insert into BooksInfo values('" + BookNameTextBox.Text + "', '" + AuthorNameTextBox.Text + "', '" + dateTimePicker1.Text + "', " + PriceTextBox.Text + ", " + QuantityTextBox.Text + ", " + QuantityTextBox.Text + ")"; cmd.ExecuteNonQuery(); MessageBox.Show("Book is successfully added"); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } BookNameTextBox.Clear(); AuthorNameTextBox.Clear(); PriceTextBox.Clear(); QuantityTextBox.Clear(); }
public void Cleardata() { FilenameLabel.Text = "FileNotSelected"; PriceTextBox.Clear(); QuantityTextBox.Clear(); ProductCodeTextBox.Clear(); ProductNameTextBox.Clear(); }
// Test input text to be only ints or decimals. private void PriceTextBox_TextChanged(object sender, EventArgs e) { if (!System.Text.RegularExpressions.Regex.IsMatch(PriceTextBox.Text, @"^[0-9]*[.,]?[0-9]*$")) { MessageBox.Show("This textbox accepts only integers or decimal numbers!"); PriceTextBox.ResetText(); } }
private void reset() { bindingDateGridView(); idTextBox.Clear(); NameTextBox.Clear(); PriceTextBox.Clear(); comboBoxOrderStatus.SelectedIndex = 0; comboBoxType.SelectedIndex = 0; }
private void ClearText() { PCTextBox.Clear(); PNTextBox.Clear(); SNTextBox.Clear(); SCTextBox.Clear(); PriceTextBox.Clear(); StockTextBox.Clear(); }
private void AddPriceButton_Click(object sender, EventArgs e) { if (!String.IsNullOrWhiteSpace(PriceTextBox.Text)) { textBox1.Text += PriceTextBox.Text + "\r\n"; WriteTextAsync(textBox1.Text); PriceTextBox.Clear(); } }
/// <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 DiscardButton_Click(object sender, RoutedEventArgs e) { BrandComboBox.GetBindingExpression(Selector.SelectedItemProperty)?.UpdateTarget(); ModelTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget(); Property1ComboBox.GetBindingExpression(Selector.SelectedItemProperty)?.UpdateTarget(); Property2ComboBox.GetBindingExpression(Selector.SelectedItemProperty)?.UpdateTarget(); PriceTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget(); StockTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateTarget(); UpdatePropertyComboBoxProperties(); }
public void Clear() { PCODETextBox.Clear(); BarcodeTextBox.Clear(); PDescTextBox.Clear(); BrandComboBox.Text = ""; CategoryComboBox.Text = ""; PriceTextBox.Clear(); PCODETextBox.Focus(); SaveButton.Enabled = true; UpdateButton.Enabled = false; }
private void PriceTextBox_LostFocus(object sender, RoutedEventArgs e) { if (DataValidation.IsPriceValid(PriceTextBox.Text)) { priceValid = true; PriceTextBox.ToValidView(); return; } priceValid = false; PriceTextBox.ToInvalidView(); }
private void ProductIDTextBox_KeyDown(object sender, KeyEventArgs e) { switch (e.Key) { case Key.Enter: { if (!int.TryParse(this.ProductIDTextBox.Text, out int prodID)) { MessageBox.Show("Введите корректный код!"); this.ProductIDTextBox.Focus(); return; } //if try { using (SmallBusinessDBEntities context = new SmallBusinessDBEntities()) { this.ProductTitleLabel.Content = (object)context.Products.FirstOrDefault(g => g.productID == prodID).productTitle; } //using PriceTextBox.Focus(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } break; case Key.F1: { if (!short.TryParse(this.GroupTextBox.Text, out short groupID)) { MessageBox.Show("Введите корректную группу!"); this.GroupTextBox.Focus(); return; } //if GetProductWindow gpw = new GetProductWindow(groupID); if (gpw.ShowDialog() == true) { this.ProductIDTextBox.Text = gpw.currentProduct.productID.ToString(); try { using (SmallBusinessDBEntities context = new SmallBusinessDBEntities()) { this.ProductTitleLabel.Content = (object)context.Products.FirstOrDefault(g => g.productID == gpw.currentProduct.productID).productTitle; } //using PriceTextBox.Focus(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } //if } break; default: break; }//switch }
private void ClearButton_Click(object sender, EventArgs e) { //Clear Textboxes TitleTextBox.Clear(); PriceTextBox.Clear(); ExtendedPriceTextBox.Clear(); DiscountedPriceTextBox.Clear(); DiscountTextBox.Clear(); QuantityTextBox.Clear(); //Set focus on Quantity QuantityTextBox.Focus(); }
private void UpdateButton_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Are You Really Want To Update This Record", "Confirm", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.OK) { UpdateAllItems(); MessageBox.Show("Record Updated Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); CategoryComboBox.SelectedIndex = -1; ItemNameTextBox.Clear(); PriceTextBox.Clear(); } }
private bool ValidateForm() { if (!Regex.Match(TitleTextBox.Text, @"^\D{1,20}$").Success) { MessageBox.Show("Title must consist of at least 1 character and not exceed 20 characters!"); TitleTextBox.Focus(); return(false); } if (!Regex.Match(DescriptionTextBox.Text, @"^\D{1,200}$").Success) { MessageBox.Show("Description must consist of at least 1 character and not exceed 200 characters!"); DescriptionTextBox.Focus(); return(false); } if (CategoryComboBox.SelectedItem == null) { MessageBox.Show("Please select category"); return(false); } if (ProducerComboBox.SelectedItem == null) { MessageBox.Show("Please select categoty"); return(false); } if (!Regex.Match(WeightTextBox.Text, @"^[0-9]*(?:\,[0-9]*)?$").Success) { MessageBox.Show("Invalid weight! Check the data you've entered!"); WeightTextBox.Focus(); return(false); } if (!Regex.Match(ComponentsTextBox.Text, @"^\D{1,200}$").Success) { MessageBox.Show("Components must consist of at least 1 character and not exceed 200 characters!"); ComponentsTextBox.Focus(); return(false); } if (!Regex.Match(PriceTextBox.Text, @"^[0-9]*(?:\,[0-9]*)?$").Success) { MessageBox.Show("Invalid price! Check the data you've entered!"); PriceTextBox.Focus(); return(false); } return(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."); }
private void SubmitButton_Click(object sender, RoutedEventArgs e) { DB db = DB.Instance; if (Product.ValidPrice(PriceTextBox.GetLineText(0))) { Product product = new Product( NameTextBox.GetLineText(0), PriceTextBox.GetLineText(0), CategoryTextBox.GetLineText(0), BrandTextBox.GetLineText(0) ); product.AddToDB(); Close(); } }
private void AddProductButton_Click(object sender, EventArgs e) { try { Products.Add(new StoredProduct(NameTextBox.Text, ToDouble(PriceTextBox.Text), ToInt64(SizeTextBox.Text), Convert.ToString(DateTimePickerOfProduct.Value))); ProductsGridView.Rows.Add(Products[Product.ID - 1].Id, Products[Product.ID - 1].Size, Products[Product.ID - 1].Date, Products[Product.ID - 1].Name, Products[Product.ID - 1].Price); } catch (Exception) { MessageBox.Show("Не все данные введены корректно."); } SizeTextBox.Clear(); NameTextBox.Clear(); PriceTextBox.Clear(); EnabledButtons(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int id = int.TryParse(Request.QueryString["Id"], out int result) ? result : 0; using (ProductContext context = new ProductContext()) { Product product = context.Products.Where(w => w.ProductId == id).FirstOrDefault(); if (product == null) { Response.Redirect("/Views/Products/ProductsPage.aspx"); } ProductIdField.Value = product.ProductId.ToString(); ProductIdField.DataBind(); ProductNameTextBox.Text = product.Title; ProductNameTextBox.DataBind(); ProductDescriptionTextBox.Text = product.Description; ProductDescriptionTextBox.DataBind(); PriceTextBox.Text = product.Price.ToString(); PriceTextBox.DataBind(); var categories = context.Categories.ToList(); var suppliers = context.Suppliers.ToList(); var manufacturers = context.Manufacturers.ToList(); CategoryDropDownList.DataSource = categories; CategoryDropDownList.SelectedValue = categories.Where(w => w.CategoryId == product.CategoryId).Select(s => s.CategoryName).FirstOrDefault(); CategoryDropDownList.DataTextField = "CategoryName"; CategoryDropDownList.DataBind(); SupplierDropDownList.Items.Add(" "); SupplierDropDownList.DataSource = suppliers; SupplierDropDownList.SelectedValue = suppliers.Where(w => w.SupplierId == product.SupplierId).Select(s => s.SupplierName).FirstOrDefault(); SupplierDropDownList.DataTextField = "SupplierName"; SupplierDropDownList.DataBind(); ManufacturerDropDownList.DataSource = manufacturers; ManufacturerDropDownList.SelectedValue = manufacturers.Where(w => w.ManufacturerId == product.ManufacturerId).Select(s => s.ManufacturerName).FirstOrDefault(); ManufacturerDropDownList.DataTextField = "ManufacturerName"; ManufacturerDropDownList.DataBind(); } } }
private void Clear() { FrameBorder.Visibility = Visibility.Hidden; AmountTextBox.ToDefaultView(DefaultThickness, DefaultBrush); amountValid = false; AmountTextBox.Text = ""; PriceTextBox.ToDefaultView(DefaultThickness, DefaultBrush); priceValid = false; PriceTextBox.Text = ""; NameTextBox.ToDefaultView(DefaultThickness, DefaultBrush); nameValid = false; NameTextBox.Text = ""; typeValid = false; TypeComboBox.SelectedIndex = -1; }
private void AddProoductButton_Click(object sender, EventArgs e) { SqlConnection con = new SqlConnection(); con.ConnectionString = ConfigurationManager.ConnectionStrings["MassiveDynamic.Properties.Settings.MassiveDynamicConnectionString"].ConnectionString; string insertIntoProductId = "'" + ProductIDTextBox.Text + "'"; string insertIntoProductName = "'" + ProductNameTextBox.Text + "'"; string insertIntoCaegoryId = "'" + CategoryIdComboBox.Text + "'"; string insertIntoQPE = "'" + QuantityPerUnitTextBox.Text + "'"; string insertIntoUnitPrice = "'" + PriceTextBox.Text + "'"; string command = string.Format("insert into Products(ProductID,ProductName,CategoryID,QuantityPerUnit,UnitPrice) values ({0},{1},{2},{3},{4})", insertIntoProductId, insertIntoProductName, insertIntoCaegoryId, insertIntoQPE, insertIntoUnitPrice); SqlCommand com = new SqlCommand(command, con); com.CommandType = CommandType.Text; try { con.Open(); com.ExecuteNonQuery(); MessageBox.Show("Данните са добавени успешно!"); ProductIDTextBox.Clear(); ProductNameTextBox.Clear(); QuantityPerUnitTextBox.Clear(); PriceTextBox.Clear(); } catch (Exception exe) { //извеждаме съобщение с възникналото изключение MessageBox.Show(exe.ToString(), "Message/Съобщение:"); } finally { con.Close(); this.Close(); } }
private void CarOperationForm_Load(object sender, EventArgs e) { initBaseData(); switch (usage) { case FormUsage.Update: initUpdateData(); break; case FormUsage.CheckOrder: initUpdateData(); setDisabledCb(); ApplyButton.Text = "Оформить"; ClearCarButton.Text = "Под Заказ"; ClearCarButton.Enabled = false; break; case FormUsage.OrderCar: ApplyButton.Text = "Оформить"; ClearCarButton.Hide(); PriceTextBox.Hide(); DeliveryCarTextBox.Hide(); DeliveryLabel.Hide(); PriceLabel.Hide(); RestLabel.Text = "Кол-во"; modelDTO.price = 1; PriceTextBox.Text = "1"; DeliveryCarTextBox.Text = "1"; break; } }
private void AddButton_Click(object sender, EventArgs e) { if (venta == null) { MessageBox.Show("Debe asignar un cliente"); ClienteTextBox.Focus(); return; } if (IdTextBox.Text == string.Empty) { MessageBox.Show("Debe ingresar un ID"); IdTextBox.Focus(); return; } int id = 0; if (!int.TryParse(IdTextBox.Text, out id)) { MessageBox.Show("Debe ingresar un ID numerico entero"); IdTextBox.Focus(); return; } if (id <= 0) { MessageBox.Show("Debe ingresar un ID mayor a cero"); IdTextBox.Focus(); return; } if (DescriptionTextBox.Text == string.Empty) { MessageBox.Show("Debe ingresar una Descripcion"); DescriptionTextBox.Focus(); return; } decimal price = 0; if (!decimal.TryParse(PriceTextBox.Text, out price)) { MessageBox.Show("Debe ingresar un Precio numerico entero"); PriceTextBox.Focus(); return; } if (price <= 0) { MessageBox.Show("Debe ingresar un Precio mayor a cero"); PriceTextBox.Focus(); return; } int amount = 0; if (!int.TryParse(AmountTextBox.Text, out amount)) { MessageBox.Show("Debe ingresar una Cantidad numerico entero"); AmountTextBox.Focus(); return; } if (amount <= 0) { MessageBox.Show("Debe ingresar una Cantidad mayor a cero"); AmountTextBox.Focus(); return; } Article article = new Article(); article.ID = id; article.Description = DescriptionTextBox.Text; article.Price = price; article.Amount = amount; venta.AddProduct(article); DetailsDataGridView.DataSource = null; DetailsDataGridView.DataSource = venta.Products; IdTextBox.Text = string.Empty; DescriptionTextBox.Text = string.Empty; PriceTextBox.Text = string.Empty; AmountTextBox.Text = string.Empty; IdTextBox.Focus(); }
// 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(); } } }
public void clear() { ItemTextBox.Clear(); PriceTextBox.Clear(); CategoryBox.Text = ""; }
void UnitDropDownList_SelectedIndexChanged(object sender, EventArgs e) { this.DisplayPrice(); PriceTextBox.Focus(); }