private void ChangeEditingStatus() { _product = new Product(); ClearProductInputBoxes(); SaveButton.Visible = IsEditing; AddingRadioButton.Visible = IsEditing; EditingRadioButton.Visible = !IsEditing; AddProductButton.Visible = !IsEditing; SearchLabel.Visible = IsEditing; SearchTextBox.Visible = IsEditing; if (IsEditing) // -----when editing---- { ProductsGridView.Visible = true; SearchTextBox.Select(); AcceptButton = SaveButton; AddingRadioButton.Checked = false; } else // ----when adding---- { ProductsGridView.Visible = false; ProductNameTextBox.Select(); AcceptButton = AddProductButton; AddingRadioButton.Checked = true; } }
private void SaveButton_Click(object sender, EventArgs e) { if (IsValid()) { SizesCart.Clear(); LoadDataIntoSizesCart(); using (SqlConnection con = new SqlConnection(ApplicationSettings.ConnectionString1())) { using (SqlCommand cmd = new SqlCommand("usp_Products_InsertNewProductt", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Name", ProductNameTextBox.Text); cmd.Parameters.AddWithValue("@CategoryID", CategoryComboBox.SelectedValue); cmd.Parameters.AddWithValue("@SupplierID", SupplierComboBox.SelectedValue); cmd.Parameters.AddWithValue("@PurchasePrice", PurchasePriceTextBox.Text); cmd.Parameters.AddWithValue("@SalesPrice", SalesPriceTextBox.Text); con.Open(); int id = Convert.ToInt32(cmd.ExecuteScalar()); SaveSizes(id); MessageBox.Show("product no. " + id.ToString() + " is saved succesfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearControls(); foreach (DataGridViewRow row in SizeDataGridView.Rows) { row.Cells["select"].Value = 0; } ProductNameTextBox.Focus(); } } } }
private void SupplierNameTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { ProductNameTextBox.Select(); } }
public void ClearTextbox() { SupplierComboBox.SelectedIndex = -1; SupplierComboBox.Items.Clear(); textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox5.Clear(); ProductNameTextBox.Clear(); ProductDesTextBox.Clear(); ProductCodeTextBox.Clear(); ShipingQtyTextBox.Clear(); totalItemTextBox.Clear(); totalQuantityTextBox.Clear(); prNmSrchBx.Clear(); itmDscrptnSrchBx.Clear(); pNCheckBox.Checked = false; pDCheckBox.Checked = false; itmCdSrchBx.Clear(); iOSrchBx.Clear(); pCCheckBox.Checked = false; iOCheckBox.Checked = false; listView1.Items.Clear(); dataGridView1.Rows.Clear(); dataGridView1.Refresh(); totalQuantity = 0; totalItem = 0; }
private void ClearselectedProduct() { impOd = null; ProductCodeTextBox.Clear(); ShipingQtyTextBox.Clear(); ProductDesTextBox.Clear(); ProductNameTextBox.Clear(); }
// FOR: ResetRecords For All Buttons Applay private void ResetRecords() { ProductCodeTextBox.Clear(); ProductNameTextBox.Clear(); StatusComboBox.SelectedIndex = -1; AddButton.Text = "Add"; ProductCodeTextBox.Focus(); }
public void Cleardata() { FilenameLabel.Text = "FileNotSelected"; PriceTextBox.Clear(); QuantityTextBox.Clear(); ProductCodeTextBox.Clear(); ProductNameTextBox.Clear(); }
private void SelectAllSizeButton_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in SizeDataGridView.Rows) { row.Cells["select"].Value = 1; } ProductNameTextBox.Focus(); }
private void textBox5_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { ProductNameTextBox.Focus(); e.Handled = true; } }
private void InitAll() { CategoryComboBox.DataSource = _context.Categories.ToList(); CategoryComboBox.DisplayMember = "Name"; CategoryComboBox.SelectedIndex = -1; Icon = Resources.shopping_cart; ProductNameTextBox.Select(); ProductNameTextBox.Focus(); }
private void Clear() { ProductIdTextBox.Clear(); ProductNameTextBox.Clear(); DescriptionTextBox.Clear(); ProductPriceTextBox.Clear(); NewProductArrivedTextBox.Clear(); onHandCount.Clear(); }
private void ClearProductInputBoxes() { ProductNameTextBox.Clear(); ProductBarcodeTextBox.Clear(); MarginTextBox.Clear(); PercentMarginTextBox.Clear(); UnitPriceTextBox.Clear(); UnitCostTextBox.Clear(); CategoryComboBox.SelectedIndex = -1; }
private bool NameIsFilled() { bool filled = !(string.IsNullOrEmpty(ProductNameTextBox.Text)); if (!filled) { MessageBox.Show("Product name cannot be empty"); ProductNameTextBox.Focus(); } return(filled); }
private void ClearselectedProduct() { ShipmentProductId = null; ImportOrderProductId = null; Sl = null; checkvalue = null; backlogQty = null; ProductCodeTextBox.Clear(); ShipingQtyTextBox.Clear(); ProductDesTextBox.Clear(); ProductNameTextBox.Clear(); }
/// <summary> /// Vymazani formulare a pridaneho obrazku /// </summary> private void ClearForm() { // polozky formulare nastaveny na puvodni hodnotu ProductNameTextBox.Clear(); ProductCathegoryCBox.SelectedIndex = -1; ProductCathegoryCBox.ResetText(); ProductPriceTextBox.Clear(); ProductDescriptionRTBox.Clear(); // obrazek je smazan ProductPictureBox.ImageLocation = string.Empty; }
private void ClearControls() { ProductNameTextBox.Clear(); SupplierComboBox.SelectedIndex = -1; CategoryComboBox.SelectedIndex = -1; PurchasePriceTextBox.Clear(); SalesPriceTextBox.Clear(); foreach (DataGridViewRow row in SizeDataGridView.Rows) { row.Cells["select"].Value = 0; } ProductNameTextBox.Focus(); }
private void NewContactButton_Click(object sender, RoutedEventArgs e) { string image = ((Icon)ImageComboBox.SelectedValue).ImagePath; Products.Add(new Product { ProductName = ProductNameTextBox.Text, Description = DescriptionTextBox.Text, Image = image }); ProductNameTextBox.Text = ""; DescriptionTextBox.Text = ""; ImageComboBox.SelectedIndex = -1; ProductNameTextBox.Focus(FocusState.Programmatic); }
private void ProductNameTextBox_Leave(object sender, EventArgs e) { if (nameProduct.Contains(ProductNameTextBox.Text)) { int index = nameProduct.IndexOf(ProductNameTextBox.Text); m_product product = allProduct[index]; UnitOfMeasurementTextBox.Text = getUomDes(getUomID(product.id)); } else { MessageBox.Show("Produk tidak ada dalam database", "Maaf"); ProductNameTextBox.Select(); ProductNameTextBox.Text = ""; } }
private void Form1_Shown(object sender, EventArgs e) { ProductNameFilterComboBox.DataSource = Enum.GetValues(typeof(FilterCondition)); var dataOperations = new DataOperations(); _bindingSource.DataSource = dataOperations.GetProducts(); dataGridView1.DataSource = _bindingSource; dataGridView1.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; ProductNameTextBox.SetCueText("Filter or empty to clear"); ActiveControl = dataGridView1; }
private bool IsValid() { if (ProductNameTextBox.Text.Trim() == string.Empty) { MessageBox.Show("Product Name is required!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); ProductNameTextBox.Focus(); return(false); } if (PurchasePriceTextBox.Text.Trim() == string.Empty) { MessageBox.Show("Purchase Price is required!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); PurchasePriceTextBox.Focus(); return(false); } return(true); }
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 очиститьToolStripMenuItem_Click(object sender, EventArgs e) { ProductNameTextBox.Clear(); InventoryNumberMaskedTextBox.Clear(); SizeTrackBar.Value = 0; radioButton1.Checked = true; radioButton2.Checked = false; GettingDatePicker.Value = DateTime.Now; WeightMaskedTextBox.Clear(); NumberMaskedTextBox.Clear(); PriceMaskedTextBox.Clear(); OrganizationNameTextBox.Clear(); CountryTextBox.Clear(); TelephoneNumberMaskedTextBox.Clear(); form2.CityTextBox.Clear(); form2.StreetTextBox.Clear(); form2.HouseMaskedTextBox.Clear(); Act = "очистка всех полей"; }
private void ProductListBox_SelectedIndexChanged(object sender, EventArgs e) { Product selectedProduct = (Product)ProductListBox.SelectedItem; if (selectedProduct != null) { ProductNameTextBox.Text = selectedProduct.Name; ProductNameLabel.Text = selectedProduct.Name; OwnerLabel.Text = selectedProduct.OwnerName; // Set default owner in combobox foreach (User u in OwnerComboBox.Items) { if (u.UserId == selectedProduct.OwnerId) { OwnerComboBox.SelectedItem = u; break; } } // Get count information StockInfo stockInfo = DBHelper.GetStockInfo(selectedProduct); if (stockInfo != null) { ProductCount.Value = stockInfo.Count; } else { ProductCount.Value = 0; } } else { // User has clicked an empty area, no products are selected. // Clear all fields ProductNameTextBox.Clear(); ProductNameLabel.Text = "Please select a product."; OwnerLabel.Text = string.Empty; OwnerComboBox.SelectedItem = null; ProductCount.Value = 0; } }
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(); } }
// ====================== END OF SEARCH FUNCTIONALITY METHODS ========================= /* * ====================== START OF INVENTORY MANAGEMENT METHODS ========================= * 1.AddProductButton_Click * 2.CategoryButton_Click * 3.ModifyButton_Click */ /* * Event Handler for Adding New Product to Inventory */ private void AddProductButton_Click(object sender, EventArgs e) { Product Prod = new Product(); bool DuplicateProduct = false; StreamWriter FileWriter; FileWriter = File.AppendText(PRODUCTDATABASEFILENAME); if (ProductNameTextBox.Text == "") { MessageBox.Show("Please enter New Product Name"); ProductNameTextBox.Focus(); ProductNameTextBox.SelectAll(); } else { if (ProductCategoryListBox.SelectedIndex == -1) { MessageBox.Show("Please select Product Category from the list"); ProductCategoryListBox.Focus(); } else { if (ProductPriceTextBox.Text == "") { MessageBox.Show("Please enter Product Price"); ProductPriceTextBox.Focus(); ProductPriceTextBox.SelectAll(); } else { try { decimal.TryParse(ProductPriceTextBox.Text, out decimal ProductPrice); if (ProductPrice <= 0) { MessageBox.Show("Product Price should be greater than Zero"); ProductPriceTextBox.Focus(); ProductPriceTextBox.SelectAll(); } else { if (ProductQuantityTextBox.Text == "") { MessageBox.Show("Please enter Product Quantity"); ProductQuantityTextBox.Focus(); ProductQuantityTextBox.SelectAll(); } else { try { int.TryParse(ProductQuantityTextBox.Text, out int ProductQuantity); if (ProductQuantity <= 0) { MessageBox.Show("Product Quantity should be greater than Zero"); ProductQuantityTextBox.Focus(); ProductQuantityTextBox.SelectAll(); } else { foreach (Product p in ProductList) { if (p.ProductCategory == ProductCategoryListBox.SelectedItem.ToString() && p.ProductName == ProductNameTextBox.Text) { MessageBox.Show("Same Product Already Exist in the same Category"); ProductNameTextBox.Focus(); ProductNameTextBox.SelectAll(); DuplicateProduct = true; break; } } if (DuplicateProduct == false) { Random RandomNumberGenerator = new Random(); int ProductNumber = RandomNumberGenerator.Next(1, 999999); string CheckProductID = ProductCategoryListBox.SelectedItem.ToString().Substring(0, 4) + ProductNumber.ToString("D6"); while (ExistProductID_Check(CheckProductID)) { ProductNumber = RandomNumberGenerator.Next(1, 999999); CheckProductID = ProductCategoryListBox.SelectedItem.ToString().Substring(0, 4) + ProductNumber.ToString("D6"); } Prod.ProductID = ProductCategoryListBox.SelectedItem.ToString().Substring(0, 4) + ProductNumber.ToString("D6"); FileWriter.WriteLine(Prod.ProductID); Prod.ProductCategory = ProductCategoryListBox.SelectedItem.ToString(); FileWriter.WriteLine(Prod.ProductCategory); Prod.ProductName = ProductNameTextBox.Text; FileWriter.WriteLine(Prod.ProductName); Prod.ProductPrice = decimal.Parse(ProductPriceTextBox.Text); FileWriter.WriteLine(Prod.ProductPrice); Prod.ProductQuantity = int.Parse(ProductQuantityTextBox.Text); FileWriter.WriteLine(Prod.ProductQuantity); ProductList.Add(Prod); FileWriter.Close(); MessageBox.Show("Product '" + Prod.ProductName + "' Added Successfully to the Category '" + Prod.ProductCategory + "'"); ProductCategoryListBox.SelectedIndex = -1; ProductNameTextBox.Text = ProductPriceTextBox.Text = ProductQuantityTextBox.Text = CheckProductID = ""; } } } catch { } } } } catch { } } } } }
private void ProductsRecordForm_Load(object sender, EventArgs e) { LoadAllProductIntoDataGridView(); ProductNameTextBox.Focus(); }