private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     RealEstateDataDataContext con = new RealEstateDataDataContext();
     List<Client> client = (from e1 in con.Clients
                             select e1).ToList();
     ClientGrid.ItemsSource = client;
 }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     RealEstateDataDataContext con = new RealEstateDataDataContext();
     List<Estate> estates = (from e1 in con.Estates
                             select e1).ToList();
     EstateGrid.ItemsSource = estates;
 }
 public static void AddEstate(Estate estate)
 {
     using (RealEstateDataDataContext conn = new RealEstateDataDataContext())
     {
         conn.Estates.InsertOnSubmit(estate);
         conn.SubmitChanges();
     }
 }
 public static void AddClient(Client client)
 {
     using (RealEstateDataDataContext conn = new RealEstateDataDataContext())
     {
         conn.Clients.InsertOnSubmit(client);
         conn.SubmitChanges();
     }
 }
 public static void AddAd(Ad ad)
 {
     using (RealEstateDataDataContext conn = new RealEstateDataDataContext())
     {
         conn.Ads.InsertOnSubmit(ad);
         conn.SubmitChanges();
     }
 }
 public static void AddTransaction(Transaction transaction)
 {
     using (RealEstateDataDataContext conn = new RealEstateDataDataContext())
     {
         conn.Transactions.InsertOnSubmit(transaction);
         conn.SubmitChanges();
     }
 }
        public ViewAds()
        {
            InitializeComponent();

            RealEstateDataDataContext con = new RealEstateDataDataContext();
            List<Ad> transaction = (from e1 in con.Ads
                                             select e1).ToList();
            AdGrid.ItemsSource = transaction;
        }
        public ViewTransaction()
        {
            InitializeComponent();

            RealEstateDataDataContext con = new RealEstateDataDataContext();
            List<Transaction> transaction = (from e1 in con.Transactions
                                    select e1).ToList();
            TransactionGrid.ItemsSource = transaction;
        }
 public static void DeleteClient(Client client)
 {
     using (RealEstateDataDataContext conn = new RealEstateDataDataContext())
     {
         Client cli = (from c in conn.Clients
                       where c.Id == client.Id
                       select c).FirstOrDefault();
         conn.Clients.DeleteOnSubmit(cli);
         conn.SubmitChanges();
     }
 }
        public AddAd()
        {
            InitializeComponent();

            RealEstateDataDataContext con = new RealEstateDataDataContext();
            List<Estate> client = (from e1 in con.Estates
                                   select e1).ToList();

            comboBox1.ItemsSource = client;
            comboBox1.DisplayMemberPath = "Name";
            comboBox1.SelectedValuePath = "Id";
        }
        public static void DeleteEstate(Estate estate)
        {
            using (RealEstateDataDataContext conn = new RealEstateDataDataContext())
            {
                Estate est = (from e1 in conn.Estates
                             where e1.Id == estate.Id
                             select e1).FirstOrDefault();
                conn.Estates.DeleteOnSubmit(est);
                conn.SubmitChanges();

            }
        }
        public static void UpdateClient(Client client)
        {
            using (RealEstateDataDataContext conn = new RealEstateDataDataContext())
            {
                Client cli = (from c in conn.Clients
                              where c.Id == client.Id
                              select c).FirstOrDefault();
                cli.FirstName = client.FirstName;
                cli.LastName = client.LastName;

                conn.SubmitChanges();
            }
        }
        public UpdateEstate(Estate estate)
        {
            InitializeComponent();

            RealEstateDataDataContext con = new RealEstateDataDataContext();
            List<Client> client = (from e1 in con.Clients
                                   select e1).ToList();

            comboBox1.ItemsSource = client;
            comboBox1.DisplayMemberPath = "FirstName";
            comboBox1.SelectedValuePath = "Id";

            this.estate = estate;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            RealEstateDataDataContext con = new RealEstateDataDataContext();
            List<Client> client = (from e1 in con.Clients
                                   select e1).ToList();

            EditClientt.ItemsSource = client;
            EditClientt.SelectionChanged += new SelectionChangedEventHandler(EditClienttSelectionChanged);
            EditClientt.IsReadOnly = true;

            show.IsEnabled      = false;
            delete.IsEnabled    = false;
            update.IsEnabled    = false;
        }
        public AddTransaction()
        {
            InitializeComponent();

            RealEstateDataDataContext con = new RealEstateDataDataContext();
            List<Client> client = (from e1 in con.Clients
                                   select e1).ToList();

            comboBox1.ItemsSource = client;
            comboBox1.DisplayMemberPath = "FirstName";
            comboBox1.SelectedValuePath = "Id";

            comboBox2.ItemsSource = client;
            comboBox2.DisplayMemberPath = "FirstName";
            comboBox2.SelectedValuePath = "Id";
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            nameLabel.Content = client.FirstName.Trim() + " " + client.LastName.Trim();

            RealEstateDataDataContext con = new RealEstateDataDataContext();
            List<Estate> estates = (from e1 in con.Estates
                                    where e1.Owner == client.Id
                                    select e1).ToList();
            EstateGrid.ItemsSource = estates;
            EstateGrid.IsReadOnly = true;

            int cl;
            cl = Convert.ToInt32(client.Id);
            count_moneyResult result = new count_moneyResult();
            var a = (count_moneyResult)con.count_money(cl).SingleOrDefault();
            nameLabe2.Content = a.Column1;
        }
        private void findFilteredEstates()
        {
            float fee;
            float.TryParse(Fee.Text, out fee);

            RealEstateDataDataContext con = new RealEstateDataDataContext();
            estates = (from e1 in con.Estates
                                    where e1.Fee >= fee
                                    select e1).ToList();
            EditEstatee.ItemsSource = estates;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            con = new RealEstateDataDataContext();
            estates = (from e1 in con.Estates
                                    select e1).ToList();
            EditEstatee.ItemsSource = estates;
            EditEstatee.SelectionChanged += new SelectionChangedEventHandler(EditEstateeSelectionChanged);
            EditEstatee.IsManipulationEnabled = false;
            EditEstatee.IsReadOnly = true;

            show.IsEnabled   = false;
            delete.IsEnabled = false;
            update.IsEnabled = false;
            //export.IsEnabled = false;
        }
        public static void UpdateEstate(Estate estate)
        {
            using (RealEstateDataDataContext conn = new RealEstateDataDataContext())
            {
                Estate est = (from e1 in conn.Estates
                              where e1.Id == estate.Id
                              select e1).FirstOrDefault();
                est.Name = estate.Name;
                est.Description = estate.Description;
                est.Fee = estate.Fee;
                est.Owner = estate.Owner;

                conn.SubmitChanges();
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            RealEstateDataDataContext con = new RealEstateDataDataContext();
            titleLabel.Content = estate.Name;
            nameField.Text = estate.Name;
            descriptionField.Text = estate.Description;
            feeField.Text = estate.Fee.ToString();

            owner = con.Clients.Single(c => c.Id == estate.Owner);
            ownerField.Text = (owner.FirstName+" "+owner.LastName);

            byte[] barrImg = (byte[])estate.Photo.ToArray();
            string strfn = Convert.ToString(DateTime.Now.ToFileTime());
            FileStream fs1 = new FileStream(strfn, FileMode.CreateNew, FileAccess.Write);
            fs1.Write(barrImg, 0, barrImg.Length);
            fs1.Flush();
            fs1.Close();
            ImageSourceConverter imgs = new ImageSourceConverter();
            image1.SetValue(System.Windows.Controls.Image.SourceProperty, imgs.ConvertFromString(strfn));
        }