private void btnAptSave_Click(object sender, RoutedEventArgs e)
 {
     var viewModel = new ECCAppointmentsViewModel();
     viewModel.AppointmentName = DisplayText.Text;
     viewModel.Date = Convert.ToDateTime(datetxtBlk.Text);
     StudioRepository.SaveAppointment(viewModel);
     var msgBox = new BookerStudioMessageBox("Saved successfully.", "The appointment is saved successfully!", GuestBookerMessageBoxButtons.Ok, IconType.Attention);
     msgBox.ShowDialog();
 }
        private void btnAptDelete_Click(object sender, RoutedEventArgs e)
        {
            var model = StudioRepository.GetAppointmentFromRepository(DisplayText.Text, Convert.ToDateTime(datetxtBlk.Text));
            foreach (var item in model)
            {
                StudioRepository.DeleteAppointment(item);
            }
            var msgBox = new BookerStudioMessageBox("Deleted successfully.", "The appointment was deleted successfully!", GuestBookerMessageBoxButtons.Ok, IconType.Attention);
            msgBox.ShowDialog();

        }
 private void Search_Click(object sender, RoutedEventArgs e)
 {
     if (txtName.Text == String.Empty && txtOrganization.Text == String.Empty)
     {
         var msgbox = new BookerStudioMessageBox("MandatoryFieldNotEnteredException.", "Please enter either one of the fields as either one is mandatory!", GuestBookerMessageBoxButtons.Ok, iconType: IconType.Attention);
         msgbox.ShowDialog();
     }
     else
     {
         var context = StudioRepository.GetContactDetails(txtOrganization.Text, txtName.Text);
         datagrdDelContact.ItemsSource = context;
     }
 }
        private void cmdSaveContact_Click(object sender, RoutedEventArgs e)
        {
            var viewModel = new ContactFormViewModel();
            viewModel.ContactName = txtName.Text;
            viewModel.Organization = txtOrganization.Text;
            viewModel.DateOfBirth = DateTime.Parse(txtBirthDate.Text);
            viewModel.Designation = txtDesignation.Text;
            viewModel.IsIndian = chkIndian.IsChecked.Value;
            viewModel.IsOther = chkOther.IsChecked.Value;
            viewModel.IsSpecial = chkIsSpecial.IsChecked.Value;
            viewModel.PhoneNumber = txtPhoneNumber.Text;
            viewModel.Address = txtAddress.Text;
            viewModel.Email = txtEmail.Text;
            StudioRepository.UpdateContact(viewModel);

            var msgbox = new BookerStudioMessageBox("Saved successfully", "The contact has been saved successfully!", GuestBookerMessageBoxButtons.Ok, IconType.Info);
            msgbox.ShowDialog();
            MainWindow.MainStatusBarMessage.Text = "The changes made were saved successfully.";
        }
 private void Delete_Click_1(object sender, RoutedEventArgs e)
 {
     if (datagrdDelContact.SelectedItem == null )
     {
         var msgbox = new BookerStudioMessageBox("Attention", "Please select a particular record to be deleted!", GuestBookerMessageBoxButtons.Ok, iconType: IconType.Attention);
         msgbox.ShowDialog();
     }
     else
     {
         ECCMaster model = (ECCMaster)datagrdDelContact.SelectedItem;
         StudioRepository.DeleteCustomer(model);
         var msgbox = new BookerStudioMessageBox("Deleted Customer.", "The customer was deleted successfully!", GuestBookerMessageBoxButtons.Ok, iconType: IconType.Attention);
         msgbox.ShowDialog();
         Search_Click(sender, e);
         MainWindow.MainStatusBarMessage.Text = "The customer was deleted successfully.";
     }
 }
 private void Search_Click(object sender, RoutedEventArgs e)
 {
     if (txtFromDate.Text != String.Empty && txtToDate.Text != String.Empty)
     {
         
         var customerList = StudioRepository.GetCustomersByDate(DateTime.Parse(txtFromDate.Text), DateTime.Parse(txtToDate.Text));
         currentDataContext = customerList.ToList();
         datagrdViewCustomer.ItemsSource = customerList;
     }
     else
     {
         var msgbox = new BookerStudioMessageBox("MandatoryFieldsNotEnteredException", "Please specify a valid \'from date\' and \'to date\' as they are mandatory!", GuestBookerMessageBoxButtons.Ok, iconType: IconType.Attention);
         msgbox.ShowDialog();
     }
 }
 private void Export_Click(object sender, RoutedEventArgs e)
 {
     if (currentDataContext == null)
     {
         var msgbox = new BookerStudioMessageBox("Attention", "Please specify records to be exported either by clicking on Refresh or Searching for specific customers!", GuestBookerMessageBoxButtons.Ok, iconType: IconType.Attention);
         msgbox.ShowDialog();
     }
     else
     {
         new GetGridValues().PrepareData(currentDataContext);
         MainWindow.MainStatusBarMessage.Text = "The data was exported successfully.";
     }
 }
 private void btnSaveContact_Click(object sender, RoutedEventArgs e)
 {
     var viewModel = new ContactFormViewModel();
     viewModel.ContactName = txtName.Text;
     viewModel.Organization = txtOrganization.Text;
     viewModel.Designation = txtDesignation.Text;
     viewModel.DateOfBirth = DateTime.Parse(txtBirthDate.Text != "" ? txtBirthDate.Text : "12/07/1990");
     viewModel.IsSpecial = Convert.ToBoolean(chkIsSpecial.IsChecked);
     viewModel.IsIndian = Convert.ToBoolean(chkIsIndian.IsChecked);
     viewModel.IsOther = Convert.ToBoolean(chkIsOther.IsChecked);
     viewModel.PhoneNumber = txtPhoneNumber.Text; ;
     viewModel.Address = txtAddress.Text;
     viewModel.Email = txtEmail.Text;
     var chkValidation = new Validations();
     var result = chkValidation.PerformMandatoryContactValidations(viewModel);
     if (result.Result == "Success")
     {
         StudioRepository.InsertContact(viewModel);
         var msgbox = new BookerStudioMessageBox("Added contact successfully", "A new contact was added successfully!", GuestBookerMessageBoxButtons.Ok, IconType.Attention);
         msgbox.ShowDialog();
         MainWindow.MainStatusBarMessage.Text = "A new contact was added successfully.";
     }
     else if (result.Result == "Failure")
     {
         var msgBox = new BookerStudioMessageBox(result.TypeOfException, result.Message, GuestBookerMessageBoxButtons.Ok, IconType.Attention);
         msgBox.ShowDialog();
     }
 }
 private void cmdSaveCustomer_Click(object sender, RoutedEventArgs e)
 {
         var viewModel = new CustomerFormViewModel();
         viewModel.Organization = txtOrganization.Text;
         viewModel.ContactName = txtName.Text;
         viewModel.NumOfPeople = Convert.ToInt32(txtNumOfPpl.Text!="" ? txtNumOfPpl.Text:"0");
         viewModel.Purpose = txtPurpose.Text;
         viewModel.PhoneNumber = txtPhoneNumber.Text;
         viewModel.FromDate = Convert.ToDateTime(txtFromDate.Text != "" ? txtFromDate.Text : DateTime.Now.ToString());
         viewModel.ToDate = Convert.ToDateTime(txtToDate.Text != "" ? txtToDate.Text : DateTime.Now.ToString());
         viewModel.IsActive = Convert.ToBoolean(chkIsActive.IsChecked);
         viewModel.IsSpecial = Convert.ToBoolean(chkIsSpecial.IsChecked);
         var validationCheck = new Validations();
         var result = validationCheck.PerformMandatoryCustomerValidations(viewModel);
         if (result.Result == "Success")
         {
             StudioRepository.InsertCustomer(viewModel);
             var msgBox = new BookerStudioMessageBox(result.Result, result.Message, GuestBookerMessageBoxButtons.Ok, IconType.Attention);
             msgBox.ShowDialog();
             MainWindow.MainStatusBarMessage.Text = "A new customer was added successfully!";
             new StartPage().GetCurrentCustomer();
         }
         else if (result.Result == "Failure")
         {
             var msgBox = new BookerStudioMessageBox(result.TypeOfException, result.Message, GuestBookerMessageBoxButtons.Ok, IconType.Attention);
             msgBox.ShowDialog();
         }
     }
        private void cmdSaveCustomer_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var viewModel = new CustomerFormViewModel();
                viewModel.ContactName = txtName.Text;
                viewModel.Organization = txtOrganization.Text;
                var culInfo = new System.Globalization.CultureInfo("en-US");
                viewModel.EstimatedCost = int.Parse(txtTotalAmount.Text);
                viewModel.MiscDetails = txtMiscDetail.Text;
                viewModel.FromDate = DateTime.Parse(txtFromDate.Text, culInfo);
                viewModel.IDProof = txtIDProof.Text;
                viewModel.IsActive = chkIsActive.IsChecked.Value;
                viewModel.IsSpecial = chkIsSpecial.IsChecked.Value;
                viewModel.NumOfPeople = int.Parse(txtNumOfPpl.Text);
                viewModel.PhoneNumber = txtPhoneNumber.Text;
                viewModel.Purpose = txtPurpose.Text;
                viewModel.RoomDetails = txtAccDetail.Text;
                viewModel.ToDate = DateTime.Parse(txtToDate.Text, culInfo);
                StudioRepository.UpdateCustomer(viewModel);

                var msgbox = new BookerStudioMessageBox("Saved successfully", "The customer has been saved successfully!", GuestBookerMessageBoxButtons.Ok, IconType.Attention);
                msgbox.ShowDialog();
                MainWindow.MainStatusBarMessage.Text = "The changes made were saved successfully.";
            }
            catch(Exception ex)
            {
                var msgbox = new BookerStudioMessageBox("Exception!",ex.Message, GuestBookerMessageBoxButtons.Ok, IconType.Attention);
                msgbox.ShowDialog();
            }
         }
 private void closeButton_Click(object sender, RoutedEventArgs e)
 {
     var msgBox = new BookerStudioMessageBox("Quit ECC Guest Booker Studio", "Are you sure you want to quit?", GuestBookerMessageBoxButtons.YesNo, IconType.Attention);
     msgBox.ShowDialog();
     if (msgBox.DialogResult == 0)
     {
         App.Current.Shutdown();
     }
     else
     {
         e.Handled = true;
     }
 }