public void DoWriteFirmannummer()
        {
            try
            {
                using (var db = new SteinbachEntities())
                {
                    var query = from f in db.firmen
                                where f.istFirma == 1
                                select new
                    {
                        f.KdNr,
                        f.name
                    };


                    foreach (var item in query)
                    {
                        var project = from p in db.projekte where p.firmenname == item.name select p;
                        foreach (var pro in project)
                        {
                            pro.FirmenNr = item.KdNr;
                        }
                    }

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ErrorMethods.GetExceptionMessageInfo(ex));
            }
        }
Exemple #2
0
        private bool SaveChanges()
        {
            try
            {
                //if (this.KalkulationDetailView.IsEditingItem)
                //{
                //    this.KalkulationDetailView.CommitEdit();
                //}
                //if (this.KalkulationDetailView.IsAddingNew)
                //{
                //    this.KalkulationDetailView.CommitNew();
                //}


                var om = this.db.ObjectStateManager.GetObjectStateEntries(System.Data.EntityState.Modified | System.Data.EntityState.Added);
                foreach (var o in om)
                {
                    if (o.Entity is kalkulationstabelle)
                    {
                        var p = (kalkulationstabelle)o.Entity;
                        if (p.EntityState == System.Data.EntityState.Added || p.EntityState == System.Data.EntityState.Modified)
                        {
                            if (this.txtProjektnummer.Text == string.Empty)
                            {
                                MessageBox.Show("Es muss eine Projektnummer eingegeben werden");
                                return(false);
                            }
                        }
                    }
                }

                db.SaveChanges();
                //db.Dispose();
                return(true);
            }

            catch (Exception ex)
            {
                MessageBox.Show(ErrorMethods.GetExceptionMessageInfo(ex));
                return(false);
            }
        }
Exemple #3
0
        //F:\VERKAUF\BR\Aufträge\2012\E-Teile\120158-S, Tender Donau\Auftrag\Kommerziell

        //BR 100031-S-E R1
        //100031-S-E Eilbek



        public CallRechnung(string RNr, DateTime Datum, string SchiffName, string Firma, string Projektnummer, string LandSchiff = "")
        {
            try
            {
                string        kurzname   = string.Empty;
                string        pfad       = string.Empty;
                string        pfadDetail = string.Empty;
                string        year       = Datum.ToString("yyyy");
                string        Folder1    = string.Empty;
                DirectoryInfo foRechnungen;

                using (DAL.SteinbachEntities db = new DAL.SteinbachEntities())
                {
                    kurzname = db.firmen.Where(n => n.name == Firma).Single().kurzname;
                    if (LandSchiff != "")
                    {
                        pfad    = db.config.Where(i => i.mkey == "PfadSIRechnungenJets").Single().value;
                        Folder1 = string.Format(@pfad, kurzname, year, LandSchiff);
                    }
                    else
                    {
                        pfad    = db.config.Where(i => i.mkey == "PfadSIRechnungen").Single().value;
                        Folder1 = string.Format(@pfad, kurzname, year);
                    }

                    pfadDetail = db.config.Where(i => i.mkey == "PfadSIRechnungenDetail").Single().value;
                }



                DirectoryInfo fo1 = new DirectoryInfo(Folder1);

                DirectoryInfo[] fo2 = fo1.GetDirectories(string.Format("*{0}*", Projektnummer));

                if (fo2.Count() == 1)
                {
                    var foProjekt = (DirectoryInfo)fo2[0];
                    //var foRechnungen = new DirectoryInfo(string.Format("{0}\\Auftrag\\Kommerziell", foProjekt.FullName));
                    foRechnungen = new DirectoryInfo(string.Format(@pfadDetail, foProjekt.FullName));

                    FileInfo[] files = foRechnungen.GetFiles(string.Format("{0}.*", RNr));
                    if (files.Count() == 1)
                    {
                        FileInfo fi = (FileInfo)files[0];
                        OpenRechnung(fi.FullName);
                    }
                    else if (files.Count() > 1)
                    {
                        FileInfo fi = (FileInfo)files[0];
                        ShowFiles(fi.FullName);
                    }
                    else if (files.Count() == 0)
                    {
                        ShowFiles(foRechnungen.FullName);
                    }
                }
                else
                {
                    ShowFiles(fo1.FullName);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ErrorMethods.GetExceptionMessageInfo(ex));
            }
        }