private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) //event handle when picking an item { try { MySqlConnection connection = new MySqlConnection("Datasource=localhost;port=3306;username=root;password="******"\"{comboBox1.SelectedItem.ToString()}\""; string query = "SELECT * FROM bookstore.books WHERE title = " + selectedItem; connection.Open(); MySqlCommand command = new MySqlCommand(query, connection); MySqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { AuthorText.Text = reader["author"].ToString(); PriceText.Text = reader["price"].ToString(); IsbnText.Text = reader["ISBN"].ToString(); } connection.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); //clear form AuthorText.Clear(); IsbnText.Clear(); PriceText.Clear(); } QuantityText.Focus(); }
/// <summary> /// This creates the book and if a certain book is picked, the corresponding text boxes will update with the /// correct information in each box. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { string SelectedItem = (string)comboBox1.SelectedItem; try { string jsonBook = File.ReadAllText(@"Z:\Desktop\Fourth Year (F18-S19)\CompE561\Lab1\Lab1\bin\Debug\BookList.json"); JObject JSON = JObject.Parse(jsonBook); JObject targetBook = (JObject)JSON[SelectedItem]; string s_targetBook = targetBook.ToString(); Book found = new Book(); Newtonsoft.Json.JsonConvert.PopulateObject(s_targetBook, found); AuthorText.Text = found.author;; IsbnText.Text = found.ISBN; PriceText.Text = found.price.ToString(); } catch { AuthorText.Clear(); IsbnText.Clear(); PriceText.Clear(); } QuantityText.Focus(); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) //event handle when picking an item { string SelectedItem = (string)comboBox1.SelectedItem; try { //access books string BookJSON = File.ReadAllText(@"C:\Users\RMBonMAC\Documents\GitHub\BookStore\BookStore\BookStore\bin\Debug\Books.json"); JObject json = JObject.Parse(BookJSON); JObject BookTarget = (JObject)json[SelectedItem]; string book_target = BookTarget.ToString(); Book foundBook = new Book(); Newtonsoft.Json.JsonConvert.PopulateObject(book_target, foundBook); AuthorText.Text = foundBook.author;; IsbnText.Text = foundBook.ISBN; PriceText.Text = foundBook.price.ToString(); } catch { AuthorText.Clear(); IsbnText.Clear(); PriceText.Clear(); } QuantityText.Focus(); }
private void SubmitSaleButton_Click(object sender, RoutedEventArgs e) { string[] Data = new string[5]; Data[0] = VehicleText.GetLineText(0); Data[1] = CustomerText.GetLineText(0); Data[2] = EmployeeText.GetLineText(0); Data[3] = DateText.GetLineText(0); Data[4] = PriceText.GetLineText(0); MakeSale S = new MakeSale(Data, cn); try { S.CreateSale(); } catch (OleDbException ex) { ErrorWindow Error = new ErrorWindow(ex.Message); Error.ShowDialog(); return; } VehicleText.Clear(); CustomerText.Clear(); EmployeeText.Clear(); DateText.Clear(); PriceText.Clear(); }
private void AddCarSubmit_Click(object sender, RoutedEventArgs e) { string[] Data = new string[6]; Data[0] = VINText.GetLineText(0); Data[1] = ModelText.GetLineText(0); Data[2] = YearText.GetLineText(0); Data[3] = ManufacturerText.GetLineText(0); Data[4] = SeatsText.GetLineText(0); Data[5] = PriceText.GetLineText(0); string Type = TypeText.GetLineText(0); string VIN = Data[0]; MakeVehicle V = new MakeVehicle(Data, cn); MakeCar C = new MakeCar(VIN, Type, cn); try { V.CreateVehicle(); } catch (OleDbException ex) { ErrorWindow Error = new ErrorWindow(ex.Message); Error.ShowDialog(); return; } try { C.CreateCar(); } catch (OleDbException ex) { try { V.DeleteVehicle(); } catch (OleDbException ex2) { } ErrorWindow Error = new ErrorWindow(ex.Message); Error.ShowDialog(); return; } if (used) { R = new VehicleHistoryReport(Parent, cn); R.ShowDialog(); } this.Close(); }
void ReleaseDesignerOutlets() { if (BuscarButton != null) { BuscarButton.Dispose(); BuscarButton = null; } if (CategoryText != null) { CategoryText.Dispose(); CategoryText = null; } if (CountText != null) { CountText.Dispose(); CountText = null; } if (IdText != null) { IdText.Dispose(); IdText = null; } if (NameText != null) { NameText.Dispose(); NameText = null; } if (PriceText != null) { PriceText.Dispose(); PriceText = null; } if (StatusLabel != null) { StatusLabel.Dispose(); StatusLabel = null; } if (ValidarButton != null) { ValidarButton.Dispose(); ValidarButton = null; } }
public void Bind(Models.DTO.Order.Get.OrderModel model) { CellContentRootView?.SetBackgroundColor(ColorConstants.BackroundCell, 5); if (!ItemTypeOrder.IsNull()) { ItemTypeOrder.Text = model.Type == 1 ? @ROrderBar.OrderAtBar : ROrderTable.OrderAtTable; ItemTypeOrder?.SetTextColor(ColorConstants.WhiteColor); ItemTypeOrder.SetFont(FontsConstant.OpenSansBold, FontsConstant.Size14); } if (!PriceText.IsNull()) { PriceText.Text = "€" + model.TotalAmount; PriceText?.SetTextColor(ColorConstants.SelectorHome); PriceText?.SetFont(FontsConstant.OpenSansBold, FontsConstant.Size14); } if (!OrderIdText.IsNull()) { OrderIdText.Text = "#" + model.Id; OrderIdText?.SetTextColor(ColorConstants.SelectorHome); OrderIdText?.SetFont(FontsConstant.OpenSansBold, FontsConstant.Size36); } if (DateTimeText.IsNull()) { return; } DateTimeText.Text = model.UpdatedAt.UnixTimeStampToDateTime().ToString("dd.MM.yyyy / hh:mm"); DateTimeText?.SetTextColor(ColorConstants.WhiteColor); DateTimeText?.SetFont(FontsConstant.OpenSansRegular, FontsConstant.Size14); if (CellContentRootView.IsNull()) { return; } CellContentRootView.Tag = model; CellContentRootView.Click -= CellContentRootView_Click; CellContentRootView.Click += CellContentRootView_Click; }
public void Bind(IOrderContent model) { CellContentRootView?.SetBackgroundColor(ColorConstants.BackroundCell, 5); CategoryImage?.SetImageFromUrl(model.ImagePath); if (!RemoveOrderImage.IsNull()) { RemoveOrderImage?.SetImageFromResource(DrawableConstants.OrderRemoveIcon); RemoveOrderImage.Tag = model; RemoveOrderImage.Click -= RemoveOrderImage_Click; RemoveOrderImage.Click += RemoveOrderImage_Click; } if (!ItemNameText.IsNull()) { ItemNameText.Text = model.OrderName; ItemNameText?.SetTextColor(ColorConstants.WhiteColor); ItemNameText.SetFont(FontsConstant.OpenSansBold, FontsConstant.Size14); } if (!PriceText.IsNull()) { PriceText.Text = "€" + model.Price * Convert.ToInt32(model.Quantity); PriceText?.SetTextColor(ColorConstants.SelectorHome); PriceText?.SetFont(FontsConstant.OpenSansBold, FontsConstant.Size14); } if (!MinusText.IsNull()) { MinusText?.SetTextColor(ColorConstants.WhiteColor); MinusText?.SetFont(FontsConstant.OpenSansRegular, FontsConstant.Size20); MinusText?.SetBackgroundColor(ColorConstants.SelectorHome, type: RadiusType.Aspect); MinusText?.SetSelectedColor(ColorConstants.SelectorHome.SelectorTransparence(ColorConstants.Procent50)); MinusText.Text = "-"; MinusText.Tag = new { Model = model }; MinusText.Click -= MinusText_Click; MinusText.Click += MinusText_Click; } if (!QuantityText.IsNull()) { QuantityText.Text = model.Quantity; QuantityText?.SetTextColor(ColorConstants.WhiteColor); QuantityText?.SetFont(FontsConstant.OpenSansBold, FontsConstant.Size14); } if (PlusText.IsNull()) { return; } PlusText?.SetTextColor(ColorConstants.WhiteColor); PlusText?.SetFont(FontsConstant.OpenSansRegular, FontsConstant.Size20); PlusText.Text = "+"; PlusText?.SetBackgroundColor(ColorConstants.SelectorHome, type: RadiusType.Aspect); PlusText?.SetSelectedColor(ColorConstants.SelectorHome.SelectorTransparence(ColorConstants.Procent50)); PlusText.Tag = new { Model = model }; PlusText.Click -= PlusText_Click; PlusText.Click += PlusText_Click; }
public override int GetHashCode() { return(Id.GetHashCode() ^ Name.GetHashCode() ^ PriceText.GetHashCode()); }