Ejemplo n.º 1
0
        public CharityInfo(Charity charity)
        {
            InitializeComponent();
            db.Charity.Load();

            byte[]       byteImage = charity.CharityLogo;
            MemoryStream ms        = new MemoryStream(byteImage);

            logo.Source           = BitmapFrame.Create(ms, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
            nameBlock.Text        = charity.CharityName;
            descriptionBlock.Text = charity.CharityDescription;
        }
Ejemplo n.º 2
0
        private void RegistrationConfirmation(object sender, RoutedEventArgs e)
        {
            Charity selectedCharity = (Charity)organisationBox.SelectedItem;

            string temp;

            if (optionA.IsChecked == true)
            {
                temp = "A";
            }
            else if (optionB.IsChecked == true)
            {
                temp = "B";
            }
            else
            {
                temp = "C";
            }


            var raceKit = db.RaceKitOption
                          .Where(r => r.RaceKitOptionId == temp)
                          .FirstOrDefault();

            Charity charity = db.Charity
                              .Where(c => c.CharityName == selectedCharity.CharityName)
                              .FirstOrDefault();

            var runner = db.Runner
                         .Where(r => r.RunnerId == CurrentUser.RunnerId)
                         .FirstOrDefault();

            Registration user = new Registration()
            {
                RunnerId             = runner.RunnerId,
                RegistrationDateTime = DateTime.Now,
                RegistrationStatusId = 4,
                RaceKitOptionId      = raceKit.RaceKitOptionId,
                Cost              = raceKit.Cost,
                CharityId         = charity.CharityId,
                SponsorshipTarget = Convert.ToDecimal(donatBox.Text)
            };

            db.Registration.Add(user);
            db.SaveChanges();

            Manager.MainFrame.Navigate(new RegistrationConfirmation());
        }
Ejemplo n.º 3
0
        private void CharityInfo_open(object sender, RoutedEventArgs e)
        {
            Charity charity = (Charity)charityComboBox.SelectedItem;

            new CharityInfo(charity).ShowDialog();
        }
Ejemplo n.º 4
0
        private void OrganisationInfo(object sender, RoutedEventArgs e)
        {
            Charity charity = (Charity)organisationBox.SelectedItem; //передача выбранного объекта на форму CharityInfo

            new CharityInfo(charity).ShowDialog();
        }
Ejemplo n.º 5
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            #region Проверка заполнения полей

            if (TxtName.Text == "" || TxtName.Text == " ")
            {
                MessageBox.Show("Заполните наименование организации");
                return;
            }
            if (TxtDesc.Text == "" || TxtDesc.Text == " ")
            {
                MessageBox.Show("Заполните описание организации");
                return;
            }
            if (TxtSource.Text == "")
            {
                MessageBox.Show("Установите логотип организации");
                return;
            }

            #endregion

            #region Если создаем организацию

            if (LocalStorage.CharityClass.CharityId == "" || LocalStorage.CharityClass.CharityId == null || LocalStorage.CharityClass.CharityId == " ")
            {
                Charity charity = new Charity();
                charity.CharityName        = TxtName.Text;
                charity.CharityDescription = TxtDesc.Text;
                string[] fileName = TxtSource.Text.Split('\\');
                string   way      = Assembly.GetExecutingAssembly().Location.Replace("bin\\Debug\\Marathon.exe", "CharityLogos\\" + fileName[fileName.Length - 1]);
                File.Copy(TxtSource.Text, way, true);
                charity.CharityLogo = fileName[fileName.Length - 1];
                try
                {
                    using (var db = new MarathonDBEntities1())
                    {
                        db.Charity.Add(charity);
                        db.SaveChanges();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            #endregion

            #region Если редачим существующую организацию

            else
            {
                try
                {
                    using (var db = new MarathonDBEntities1())
                    {
                        var charityOrg = db.Charity.FirstOrDefault(c => c.CharityId.ToString() == LocalStorage.CharityClass.CharityId);
                        charityOrg.CharityName        = TxtName.Text;
                        charityOrg.CharityDescription = TxtDesc.Text;
                        charityOrg.CharityLogo        = LocalStorage.CharityClass.CharityLogo.Replace("CharityLogos/", "");
                        db.SaveChanges();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            #endregion
            MessageBox.Show("Изменения внесены успешно!");
        }