private void fetchTickets() { tickets = new Tickets(); DataTable salesTable = tickets.fetch(); binder.DataSource = salesTable; dgvTickets.DataSource = binder; dgvTickets.Columns[0].HeaderText = "ID"; dgvTickets.Columns[1].HeaderText = "Full Name"; dgvTickets.Columns[2].HeaderText = "Email"; dgvTickets.Columns[3].HeaderText = "Phone Number"; dgvTickets.Columns[4].Visible = false; dgvTickets.Columns[5].HeaderText = "Delivery Date"; dgvTickets.Columns[6].HeaderText = "Cost"; dgvTickets.Columns[7].HeaderText = "Description"; dgvTickets.Columns[8].HeaderText = "P. Model"; dgvTickets.Columns[9].HeaderText = "P. Brand"; dgvTickets.Columns[10].HeaderText = "Status"; dgvTickets.Columns[11].Visible = false; // Status ID }
private void btnCreateTicket_Click(object sender, EventArgs e) { string customerFullName; string customerEmail; string customerPhoneNumber; string ticketDescription = ""; int productBrandId; int productModelId; int productEstimatedCost; DateTime productEstimatedDate; try { // customer full name if (txtCustomerFullName.TextLength != 0) { customerFullName = txtCustomerFullName.Text; } else { throw new Exception("You must enter customer full name."); } // customer email if (txtCustomerEmail.TextLength != 0) { customerEmail = txtCustomerEmail.Text; } else { throw new Exception("You must enter customer email."); } // customer phone number if (txtCustomerPhoneNumber.Text.ToString().Length != 0) { if (txtCustomerPhoneNumber.MaskCompleted) { customerPhoneNumber = txtCustomerPhoneNumber.Text.ToString(); } else { throw new Exception("Invalid Phone Number"); } } else { throw new Exception("You must enter phone number."); } // product brand if (cmbProductBrand.SelectedIndex > -1) { productBrandId = ((KeyValuePair <int, string>)cmbProductBrand.SelectedItem).Key; } else { throw new Exception("You must select product brand."); } // product model if (cmbProductModel.SelectedIndex > -1) { productModelId = ((KeyValuePair <int, string>)cmbProductModel.SelectedItem).Key; } else { throw new Exception("You must select product brand."); } // product estimated cost if (txtProductCost.Text.ToString().Length != 0) { productEstimatedCost = Convert.ToInt32(txtProductCost.Text.ToString()); } else { throw new Exception("You must enter estimated product cost."); } // product estimated delivery date if (dateTimeProductDate.Value.ToString().Length != 0) { productEstimatedDate = dateTimeProductDate.Value; } else { throw new Exception("You must enter estimated product date."); } // ticket description if (rTxtTicketDescription.Text.ToString().Length != 0) { ticketDescription = rTxtTicketDescription.Text.ToString(); } string imageName = ""; if (FileName.Length != 0) { imageName = SaveImage(); } tickets = new Tickets(); Boolean result = tickets.create(customerFullName, customerEmail, customerPhoneNumber, imageName, productEstimatedDate, productEstimatedCost, productModelId, ticketDescription); if (result) { clearCreateTicketForm(); goTicketsPage(); } } catch (Exception error) { MessageBox.Show(error.Message.ToString(), "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error); } }