示例#1
0
        private void DeleteTicketButton_Click(object sender, EventArgs e)
        {
            int selectedIndex = ResultGrid.CurrentCell.RowIndex;
            int ticketId = Convert.ToInt32(ResultGrid.Rows[selectedIndex].Cells["TicketIdCol"].Value);

            if (MessageBox.Show("This will delete ticket #" + ticketId + ". Are you sure?", "Delete Ticket", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                try
                {
                    TicketRepository ticketRepo = new TicketRepository();
                    ticketRepo.DeleteTicketByTicketID(ticketId);

                    TicketAlterationRepository alterationRepo = new TicketAlterationRepository();
                    alterationRepo.DeleteAlterationsByTicketID(ticketId);
                    ResultGrid.Rows.RemoveAt(selectedIndex);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("There was an error. Please contact Jay with this message: " + ex.Message);
                }
                EnableButtonsBasedOnGrid();
            }
        }
示例#2
0
        //@return true if successful save
        private Boolean UpdateAlterationInDatabase()
        {
            try
            {
                TicketResource ticketResource = CollectFormDataForTicketResource();
                TicketRepository ticketRepo = new TicketRepository();
                ticketRepo.UpdateTicket(ticketResource);

                TicketAlterationResource alterationResource = CollectAlterationGridDataForAlterationResource();
                TicketAlterationRepository alterationRepo = new TicketAlterationRepository();
                alterationRepo.DeleteAndReinsertAlterations(alterationResource, ticketID);

                MessageBox.Show("Your alteration was successfully Updated.");
                NewTicketWithCustomerBttn.Enabled = true;

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error saving to the database. Please contact Jay with this message: " + ex.Message);
                return false;
            }
        }
示例#3
0
        //@return true if successful save
        private Boolean InsertAlterationIntoDatabase()
        {
            try
            {
                TicketResource ticketResource = CollectFormDataForTicketResource();
                TicketRepository ticketRepo = new TicketRepository();
                ticketID = ticketRepo.InsertNewTicket(ticketResource);

                TicketAlterationResource alterationResource = CollectAlterationGridDataForAlterationResource();
                TicketAlterationRepository alterationRepo = new TicketAlterationRepository();
                alterationRepo.InsertAlterations(alterationResource);

                TicketNumberLabel.Text = ticketID.ToString();
                TicketNumberLabel.Show();
                MessageBox.Show("Your alteration was successfully saved. The ticket ID is " + ticketID.ToString());
                isNewAlteration = false;
                NewTicketWithCustomerBttn.Enabled = true;

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error saving to the database. Please contact Jay with this message: " + ex.Message);
                return false;
            }
        }
示例#4
0
        private void OpenTicketButton_Click(object sender, EventArgs e)
        {
            int selectedIndex = ResultGrid.CurrentCell.RowIndex;

            int ticketId = Convert.ToInt32(ResultGrid.Rows[selectedIndex].Cells["TicketIdCol"].Value);
            try
            {
                TicketRepository ticketRepo = new TicketRepository();
                TicketResource ticketRes = ticketRepo.GetTicketByTicketID(ticketId);

                TicketAlterationRepository alterationRepo = new TicketAlterationRepository();
                TicketAlterationResource alterationRes = alterationRepo.GetAlterationsByTicketId(ticketId);

                AlterationForm alterationForm = new AlterationForm(ticketRes, alterationRes);
                alterationForm.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error. Please contact Jay with this message: " + ex.Message);
            }

            //TODO get Neil's feedback on what behavior he prefers
            //this.Close();
        }
示例#5
0
        private void hktStandardButton2_Click(object sender, EventArgs e)
        {
            TicketAlterationRepository ticketAltRepo = new TicketAlterationRepository();
            // List<TicketAlterationResourceItem> allAlterations = ticketAltRepo.GetAllAlterationItems();

            //foreach (TicketAlterationResourceItem alteration in allAlterations)
            //{
            //    string description = alteration.Description.Replace("'", "\\'");
            //    description = description.Replace("\"", "\\\"");

            //    Console.WriteLine(@"insert into Ticket_Alterations (ticket_alteration_id, ticket_id, quantity, description, price, taxable) values ("
            //    + alteration.TicketAlterationID + ","
            //    + alteration.TicketId + ","
            //    + alteration.Quantity + ",'"
            //    + description + "',"
            //    + alteration.Price + ","
            //    + alteration.Taxable + ");");
            //}
        }