示例#1
0
        private void Brisanje(object sender, RoutedEventArgs e)
        {
            // deleting an object by right - clicking on a specific plot in the datagrid

            Objekti brisi = (from o in Katastar.Objektis
                             where o.IDKatOpstine == int.Parse(((Parcele)datagrid.SelectedValue).IDKatOpstine.ToString()) && o.IDParcele == int.Parse(((Parcele)datagrid.SelectedValue).IDParcele.ToString())
                             select o).First();
            MessageBoxResult rez = MessageBox.Show("Da li ste sigurni da zelite da obrisete?", "Brisanje", MessageBoxButton.YesNo);

            if (rez == MessageBoxResult.Yes)
            {
                Katastar.Objektis.DeleteOnSubmit(brisi);

                try
                {
                    Katastar.SubmitChanges();
                    // Resetting dataagrids and fields that shows us unbooked objects for the selected municipality
                    puniDatagrid();
                    neuknjizeni();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ne moze da se obrise !" + ex);
                }
            }
        }
        private void BtnPotvrdi_Click(object sender, RoutedEventArgs e)
        {
            if (!String.IsNullOrEmpty(tbSifra.Text) && !String.IsNullOrEmpty(tbVlasnik.Text) && !String.IsNullOrEmpty(tbKvadratura.Text) && !String.IsNullOrEmpty(cbKatOpstina.Text) && lbParcela.SelectedValue != null)
            {
                try
                {
                    Objekti objekti = (from o in Katastar.Objektis
                                       where o.IDKatOpstine == int.Parse(((Parcele)lbParcela.SelectedValue).IDKatOpstine.ToString()) && o.IDParcele == int.Parse(((Parcele)lbParcela.SelectedValue).IDParcele.ToString())
                                       select o).First();
                    if (objekti != null)
                    {
                        MessageBox.Show("Na ovoj parceli ima objekta pokusaj na drugoj");
                    }
                }
                catch (Exception)
                {
                    Objekti nov = new Objekti()
                    {
                        IDObjekta    = (int.Parse)(tbSifra.Text),
                        Vlasnik      = tbVlasnik.Text,
                        Kvadratura   = int.Parse(tbKvadratura.Text),
                        Uknjizeno    = (bool)cbUknjizeno.IsChecked,
                        IDKatOpstine = (int.Parse)(((KatastarskeOpstine)cbKatOpstina.SelectedValue).IDKatOpstina.ToString()),
                        IDParcele    = (int.Parse)(((Parcele)lbParcela.SelectedValue).IDParcele.ToString()),
                    };


                    Katastar.Objektis.InsertOnSubmit(nov);



                    try
                    {
                        Katastar.SubmitChanges();
                        MessageBox.Show("Uspesan unos");
                        resetuj();
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            else
            {
                MessageBox.Show("Sva polja su obavezna!!!");
            }
        }
示例#3
0
 private void Datagrid_LoadingRowDetails(object sender, DataGridRowDetailsEventArgs e)
 {
     // view of objects located on the land that we clicked, there can be only one object on that land
     try
     {
         Objekti objekti = (from o in Katastar.Objektis
                            where o.IDKatOpstine == int.Parse(((Parcele)datagrid.SelectedValue).IDKatOpstine.ToString()) && o.IDParcele == int.Parse(((Parcele)datagrid.SelectedValue).IDParcele.ToString())
                            select o).First();
         if (objekti != null)
         {
             TextBox tb1 = e.DetailsElement.FindName("txtIDObjekta") as TextBox;
             tb1.Text = objekti.IDObjekta.ToString();
             TextBox tb2 = e.DetailsElement.FindName("txtVlasnik") as TextBox;
             tb2.Text = objekti.Vlasnik;
             TextBox tb3 = e.DetailsElement.FindName("txtKvadratura") as TextBox;
             tb3.Text = objekti.Kvadratura.ToString();
             CheckBox cb1 = e.DetailsElement.FindName("cbUknjizeno") as CheckBox;
             if (objekti.Uknjizeno == true)
             {
                 cb1.IsChecked = true;
             }
         }
     }
     catch (Exception)
     {
         TextBox tb1 = e.DetailsElement.FindName("txtIDObjekta") as TextBox;
         tb1.Text = "";
         TextBox tb2 = e.DetailsElement.FindName("txtVlasnik") as TextBox;
         tb2.Text = "";
         TextBox tb3 = e.DetailsElement.FindName("txtKvadratura") as TextBox;
         tb3.Text = "";
         CheckBox cb1 = e.DetailsElement.FindName("cbUknjizeno") as CheckBox;
         cb1.IsChecked = false;
         MessageBox.Show("Nema objekta na parceli");
     }
 }
 private void detach_Objektis(Objekti entity)
 {
     this.SendPropertyChanging();
     entity.Parcele = null;
 }
 private void attach_Objektis(Objekti entity)
 {
     this.SendPropertyChanging();
     entity.Parcele = this;
 }
 partial void DeleteObjekti(Objekti instance);
 partial void UpdateObjekti(Objekti instance);
 partial void InsertObjekti(Objekti instance);
 private void detach_Objektis(Objekti entity)
 {
     this.SendPropertyChanging();
     entity.KatastarskeOpstine = null;
 }