public FrmEditShopItem(PrintShopItem item, int artistAttendingID = -1) { InitializeComponent(); TxtNotes.SetWatermark("Optional"); TxtPrice.SetWatermark("NFS If Blank"); ShopItem = item ?? new PrintShopItem(); if (artistAttendingID > -1) { ShopItem.ArtistAttendingID = artistAttendingID; } if (item == null) { return; } LblShowNumber.Text = ShopItem.ShowNumber != null?ShopItem.ShowNumber.ToString() : "TBD"; TxtTitle.Text = ShopItem.Title; TxtMedia.Text = ShopItem.Media; NumQuantitySent.Value = ShopItem.QuantitySent; TxtPrice.Text = ShopItem.Price.ToString(); TxtNotes.Text = ShopItem.Notes ?? ""; TxtLocation.Text = ShopItem.LocationCode ?? ""; CmbCategory.SelectedIndex = ShopItem.Category != null?CmbCategory.FindString(ShopItem.Category) : 0; }
private void BtnSave_Click(object sender, EventArgs e) { TxtPrice.BackColor = SystemColors.Control; decimal price; if (TxtPrice.Text == "" || !decimal.TryParse(TxtPrice.Text, NumberStyles.Currency, null, out price)) { TxtPrice.BackColor = Color.Yellow; TxtPrice.Focus(); return; } ShopItem.Title = TxtTitle.Text; ShopItem.Media = TxtMedia.Text; ShopItem.QuantitySent = Convert.ToInt32(NumQuantitySent.Value); ShopItem.Price = price; ShopItem.Notes = TxtNotes.Text.Trim().Length > 0 ? TxtNotes.Text : null; ShopItem.LocationCode = TxtLocation.Text.Trim().Length > 0 ? TxtLocation.Text : null; ShopItem.Category = CmbCategory.SelectedItem != null?CmbCategory.SelectedItem.ToString() : null; if (ShopItem.Save()) { DialogResult = DialogResult.OK; } else { MessageBox.Show("An error occurred trying to save this item: " + ShopItem.LastError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void InitControls() { TxtIdx.Clear(); TxtAuthor.Clear(); TxtNames.Clear(); TxtIsbn.Clear(); TxtPrice.Clear(); CboDivision.SelectedIndex = 0; DtReleaseDate.Value = DateTime.Today; TxtIdx.Focus(); baseMode = BaseMode.NONE; #region comboBox Dictionary /*Dictionary<string, string> dic = new Dictionary<string, string> * { * { "선택", "00" }, * { "서울특별시", "11" }, * { "부산광역시", "21" }, * { "대구광역시", "22" }, * { "인천광역시", "23" }, * { "광주광역시", "24" }, * { "대전광역시", "25" } * }; * * CboDivision.DataSource = new BindingSource(dic, null); * CboDivision.DisplayMember = "Key"; * CboDivision.ValueMember = "Value";*/ #endregion }
public void FillOfferForm(string offerName, string offerDescription, string price) { TxtName.SendKeys(offerName); TxtDescription.SendKeys(offerDescription); TxtPrice.SendKeys(price); ButtonSubmit.Click(); }
//reset method private void Reset() { TxtName.Clear(); TxtPages.Clear(); TxtPrice.Clear(); TxtQuantity.Clear(); CbxLanguage.SelectedItem = null; BtnUpdate.Visibility = Visibility.Hidden; BtnDelete.Visibility = Visibility.Hidden; BtnRead.Visibility = Visibility.Hidden; }
//(Reset)Returning everything back to its original// private void Reset() { CmbBookcase.SelectedItem = null; CmbShelf.SelectedItem = null; TxtName.Clear(); TxtPrice.Clear(); DeleteBtn.Visibility = Visibility.Hidden; UpdateBtn.Visibility = Visibility.Hidden; CreateBtn.Visibility = Visibility.Visible; }
private void btnSubmitItem_Click(object sender, RoutedEventArgs e) { if (TxtNameItem.Text == "") { MessageBox.Show("Fill column name please", "Alert", MessageBoxButton.OK); TxtNameItem.Focus(); } else if (TxtStock.Text == "") { MessageBox.Show("Fill column stock please", "Alert", MessageBoxButton.OK); TxtStock.Focus(); } else if (TxtPrice.Text == "") { MessageBox.Show("Fill column price please", "Alert", MessageBoxButton.OK); TxtPrice.Focus(); } else { try { var itemstock = myContext.Items.FirstOrDefault(a => a.Name == TxtNameItem.Text); if (itemstock != null) { if (itemstock.Name == TxtNameItem.Text && itemstock.Price.ToString() == TxtPrice.Text && itemstock.SupplierFK.Id.ToString() == comboBoxSupplier.Text) { itemstock.Stock += Convert.ToInt32(TxtStock.Text); myContext.SaveChanges(); Load(); MessageBox.Show("1 row has been updated.", "Message", MessageBoxButton.OK); } else { MessageBox.Show("Don't submit in here, please update item"); } } else { var supplier = myContext.Suppliers.FirstOrDefault(data => data.Id == supplierid); var push = new Item(TxtNameItem.Text, Convert.ToInt32(TxtStock.Text), Convert.ToInt32(TxtPrice.Text), supplier); myContext.Items.Add(push); myContext.SaveChanges(); Load(); MessageBox.Show("1 row has been inserted.", "Message", MessageBoxButton.OK); } } catch (Exception x) { MessageBox.Show(x.Message); } //comboBoxSupplier.Text = "--Choose Supplier--"; } }
private void BtnNew_Click(object sender, EventArgs e) { dateTimePicker1.Value = System.DateTime.Today; TxtOrder.Clear(); TxtCustomer.Clear(); TxtPhone.Clear(); ComboItem.SelectedIndex = -1; TxtPrice.Clear(); TxtQty.Clear(); TxtTotal.Clear(); TxtOrder.Focus(); }
//Reset Textbox Value private void Reset() { TxtName.Clear(); TxtPrice.Clear(); TxtQuantity.Clear(); BtnCreate.Visibility = Visibility.Visible; BtnUpdate.Visibility = Visibility.Hidden; BtnDelete.Visibility = Visibility.Hidden; FillBookData(); }
private void txtPrice_Validating(object sender, CancelEventArgs e) { string errorMsg; if (!ValidPrice(TxtPrice.Text, out errorMsg)) { //Cancel the event and select the text to be corrected by the user e.Cancel = true; TxtPrice.Select(0, TxtPrice.Text.Length); //Set the ErrorProvider error with the text to display this.errorProvider1.SetError(TxtPrice, errorMsg); } if (e.Cancel == false) { this.errorProvider1.Clear(); } }
private void btnUpdateItem_Click(object sender, RoutedEventArgs e) { int num = Convert.ToInt32(TxtIdItem.Text); var updated = myContext.Items.FirstOrDefault(data => data.Id == num); var supplier = myContext.Suppliers.FirstOrDefault(data => data.Id == supplierid); if (TxtNameItem.Text == "") { MessageBox.Show("Fill column name please", "Alert", MessageBoxButton.OK); TxtNameItem.Focus(); } else if (TxtStock.Text == "") { MessageBox.Show("Fill column stock please", "Alert", MessageBoxButton.OK); TxtStock.Focus(); } else if (TxtPrice.Text == "") { MessageBox.Show("Fill column price please", "Alert", MessageBoxButton.OK); TxtPrice.Focus(); } else { try { updated.Name = TxtNameItem.Text; updated.Stock = Convert.ToInt32(TxtStock.Text); updated.Price = Convert.ToInt32(TxtPrice.Text); updated.SupplierFK = supplier; myContext.SaveChanges(); Load(); } catch (Exception x) { MessageBox.Show(x.Message); } MessageBox.Show("Updated Success!", "Success", MessageBoxButton.OK); btnSubmitItem.IsEnabled = true; btnUpdateItem.IsEnabled = false; btnUpdateItem.IsEnabled = false; //comboBoxSupplier.Text = "--Choose Supplier--"; } }
private void BtnSubmitItem_Click(object sender, RoutedEventArgs e) { int Stock = Convert.ToInt32(TxtStock.Text); int Price = Convert.ToInt32(TxtPrice.Text); if (TxtNameItem.Text == "") { MessageBox.Show("Name Should be Filled!", "Warning!", MessageBoxButton.OK); TxtNameItem.Focus(); } else if (TxtStock.Text == "") { MessageBox.Show("Stock Should be Filled!", "Warning!", MessageBoxButton.OK); TxtStock.Focus(); } else if (TxtPrice.Text == "") { MessageBox.Show("Price Should be Filled!", "Warning!", MessageBoxButton.OK); TxtPrice.Focus(); } else if (CbSupplier.Text == "") { MessageBox.Show("Select Supplier Name!", "Warning!", MessageBoxButton.OK); } else { var supplier = myContext.Suppliers.Where(s => s.Id == supplierId).FirstOrDefault(); var push = new Item(TxtNameItem.Text, Stock, Price, supplier); myContext.Items.Add(push); var result = myContext.SaveChanges(); if (result > 0) { MessageBox.Show("1 row has been inserted"); TxtNameItem.Text = ""; TxtStock.Text = ""; TxtPrice.Text = ""; dataGridItem.ItemsSource = myContext.Items.ToList(); } } }
private void BtnSave_Click(object sender, RoutedEventArgs e) { try { if ((TxtNameItem.Text == "") || (TxtStock.Text == "") || (TxtPrice.Text == "")) { if (TxtNameItem.Text == "") { MessageBox.Show("Name Item Is Required", "Caution", MessageBoxButton.OK); TxtNameItem.Focus(); } else if (TxtStock.Text == "") { MessageBox.Show("Stock Item Is Required", "Caution", MessageBoxButton.OK); TxtStock.Focus(); } else if (TxtPrice.Text == "") { MessageBox.Show("Price Item is Required", "Caution", MessageBoxButton.OK); TxtPrice.Focus(); } } else { if (TxtNameItem.Text != null) { int Stock = Convert.ToInt32(TxtStock.Text); int Price = Convert.ToInt32(TxtPrice.Text); var supplier = myContext.Suppliers.Where(w => w.Id == supplierid).FirstOrDefault(); var itemname = myContext.Items.Where(i => i.Name == TxtNameItem.Text).FirstOrDefault(); //var priceitem = myContext.Items.Where(i => i.Price == TxtPriceItem.Text).FirstOrDefault(); if (itemname != null) { var stockrecent = itemname.Stock; var pricerecent = itemname.Price; var supplierrecent = itemname.Supplier.ToString(); if (TxtPrice.Text == pricerecent.ToString()) { int updStock = Stock + stockrecent; itemname.Stock = Convert.ToInt32(updStock); var result2 = myContext.SaveChanges(); if (result2 > 0) { MessageBox.Show("Stock Has Been Updated"); } else { MessageBox.Show("Stock Cant be Updated"); } GridItem.ItemsSource = myContext.Items.ToList(); } else { int Stock2 = Convert.ToInt32(TxtStock.Text); int Price2 = Convert.ToInt32(TxtPrice.Text); var supplier2 = myContext.Suppliers.Where(w => w.Id == supplierid).FirstOrDefault(); var pushStock = new Item(TxtNameItem.Text, Stock2, Price2, supplier2); myContext.Items.Add(pushStock); var result = myContext.SaveChanges(); if (result > 0) { MessageBox.Show("New Item has been inserted"); } else { MessageBox.Show("New item cant be inserted"); } GridItem.ItemsSource = myContext.Items.ToList(); } } else { int Stock2 = Convert.ToInt32(TxtStock.Text); int Price2 = Convert.ToInt32(TxtPrice.Text); var supplier2 = myContext.Suppliers.Where(w => w.Id == supplierid).FirstOrDefault(); var pushStock = new Item(TxtNameItem.Text, Stock2, Price2, supplier2); myContext.Items.Add(pushStock); var result = myContext.SaveChanges(); if (result > 0) { MessageBox.Show("New Item has been inserted"); } else { MessageBox.Show("New item cant be inserted"); } GridItem.ItemsSource = myContext.Items.ToList(); } } } ComboItem.ItemsSource = myContext.Items.ToList(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Message", MessageBoxButton.OK); } }
/// <summary> /// Saving Product /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnSave_Click(object sender, EventArgs e) { try { if (TxtProductNumber.Text == "") { MessageBox.Show("Enter Product Number"); TxtProductNumber.Focus(); } else if (TxtProductName.Text == "") { MessageBox.Show("Enter Product Name"); TxtProductName.Focus(); } else if (TxtPrice.Text == "") { MessageBox.Show("Enter Price"); TxtPrice.Focus(); } else if (ComboColor.SelectedIndex == -1) { MessageBox.Show("Select Color"); ComboColor.Focus(); } else if (ComboClass.SelectedIndex == -1) { MessageBox.Show("Select Class"); ComboClass.Focus(); } else { string message = "Are you sure you want save this record"; if (MessageBox.Show(message, "confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.Yes) { string selectedComboColor = ComboColor.Items[ComboColor.SelectedIndex].ToString(); string selectedComboClass = ComboClass.Items[ComboClass.SelectedIndex].ToString(); Product objproduct = new Product(); objproduct.Color = selectedComboColor; objproduct.Description = TxtDescription.Text; objproduct.Name = TxtProductName.Text; objproduct.Price = Convert.ToDecimal(TxtPrice.Text); objproduct.ProductNumber = TxtProductNumber.Text; objproduct.ProductClass = selectedComboClass; objproduct.CreatedDate = DateTime.Now; objproduct.CLientIDToken = ShareObject.CLientIDToken; // Calling Business Layer ProductBL.AddProduct(objproduct); // Binding data to DataGridView DGData.DataSource = ProductBL.GetData(ShareObject.CLientIDToken); DGData.ReadOnly = true; Clear(); } } } catch (Exception) { throw; } }