Inheritance: INotifyPropertyChanging, INotifyPropertyChanged
Ejemplo n.º 1
0
        public AgencyProfile(Agency agent, bool isAdmin, bool IsEdit)
        {
            InitializeComponent();

            if (isAdmin == false)
            {
                agencyRating_TB.Visibility = Visibility.Hidden;
                agencyRating_LBL.Visibility = Visibility.Hidden;
                save_BTN.Visibility = Visibility.Hidden;
                agencyDelete_BTN.Visibility = Visibility.Hidden;
            }

            if(isAdmin)

            this.agent = agent;

            this.agencyName_TB.Text = agent.Name;
            this.agencyAlternateName_TB.Text = agent.AlternateContact;
            this.agencyEmail_TB.Text = agent.Email;
            this.agencyCoordinatorName_TB.Text = agent.CoordinatorName;
            this.agencyRating_TB.Text = agent.Rating.ToString();
            this.agencyPhone_TB.Text = agent.Phone;
            this.agencyFax_TB.Text = agent.FaxNumber;
            this.agencyAddressCity_TB.Text = agent.City;
            this.agencyAddressState_TB.Text = agent.State;
            this.agencyAddressStreet_TB.Text = agent.StreetAddress;
            this.agencyAddressZipcode_TB.Text = agent.Zip;
            this.agencyWebsite_TB.Text = agent.WebsiteLink;
            this.description_TB.Text = agent.Description;
        }
        public AgencyProfile(Agency agent, bool isAdmin, bool IsEdit)
        {
            InitializeComponent();

            //Feature Set 1 Problem B
            //Only admins can rate, save and delete agencies.
            if (isAdmin)
            {
                agencyRating_TB.Visibility = Visibility.Visible;
                agencyRating_LBL.Visibility = Visibility.Visible;
                save_BTN.Visibility = Visibility.Visible;
                agencyDelete_BTN.Visibility = Visibility.Visible;
            }
            else
            {
                agencyRating_TB.Visibility = Visibility.Hidden;
                agencyRating_LBL.Visibility = Visibility.Hidden;
                save_BTN.Visibility = Visibility.Hidden;
                agencyDelete_BTN.Visibility = Visibility.Hidden;
            }

            this.agent = agent;

            this.agencyName_TB.Text = agent.Name;
            this.agencyAlternateName_TB.Text = agent.AlternateContact;
            this.agencyEmail_TB.Text = agent.Email;
            this.agencyCoordinatorName_TB.Text = agent.CoordinatorName;
            this.agencyRating_TB.Text = agent.Rating.ToString();
            this.agencyPhone_TB.Text = agent.Phone;
            this.agencyFax_TB.Text = agent.FaxNumber;
            this.agencyAddressCity_TB.Text = agent.City;
            this.agencyAddressState_TB.Text = agent.State;
            this.agencyAddressStreet_TB.Text = agent.StreetAddress;
            this.agencyAddressZipcode_TB.Text = agent.Zip;
            this.agencyWebsite_TB.Text = agent.WebsiteLink;
            this.description_TB.Text = agent.Description;
        }
        private void save_BTN_Click(object sender, RoutedEventArgs e)
        {
            if (dbMethods.CheckDatabaseConnection())
            {
                using (PubsDataContext db = new PubsDataContext())
                {
                    var CheckExists = (from s in db.Agencies
                                       where s.Name == agencyName_TB.Text
                                       select s);
                    //if the agency does not exists, application will create a new agency
                    try
                    {
                        if (CheckExists.Count() == 0)
                        {
                            agent.Name = agencyName_TB.Text;
                            agent.City = agencyAddressCity_TB.Text;
                            agent.CoordinatorName = agencyCoordinatorName_TB.Text;
                            agent.Description = description_TB.Text;
                            agent.Email = agencyEmail_TB.Text;
                            agent.FaxNumber = agencyFax_TB.Text;
                            agent.Phone = agencyPhone_TB.Text;
                            agent.Rating = Convert.ToInt32(agencyRating_TB.Text);
                            agent.State = agencyAddressState_TB.Text;
                            agent.StreetAddress = agencyAddressStreet_TB.Text;
                            agent.WebsiteLink = agencyWebsite_TB.Text;
                            agent.Zip = agencyAddressZipcode_TB.Text;
                            agent.AlternateContact = agencyAlternateName_TB.Text;

                            db.Agencies.InsertOnSubmit(agent);
                            db.SubmitChanges();
                        }
                        else
                        {
                            //save agency info && save as current agent
                            Agency agency = agent = (from s in db.Agencies
                                             where s.Name == agent.Name
                                             select s).Single();
                            agency.Name = agencyName_TB.Text;
                            agency.City = agencyAddressCity_TB.Text;
                            agency.CoordinatorName = agencyCoordinatorName_TB.Text;
                            agency.Description = description_TB.Text;
                            agency.Email = agencyEmail_TB.Text;
                            agency.FaxNumber = agencyFax_TB.Text;
                            agency.Phone = agencyPhone_TB.Text;
                            agency.Rating = Convert.ToInt32(agencyRating_TB.Text);
                            agency.State = agencyAddressState_TB.Text;
                            agency.StreetAddress = agencyAddressStreet_TB.Text;
                            agency.WebsiteLink = agencyWebsite_TB.Text;
                            agency.Zip = agencyAddressZipcode_TB.Text;
                            agency.AlternateContact = agencyAlternateName_TB.Text;

                            db.SubmitChanges();
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("SLApp apologies for the inconvenience, but at this time Rating must contain contain data.",
                                        "Save Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
        }
Ejemplo n.º 4
0
 partial void DeleteAgency(Agency instance);
Ejemplo n.º 5
0
 partial void UpdateAgency(Agency instance);
Ejemplo n.º 6
0
 partial void InsertAgency(Agency instance);