예제 #1
0
        private void CreateShowing_button_Click(object sender, RoutedEventArgs e)
        {
            if (Play_AddShowing_combo.Items.Count == 0)
            {
                MessageBox.Show("Please enter a play to search for");
            }
            else
            {
                KeyValuePair <int, string> test = (KeyValuePair <int, string>) this.Play_AddShowing_combo.SelectedValue;
                int playId = int.Parse((test.Key).ToString());

                dataSet = PlaysClass.getPlayDetailsById(playId);
                int playLength = int.Parse(dataSet.Tables[0].Rows[0]["Length"].ToString());

                string startTime       = StartTime_AddShowing_txt.Text;
                string timeToBeChecked = ValidationClass.TimeChecker(startTime);

                if (timeToBeChecked != null)
                {
                    MessageBox.Show(timeToBeChecked);
                }
                else
                {
                    //var startTimeCharArray = startTime.ToCharArray();
                    //string startHour = startTimeCharArray[0].ToString() + startTimeCharArray[1].ToString();
                    //string startMinutes = startTimeCharArray[3].ToString() + startTimeCharArray[4].ToString();

                    //DateTime startDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
                    //    int.Parse(startHour), int.Parse(startMinutes), 0);

                    //DateTime endDateTime = startDateTime.AddMinutes(playLength);
                    //string endTime = endDateTime.Hour + ":" + endDateTime.Minute;

                    DateTime?startDate = this.StartDate_AddShowing.SelectedDate;
                    DateTime?endDate   = this.EndDate_AddShowing.SelectedDate;
                    if (startDate > endDate)
                    {
                        MessageBox.Show("Start date must be earlier than End date");
                    }
                    else
                    {
                        string priceToBeChecked = UpperCircle_AddShowing_txt.Text.ToString();
                        priceToBeChecked = ValidationClass.FloatChecker(priceToBeChecked);
                        if (priceToBeChecked != null)
                        {
                            MessageBox.Show(priceToBeChecked);
                        }
                        else
                        {
                            float upperCirclePrice = float.Parse(this.UpperCircle_AddShowing_txt.Text.ToString());

                            priceToBeChecked = DressCircle_AddShowing_txt.Text.ToString();
                            priceToBeChecked = ValidationClass.FloatChecker(priceToBeChecked);
                            if (priceToBeChecked != null)
                            {
                                MessageBox.Show(priceToBeChecked);
                            }
                            else
                            {
                                float dressCirclePrice = float.Parse(this.DressCircle_AddShowing_txt.Text.ToString());

                                priceToBeChecked = Stalls_AddShowing_txt.Text.ToString();
                                priceToBeChecked = ValidationClass.FloatChecker(priceToBeChecked);
                                if (priceToBeChecked != null)
                                {
                                    MessageBox.Show(priceToBeChecked);
                                }
                                else
                                {
                                    float stallPrice = float.Parse(this.Stalls_AddShowing_txt.Text.ToString());
                                    if (this.StartDate_AddShowing.SelectedDate == null || this.EndDate_AddShowing.SelectedDate == null)
                                    {
                                        MessageBox.Show("please enter start and end date");
                                    }
                                    else
                                    {
                                        bool sqlQuerryState = ShowingsClass.makeShowings((DateTime)startDate, (DateTime)endDate, startTime, playId, upperCirclePrice, dressCirclePrice, stallPrice);
                                        if (sqlQuerryState == true)
                                        {
                                            MessageBox.Show("Showing added");
                                            fillDatePicker(this.SelectDate_EditDelShow);
                                        }
                                        else
                                        {
                                            MessageBox.Show("conclict with current showing");
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }