private void CreateCalk()
        {
            var query = from k in db.kalkulationstabellen where k.id == 794 select k;
            var calc  = query.FirstOrDefault();

            kalkulationstabelle_detail det = db.CreateObject <kalkulationstabelle_detail>();

            det.created                = DateTime.Now;
            det.artikelnr              = "1140";
            det.beschreibung           = "Keine";
            det.einheit                = "Stück";
            det.einzelpreis            = 6625;
            det.epnok                  = 0;
            det.idx                    = 4;
            det.menge                  = 13;
            det.id_kalkulationstabelle = 794;
            db.AddTokalkulationstabelle_details(det);
            db.SaveChanges();
        }
Esempio n. 2
0
 void KalkulationView_CurrentChanged(object sender, EventArgs e)
 {
     CurrDetails = (kalkulationstabelle_detail)KalkulationDetailView.CurrentItem;
 }
        void PopulateGrid()
        {
            int[]    widths   = { 20, 20, 30, 60, 80, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60 };
            string[] headers  = { "Id", "Pos.", "Menge", "Einheit", "Beschreibung", "Artikel Nr.", "EP NOK", "Umrechn. €", "Summe Pos.", "Aufschlag", "Einzelpreis", "Gesamt alle Pos", "% von Gesamt", "Anteil Transport", "SI EInzel inl. Transp.", "Rundumgspreis", "Gesamt Angebot" };
            string[] surpress = { "kalkulationstabelle", "created", "kalkulationstabelle", "kalkulationstabelleReference", "SummePosition", "EntityState", "EntityKey", "id_kalkulationstabelle" };

            _flex.ItemsSource = null;
            _flex.Rows.Clear();
            _flex.Columns.Clear();
            var neu         = new kalkulationstabelle_detail();
            var detailQuery = from d in db.kalkulationstabelle_details where d.id_kalkulationstabelle == 794 select d;
            int rows        = detailQuery.Count();



            using (_flex.Rows.DeferNotifications())
                using (_flex.Columns.DeferNotifications())
                {
                    while (_flex.Columns.Count <= headers.Count())
                    {
                        _flex.Columns.Add(new Column());
                    }
                    while (_flex.Rows.Count < rows + 1)
                    {
                        _flex.Rows.Add(new Row());
                    }
                }
            int    z         = 1;
            int    s         = 0;
            bool   bSurpress = false;
            object xx;



            for (int i = 0; i < headers.Count(); i++)
            {
                _flex[0, i]            = headers[i];
                _flex.Columns[i].Width = new System.Windows.GridLength((double)widths[i]);
            }


            PropertyInfo[] cols = null;
            foreach (var c in detailQuery)
            {
                s    = 0;
                cols = c.GetType().GetProperties();

                foreach (PropertyInfo pi in cols)
                {
                    bSurpress = false;
                    // Spaltentyp:
                    Type colType = pi.PropertyType;

                    if (colType.IsGenericType &&
                        colType.GetGenericTypeDefinition() == typeof(Nullable <>))
                    {
                        colType = colType.GetGenericArguments()[0];
                    }


                    foreach (var item in surpress)
                    {
                        if (pi.Name == item)
                        {
                            bSurpress = true;
                            break;
                        }
                    }
                    if (bSurpress == false)
                    {
                        xx          = pi.GetValue(c, null) == null ? DBNull.Value : pi.GetValue(c, null);
                        _flex[z, s] = xx.ToString();
                        s++;
                    }
                }
                s = 0;
                z++;
            }
        }