/// <summary>
        /// Upload excel for flight schedule
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void UploadScheduleBtnClicked(object sender, EventArgs e)
        {
            if (RadAsyncUploadSchedule.UploadedFiles.Count == 0)
            {
                return;
            }

            UploadedFile attachment = RadAsyncUploadSchedule.UploadedFiles[0];

            bool validInput = InvalidUploadInput();

            if (!validInput)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "InValidUploadFile", "InValidUploadFile();", true);
                return;
            }

            int userId = Convert.ToInt32(Session["USERID"]);
            var user   = _accountManagement.GetUserById(userId);

            FlightScheduleEngine scheduleEngine = new FlightScheduleEngine();

            string notificationEmails = (System.Configuration.ConfigurationManager.AppSettings["NotificationEmails"]);

            var emails = notificationEmails.Split(new char[] { ';' });

            //validate before upload
            bool valid = ValidateSchedule(attachment, scheduleEngine, user, emails);

            if (!valid)
            {
                return;
            }

            //valid schedule, upload it
            scheduleEngine.UploadFlightSchedule(attachment.InputStream, chkClearFlightSchedule.Checked);

            var defaultMessage = EmailHelper.FlightScheduleUploadTemplate;

            EmailHelper.SendMail(user.Username, "*****@*****.**", "EMMA- Flight Schedule Upload - " + attachment.FileName, defaultMessage);

            foreach (var email in emails)
            {
                if (!string.IsNullOrEmpty(email))
                {
                    EmailHelper.SendMail(email, "*****@*****.**", "EMMA- Flight Schedule Upload - " + attachment.FileName, defaultMessage);
                }
            }

            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "UploadCompleted", "UploadCompleted();", true);
        }
        private void UploadSchedule()
        {
            try
            {
                this.InvokeEx(f => f.btnDownloadSchedule.Enabled = false);
                this.InvokeEx(f => f.groupBoxUpload.Enabled      = false);
                this.InvokeEx(f => f.lblStatus.Text = "In Progress, please wait!");


                bool valid = ValidateSchedule();

                if (!valid)
                {
                    this.InvokeEx(f => f.btnDownloadSchedule.Enabled = true);
                    this.InvokeEx(f => f.groupBoxUpload.Enabled      = true);
                    this.InvokeEx(f => f.lblStatus.Visible           = false);
                    return;
                }

                Stream stream = System.IO.File.OpenRead(txtBoxFileName.Text);
                flightScheduleEngine.UploadFlightSchedule(stream, true);

                MessageBox.Show("Upload completed successfully");
                this.InvokeEx(f => f.btnDownloadSchedule.Enabled = true);
                this.InvokeEx(f => f.groupBoxUpload.Enabled      = true);
                this.InvokeEx(f => f.lblStatus.Visible           = false);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Upload failed - please contact applaud");

                this.InvokeEx(f => f.btnDownloadSchedule.Enabled = true);
                this.InvokeEx(f => f.groupBoxUpload.Enabled      = true);
                this.InvokeEx(f => f.lblStatus.Visible           = false);
            }
        }