Пример #1
0
        public static void AddService(User user, int EventID, string Address, string name, string url, string notes)
        {
            bool allow = false;
            if (user.isSystemAdmin || user.isEventOrganizer)
            {
                allow = true;
            }

            if (!allow)
            {
                if (!user.isAuthorized(EventController.GetEvent(EventID), EnumFunctions.Manage_Items))
                    throw new FaultException<SException>(new SException(),
                       new FaultReason("Invalid User, User Does Not Have Rights To Edit this Service!"));

            }

            try
            {
                DAL dalDataContext = new DAL();
                Table<Service> services = dalDataContext.services;

                Service creatingService = new Service(Address, name, url, notes);

                services.InsertOnSubmit(creatingService);
                services.Context.SubmitChanges();
                dalDataContext.SubmitChanges();
            }
            catch
            {
                throw new FaultException<SException>(new SException(),
                   new FaultReason("An Error occured While Adding New Service, Please Try Again!"));
            }
        }
 private void UpdateService(Service service)
 {
     try
     {
         var textRange = new TextRange(txtNote.Document.ContentStart, txtNote.Document.ContentEnd);
         ServiceContactHelper client = new ServiceContactHelper();
         if (event_ == null)
         {
             client.EditService(service.ServiceID, user, -1, txtAddress.Text.Trim(), txtName.Text.Trim(), txtWebsite.Text.Trim(), textRange.Text.Trim());
         }
         else
         {
             client.EditService(service.ServiceID, user, event_.EventID, txtAddress.Text.Trim(), txtName.Text.Trim(), txtWebsite.Text.Trim(), textRange.Text.Trim());
         }
         client.Close();
         MessageBox.Show("Operation Success");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void DeleteService(Service service)
 {
     try
     {
         ServiceContactHelper client = new ServiceContactHelper();
         client.DeleteService(user, service.ServiceID);
         client.Close();
         MessageBox.Show("Operation Success");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #4
0
        public frmAddEditReview(User u, frmServiceContactList f, Review r, Service s, Events e)
            : this()
        {
            created = false;
            this.servicefrm = f;
            this.user = u;
            this.review = r;
            this.service = s;
            this.event_ = e;

            this.txtServiceName.Text = service.Name;
            if (review == null)
            {
                //today
                this.txtReviewer.Text = user.Name;
                this.txtReviewDate.Text = DateTime.Now.ToShortDateString();
            }
            else
            {
                this.txtReviewer.Text = review.UserName;
                this.txtReviewDate.Text = review.ReviewDate.ToShortDateString();
            }

            //select mode

            if (review == null)
            {
                //add new
                btnDelete.IsEnabled = false;
                lblReport.Visibility = Visibility.Collapsed;
            }
            else
            {
                if (review.UserID == user.UserID)
                {
                    //edit
                    btnDelete.IsEnabled = true;
                    lblReport.Visibility = Visibility.Collapsed;
                }
                else
                {
                    //browse
                    if (!user.isSystemAdmin)
                    {

                        btnDelete.Visibility = Visibility.Visible;
                        btnSave.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        btnDelete.Visibility = Visibility.Collapsed;
                        btnSave.Visibility = Visibility.Collapsed;

                    }
                    rating.IsEnabled = false;
                    txtReviewDescription.IsReadOnly = true;

                    lblReport.Visibility = Visibility.Visible;
                }
                load_data(review);
            }
        }