private void Add_Click(object sender, RoutedEventArgs e)
        {
            int num;
            DateTime dat;

            if (Title.Text.Trim() == "")
                System.Windows.MessageBox.Show("Missing title");
            if (Description.Text.Trim() == "")
                System.Windows.MessageBox.Show("Missing description");
            else
            {
                Ad ad = new Ad();
                ad.Title = Title.Text.Trim();
                ad.Description = Description.Text.Trim();

                num = Convert.ToInt32(comboBox1.SelectedValue);
                ad.EstateId = num;

                dat = Convert.ToDateTime(datePicker1.Value);
                ad.StartDate = dat;

                dat = Convert.ToDateTime(datePicker2.Value);
                ad.EndDate = dat;

                if (File_Path.Text.Length > 0)
                {
                    FileStream photo = File.Open(Convert.ToString(File_Path.Text), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                    BinaryReader photoBinary = new BinaryReader(photo);
                    ad.Photo = photoBinary.ReadBytes((int)photo.Length);
                }
                Admin.AddAd(ad);
                System.Windows.MessageBox.Show(ad.Title + " was added");
                DialogResult = true;
            }
        }
Esempio n. 2
0
 public static void AddAd(Ad ad)
 {
     using (RealEstateDataDataContext conn = new RealEstateDataDataContext())
     {
         conn.Ads.InsertOnSubmit(ad);
         conn.SubmitChanges();
     }
 }
		private void detach_Ads(Ad entity)
		{
			this.SendPropertyChanging();
			entity.Estate = null;
		}
		private void attach_Ads(Ad entity)
		{
			this.SendPropertyChanging();
			entity.Estate = this;
		}
 partial void DeleteAd(Ad instance);
 partial void UpdateAd(Ad instance);
 partial void InsertAd(Ad instance);