Exemplo n.º 1
0
        private void EditShowing_button_Click(object sender, RoutedEventArgs e)
        {
            if (SelectDate_EditDelShow.SelectedDate == null)
            {
                MessageBox.Show("Please select a date for the required showing");
            }
            else
            {
                int    showingId       = ShowingsClass.getShowingIdByDate(ShowingsClass.formatDateTimeToSqlLiteDateString((DateTime)SelectDate_EditDelShow.SelectedDate));
                string startTime       = this.TimeOfShowing_EditDeleteShowing_txt.Text;
                string timeToBeChecked = ValidationClass.TimeChecker(startTime);

                if (timeToBeChecked != null)
                {
                    MessageBox.Show(timeToBeChecked);
                }
                else
                {
                    double upperCirclePrice = double.Parse(this.UpperCircle_EditDelShow_txt.Text);
                    string priceToBeChecked = UpperCircle_EditDelShow_txt.Text.ToString();
                    priceToBeChecked = ValidationClass.FloatChecker(priceToBeChecked);
                    if (priceToBeChecked != null)
                    {
                        MessageBox.Show(priceToBeChecked);
                    }
                    else
                    {
                        double dressCirclePrice = double.Parse(this.DressCircle_EditDelShow_txt.Text);
                        priceToBeChecked = DressCircle_EditDelShow_txt.Text.ToString();
                        priceToBeChecked = ValidationClass.FloatChecker(priceToBeChecked);
                        if (priceToBeChecked != null)
                        {
                            MessageBox.Show(priceToBeChecked);
                        }
                        else
                        {
                            double stallPrice = double.Parse(this.Stalls_EditDelShow_txt.Text);
                            priceToBeChecked = Stalls_EditDelShow_txt.Text.ToString();
                            priceToBeChecked = ValidationClass.FloatChecker(priceToBeChecked);
                            if (priceToBeChecked != null)
                            {
                                MessageBox.Show(priceToBeChecked);
                            }
                            else
                            {
                                dataSet = ShowingsClass.getShowingByShowingId(showingId);
                                string unedditedSqlDateTimeString = dataSet.Tables[0].Rows[0]["Date"].ToString();
                                string newDateTimeSqlString       = ShowingsClass.replaceSqlDateTimeWithNewTime(unedditedSqlDateTimeString, startTime);
                                ShowingsClass.editShowingDetails(showingId, newDateTimeSqlString, upperCirclePrice, dressCirclePrice, stallPrice);
                                MessageBox.Show("Showing edited");
                            }
                        }
                    }
                }
            }
        }
        public void testEditShowing()
        {
            ShowingsClass.editShowingDetails(2, "2017-06-22 12:00", 7, 2, 1);
            dataSet = ShowingsClass.getShowingByShowingId(2);

            string actualShowingDate             = dataSet.Tables[0].Rows[0]["Date"].ToString();
            double actualShowingUpperCirclePrice = double.Parse(dataSet.Tables[0].Rows[0]["UpperCirclePrice"].ToString());
            double actualShowingDressCirclePrice = double.Parse(dataSet.Tables[0].Rows[0]["DressCirclePrice"].ToString());
            double actualShowingStallPrice       = double.Parse(dataSet.Tables[0].Rows[0]["StallsPrice"].ToString());

            string expectedShowingDate             = "2017-06-22 12:00";
            double expectedShowingUpperCirclePrice = 7;
            double expectedShowingDressCirclePrice = 2;
            double expectedShowingStallPrice       = 1;

            Assert.AreEqual(expectedShowingDate, actualShowingDate);
            Assert.AreEqual(expectedShowingUpperCirclePrice, actualShowingUpperCirclePrice);
            Assert.AreEqual(expectedShowingDressCirclePrice, actualShowingDressCirclePrice);
            Assert.AreEqual(expectedShowingStallPrice, actualShowingStallPrice);
        }