// UPDATE AN AUCTION private void btnUpdateAuction_Click(object sender, EventArgs e) { string result = cbResult.Text; string productName = txtProdName.Text; string productDescription = txtProdDescription.Text; bool payment = false; DateTime timeLeftDateAndTime = dtpDateTl.Value.Date.Add(dtpClockTl.Value.TimeOfDay); DateTime paymentDateAndTime = dtpDatePayD.Value.Date.Add(dtpClockPayD.Value.TimeOfDay); int findAuctionId; int.TryParse(txtboxAuctionId.Text, out findAuctionId); if (radioBtnAuction.Checked) { payment = true; } else if (rbutNotPayed.Checked) { payment = false; } else if (!radioBtnAuction.Checked && !rbutNotPayed.Checked) { MessageBox.Show("Please chose wheter it is payed!"); } ControlAuction ctrlAuction = new ControlAuction(); ctrlAuction.UpdateAuction(findAuctionId, timeLeftDateAndTime, payment, result, paymentDateAndTime, productName, productDescription); }
public Form2() { InitializeComponent(); ControlAuction aus = new ControlAuction(); dataGridView1.DataSource = aus.ViewAuction(); }
// LIST ALL AUCTIONS METHOD private void listAllAuctions() { ControlAuction ctrlAuction = new ControlAuction(); List <Auction> allAuctions = ctrlAuction.GetAllAuctions(); // CLEAR LIST listBoxAuctions.Items.Clear(); // REFRESH LIST foreach (Auction auction in allAuctions) { listBoxAuctions.Items.Add(auction); } }
// METHOD - ASYNCHRONOUS FIND ALL AUCTIONS (OBS. INVOKERS) private async Task ListAllAuctionsAsync() { await Task.Run(() => { ControlAuction ctrlAuction = new ControlAuction(); List <Auction> allAuctions = ctrlAuction.GetAllAuctions(); //Clear list this.Invoke((MethodInvoker)(() => listBoxAuctions.Items.Clear())); // Update list foreach (Auction auction in allAuctions) { this.Invoke((MethodInvoker)(() => listBoxAuctions.Items.Add(auction))); } }); }
// DELETE AUCTION private void btnDeleteAuction_Click(object sender, EventArgs e) { int auctionIdToDelete; int.TryParse(txtboxAuctionId.Text, out auctionIdToDelete); bool allIsGood = !(auctionIdToDelete <= 0); if (allIsGood) { ControlAuction ctrlAuction = new ControlAuction(); ctrlAuction.DeleteAuction(auctionIdToDelete); MessageBox.Show("Auction with ID: #" + auctionIdToDelete + " was removed from database!"); } else { MessageBox.Show("The ID was not found - try again!"); } }
private void button2_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(TxtBoxId.Text)) { MessageBox.Show("Indtast Byd Pris!!!"); TxtBoxId.Select(); } else { string IdD = TxtBoxId.Text; int Id = Int32.Parse(IdD); ControlAuction aus = new ControlAuction(); aus.DeleteAuction(Id); TxtBoxId.Text = String.Empty; } }
//CREATE AUCTION private void btnAuction_Click(object sender, EventArgs e) { string result = cbResult.Text; string productName = txtProdName.Text; string productDescription = txtProdDescription.Text; bool payment = false; DateTime timeLeftDateAndTime = dtpDateTl.Value.Date.Add(dtpClockTl.Value.TimeOfDay); DateTime paymentDateAndTime = dtpDatePayD.Value.Date.Add(dtpClockPayD.Value.TimeOfDay); if (radioBtnAuction.Checked) { payment = true; } else if (rbutNotPayed.Checked) { payment = false; } else if (!radioBtnAuction.Checked && !rbutNotPayed.Checked) { MessageBox.Show("Please chose wheter it is payed!"); } bool inputIsOk = (!string.IsNullOrEmpty(result) && !string.IsNullOrEmpty(productName) && !string.IsNullOrEmpty(productDescription)); if (inputIsOk) { ControlAuction ctrlAuction = new ControlAuction(); ctrlAuction.AddAuction(timeLeftDateAndTime, payment, result, paymentDateAndTime, productName, productDescription); MessageBox.Show("Auction created!"); } else { MessageBox.Show("Auction not created! Try again."); } }
private void BtnCreateAuction_Click(object sender, EventArgs e) { string Title = TxtBoxTitle.Text; string Description = TxtBoxDescription.Text; string Category = comboBox1.Text; string CurrentPriceD = TxtBoxCurrentPrice.Text; string MaxPriceD = TxtBoxMaxPrice.Text; string BidD = TxtByd.Text; string EndDateD = dateTimePicker1.Text; string StatusD = TxtBoxStatus.Text; string IdD = textBoxId2.Text; if (string.IsNullOrWhiteSpace(TxtByd.Text)) { MessageBox.Show("Indtast Byd Pris!!!"); TxtByd.Select(); } else if (string.IsNullOrWhiteSpace(TxtBoxStatus.Text)) { MessageBox.Show("Indtast Status!!!"); TxtBoxStatus.Select(); } else if (string.IsNullOrWhiteSpace(TxtBoxTitle.Text)) { MessageBox.Show("Indtast titel!!!"); TxtBoxTitle.Select(); } else if (string.IsNullOrWhiteSpace(TxtBoxDescription.Text)) { MessageBox.Show("Indtast beskrivelse!!!"); TxtBoxDescription.Select(); } else if (string.IsNullOrWhiteSpace(comboBox1.Text)) { MessageBox.Show("Indtast katagori!!!"); comboBox1.Select(); } else if (string.IsNullOrWhiteSpace(TxtBoxCurrentPrice.Text)) { MessageBox.Show("Indtast start pris!!!"); TxtBoxCurrentPrice.Select(); } else if (string.IsNullOrWhiteSpace(TxtBoxMaxPrice.Text)) { MessageBox.Show("Indtast køb nu pris!!!"); TxtBoxMaxPrice.Select(); } else if (string.IsNullOrWhiteSpace(dateTimePicker1.Text)) { MessageBox.Show("Indtast s**t dato!!!"); dateTimePicker1.Select(); } else if (string.IsNullOrWhiteSpace(textBoxId2.Text)) { MessageBox.Show("Indtast et id!!!"); textBoxId2.Select(); } else { decimal Bid = decimal.Parse(BidD); decimal CurrentPrice = decimal.Parse(CurrentPriceD); decimal MaxPrice = decimal.Parse(MaxPriceD); int Status = int.Parse(StatusD); int Id = int.Parse(IdD); DateTime EndDate = DateTime.Parse(EndDateD); ControlAuction aus = new ControlAuction(); aus.EditAuction(Id, Bid, Status, CurrentPrice, MaxPrice, EndDate, Title, Description, Category); textBoxId2.Text = String.Empty; TxtBoxTitle.Text = String.Empty; TxtBoxDescription.Text = String.Empty; TxtBoxCurrentPrice.Text = String.Empty; TxtBoxStatus.Text = String.Empty; TxtBoxMaxPrice.Text = String.Empty; TxtByd.Text = String.Empty; dateTimePicker1.Text = String.Empty; comboBox1.Text = String.Empty; } }
private void button1_Click(object sender, EventArgs e) { ControlAuction aus = new ControlAuction(); dataGridView1.DataSource = aus.ViewAuction(); }
public List <Auction> GetAuctionAll() { ControlAuction ctrlAuction = new ControlAuction(); return(ctrlAuction.GetAllAuctions()); }
public void UpdateAuction(Auction auctionToUpdate) { ControlAuction ctrlAuction = new ControlAuction(); ctrlAuction.ModifyAuction(auctionToUpdate); }
public Auction GetAuctionById(int findAuctionId) { ControlAuction ctrlAuction = new ControlAuction(); return(ctrlAuction.GetAuctionById(findAuctionId)); }
public void DeleteAuction(int auctionId) { ControlAuction ctrlAuction = new ControlAuction(); ctrlAuction.DeleteAuction(auctionId); }
public bool AddAuction(Auction auctionToAdd) { ControlAuction ctrlAuction = new ControlAuction(); return(ctrlAuction.InsertAuction(auctionToAdd)); }