Exemplo n.º 1
0
 //Determina si el documento existe
 //params Objeto tipo documento(propiedad Nombre)
 public bool ExisteDocumento(string nombre, Proyecto p)
 {
     using (var db = new Model.Context())
     {
         try
         {
             List <Documento> lDocs = new List <Documento>();
             lDocs = db.DocumentoSet.
                     Where(b => b.ProyectoId.
                           Equals(p.Id) &&
                           b.Nombre.Equals(nombre))
                     .ToList();
             if (lDocs.Count > 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception e)
         {
             throw new Exception("Hubo un error en base de datos.", e);
         }
     }
 }
Exemplo n.º 2
0
 public Documento GetDocumentoUbicacion(string ubicacion)
 {
     using (var db = new Model.Context())
     {
         return(db.DocumentoSet.Single(b => b.Ubicacion.Equals(ubicacion)));
     }
 }
Exemplo n.º 3
0
        public void addProjToUser(ConectionData data, ScaffoldedModel models)
        {
            Model.Context context = new Model.Context();
            Model.User    user    = context.User.Where(c => c.LoginName == User.Identity.Name).FirstOrDefault();

            Model.Projects project = new Model.Projects();
            project.Owner            = user;
            project.OwnerId          = user.Id;
            project.ProjectName      = data.ProjName;
            project.ContextName      = data.ContextName;
            project.ConnectionString = data.ConnectionString;
            context.Add(project);
            foreach (var file in models.AdditionalFiles)
            {
                Model.Model model = new Model.Model();
                model.Project   = project;
                model.Projectid = project.Id;
                model.Model1    = file.Code;
                model.Filename  = Path.GetFileName(file.Path);
                context.Add(model);
            }
            Model.Model ContextModel = new Model.Model();
            ContextModel.Project   = project;
            ContextModel.Projectid = project.Id;
            ContextModel.Model1    = models.ContextFile.Code;
            ContextModel.Filename  = Path.GetFileName(models.ContextFile.Path);
            context.Add(ContextModel);
            context.SaveChanges();
            context.Dispose();
        }
Exemplo n.º 4
0
        // Function  to delect a result of simulation
        public void delectSimulaion(Simulation Sim)
        {
            using (var context = new Model.Context())
            {
                int SimId = Sim.Id;


                Cursor.Current = Cursors.WaitCursor;        // waiting animation cursor
                                                            //context.Database.Initialize(force: true);   // connect to db, it takes time
                context.Database.Initialize(force: true);   // connect to db, it takes time
                Model.Simulation SimToRemove = context.Simulations.Where(u => u.Id == SimId).First();
                if (SimToRemove != null)
                {
                    context.Simulations.Attach(SimToRemove);
                    context.Simulations.Remove(SimToRemove);
                    context.SaveChanges();
                    VMMain.UIMainForm.genMsgBox("Simulation deleted.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }


                Cursor.Current = Cursors.Arrow;             // get back to normal cursor

                SimulationForBinding = new List <Simulation>(Simulations);
                blSimulation         = new BindingList <Simulation>(SimulationForBinding);
                this.View.getLboxSim().DataSource    = blSimulation;
                this.View.getLboxSim().DisplayMember = "LbInformation";
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///  Speichert eine neue Tätigkeit im Model
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Model.TR_ARBEIT currentArbeit = this.gridArbeitsDaten.DataContext as Model.TR_ARBEIT;

            if (currentArbeit != null)
            {
                using (Model.Context context = new Model.Context())
                {
                    Model.TR_ARBEIT arbeitToSave;

                    if (!currentArbeit.isNew)
                    {
                        arbeitToSave = context.TR_ARBEIT.Where(q => q.ARB_ID == currentArbeit.ARB_ID).First();

                        if (arbeitToSave != null)
                        {
                            context.ApplyCurrentValues<Model.TR_ARBEIT>("TR_ARBEIT", currentArbeit);
                            context.SaveChanges();
                        }
                    }
                    else
                    {
                        context.AddToTR_ARBEIT(currentArbeit);
                        context.SaveChanges();
                    }
                }

                this.dataGridArbeitsDaten.DataContext = getArbeit();
            }
        }
Exemplo n.º 6
0
 public IActionResult ProjectLoad([FromBody] string ProjectID)
 {
     if (ProjectID != null)
     {
         var context   = new Model.Context();
         var projectdb = context.Projects.Where(c => c.Id == Convert.ToInt32(ProjectID)).FirstOrDefault();
         var Project   = new Tempproj();
         Project.Data = new ConectionData()
         {
             ConnectionString = projectdb.ConnectionString,
             ContextName      = projectdb.ContextName,
             ProjName         = projectdb.ProjectName
         };
         Project.Id           = projectdb.Id;
         Project.FileNames    = context.Model.Where(c => c.Projectid == projectdb.Id).Select(e => e.Filename).ToList();
         Project.Models       = context.Model.Where(c => c.Projectid == projectdb.Id).Select(e => e.Model1).ToList();
         Project.RandomEnding = randomEndingForFolder;
         context.Dispose();
         return(Ok(Project));
     }
     else
     {
         return(BadRequest());
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Speichert Änderungen eines Nutzerdatensatzes im Model
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Model.T_NUTZER currentNutzer = this.gridNutzerDaten.DataContext as Model.T_NUTZER;

            if (currentNutzer != null)
            {
                using (Model.Context context = new Model.Context())
                {
                    Model.T_NUTZER nutzerToSave;

                    if (!currentNutzer.isNew)
                    {
                        nutzerToSave = context.T_NUTZER.Where(q => q.NUT_ID == currentNutzer.NUT_ID).First();

                        if (nutzerToSave != null)
                        {
                            context.ApplyCurrentValues<Model.T_NUTZER>("T_NUTZER", currentNutzer);
                            context.SaveChanges();
                        }
                    }
                    else
                    {
                        context.AddToT_NUTZER(currentNutzer);
                        context.SaveChanges();
                    }
                }

                this.dataGridNutzerDaten.DataContext = getNutzer();
            }
        }
Exemplo n.º 8
0
 // Function to save the result of simulation
 public void saveSimulation(Model.Simulation simulation)
 {
     if (this.View.isSimulate == true)
     {
         using (var context = new Model.Context())
         {
             Cursor.Current = Cursors.WaitCursor;        // waiting animation cursor
             context.Database.Initialize(force: false);  // connect to db
             context.Simulations.Add(simulation);
             try
             {
                 context.SaveChanges();  // save change
                 VMMain.UIMainForm.genMsgBox("Simulation saved!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             catch (Exception e)
             {
                 VMMain.HandleException(e, this.VMMain.UIMainForm);
                 VMMain.UIMainForm.genMsgBox("Fail to save the simulation", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 Cursor.Current = Cursors.Arrow;             // get back to normal cursor
             }
         }
     }
     else
     {
         VMMain.UIMainForm.genMsgBox("You haven't simulated yet.", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public override void BeforeEachTest()
        {
            FieldInfo fieldInfo = typeof(ExampleC.InExampleC_1).GetField("is_spec_1",
                                                                         BindingFlags.Instance | BindingFlags.NonPublic);

            context = Target.FindContexts(fieldInfo);
        }
Exemplo n.º 10
0
        /**
         * Connect database and get Client list
         */
        public void getDataFromDb()
        {
            Cursor.Current = Cursors.WaitCursor;        // waiting animation cursor
            using (var context = new Model.Context())
            {
                context.Database.Initialize(force: false);  // connect to db, it takes time
                Clients = context.Clients
                          .Include(c => c.AccountList)      // get related entities
                          .Include(bpl => bpl.BoughtProductList)
                          .Include("BoughtProductList.Product")
                          .Include("BoughtProductList.Product.TimeInterests")
                          .Include("BoughtProductList.Product.SillInterests")
                          .ToList();
            }
            Cursor.Current = Cursors.Arrow;                  // get back to normal cursor

            ClientsForBinding  = new List <Client>(Clients); // clone for binding list
            ProductsForBinding = new List <BoughtProduct>();

            // bind list to listBoxes
            blClients  = new BindingList <Client>(ClientsForBinding);
            blProducts = new BindingList <BoughtProduct>(ProductsForBinding);

            View.getLBoxClient().DataSource     = blClients;
            View.getLBoxClient().DisplayMember  = "FullName";
            View.getLBoxProduct().DataSource    = blProducts;
            View.getLBoxProduct().DisplayMember = "Name";
        }
Exemplo n.º 11
0
            public void Execute(object parameter)
            {
                if (
                    MessageBox.Show(
                        "Ao realizar esta ação, todas as informações armazenadas sobre o conteúdo que você possui serão apagadas (entretanto todos os arquivos de vídeo que você possui permanecerá intacto). Você realmente deseja realizar esta ação?",
                        Properties.Settings.Default.AppName, MessageBoxButton.YesNo,
                        MessageBoxImage.Question) ==
                    MessageBoxResult.Yes)
                {
                    using (var db = new Model.Context())
                    {
                        db.Database.ExecuteSqlCommand(@"/*Disable Constraints & Triggers*/
exec sp_MSforeachtable 'IF OBJECT_ID(''?'') NOT IN (ISNULL(OBJECT_ID(''[dbo].[__MigrationHistory]''),0))
                                                   ALTER TABLE ? NOCHECK CONSTRAINT ALL'
exec sp_MSforeachtable 'IF OBJECT_ID(''?'') NOT IN (ISNULL(OBJECT_ID(''[dbo].[__MigrationHistory]''),0))
                                                   ALTER TABLE ? DISABLE TRIGGER ALL'

/*Perform delete operation on all table for cleanup*/
exec sp_MSforeachtable 'IF OBJECT_ID(''?'') NOT IN (ISNULL(OBJECT_ID(''[dbo].[__MigrationHistory]''),0))
                                                   DELETE ?'

/*Enable Constraints & Triggers again*/
exec sp_MSforeachtable 'IF OBJECT_ID(''?'') NOT IN (ISNULL(OBJECT_ID(''[dbo].[__MigrationHistory]''),0))
                                                   ALTER TABLE ? CHECK CONSTRAINT ALL'
exec sp_MSforeachtable 'IF OBJECT_ID(''?'') NOT IN (ISNULL(OBJECT_ID(''[dbo].[__MigrationHistory]''),0))
                                                   ALTER TABLE ? ENABLE TRIGGER ALL'

/*Reset Identity on tables with identity column*/
exec sp_MSforeachtable 'IF OBJECT_ID(''?'') NOT IN (ISNULL(OBJECT_ID(''[dbo].[__MigrationHistory]''),0))
                                                   AND OBJECTPROPERTY(OBJECT_ID(''?''), ''TableHasIdentity'') = 1 BEGIN DBCC CHECKIDENT (''?'',RESEED,0) END'");
                    }
                    frmMain.MainVM.AtualizarPosters(Enums.TipoConteudo.AnimeFilmeSérie);
                }
            }
 public override void BeforeEachTest()
 {
     descriptions = Target.FindContextsIn(typeof(Account).Assembly);
     context      =
         descriptions.Where(x => x.Name == "when transferring between two accounts").FirstOrDefault();
     context.ShouldNotBeNull();
 }
Exemplo n.º 13
0
        /// <summary>
        ///  Speichert ein neues Material im Model
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Model.TR_MATERIAL currentMaterial = this.gridMaterialDaten.DataContext as Model.TR_MATERIAL;

            if (currentMaterial != null)
            {
                using (Model.Context context = new Model.Context())
                {
                    Model.TR_MATERIAL materialToSave;

                    if (!currentMaterial.isNew)
                    {
                        materialToSave = context.TR_MATERIAL.Where(q => q.MAT_ID == currentMaterial.MAT_ID).First();

                        if (materialToSave != null)
                        {
                            context.ApplyCurrentValues<Model.TR_MATERIAL>("TR_MATERIAL", currentMaterial);
                            context.SaveChanges();
                        }
                    }
                    else
                    {
                        context.AddToTR_MATERIAL(currentMaterial);
                        context.SaveChanges();
                    }
                }

                this.dataGridMaterialDaten.DataContext = getMaterial();
            }
        }
Exemplo n.º 14
0
 public IActionResult EditModel([FromBody] EditModel tempproj)
 {
     Model.Context context = new Model.Context();
     Model.Model   model   = context.Model.Where(c => c.Projectid == tempproj.Id).Where(c => c.Filename == tempproj.Filename).FirstOrDefault();
     model.Model1 = tempproj.Model;
     context.SaveChanges();
     return(Ok());
 }
 private void SaveScript(Model.Script script)
 {
     using (var context = new Model.Context())
     {
         context.Scripts.Add(script);
         context.SaveChanges();
     }
 }
Exemplo n.º 16
0
 /// <summary>
 /// Gibt alle Nutzer zurück
 /// </summary>
 /// <returns>Liste der Nutzer</returns>
 private List<Model.T_NUTZER> getNutzer()
 {
     List<Model.T_NUTZER> nutzer = new List<Model.T_NUTZER>();
     using(Model.Context context = new Model.Context())
     {
         nutzer = context.T_NUTZER.ToList();
     }
     return nutzer;
 }
Exemplo n.º 17
0
        /**
         * Sell the selected product
         */
        public void SellProduct()
        {
            if (View.getLBoxClient().SelectedValue != null)
            {
                if (View.getLBoxProduct().SelectedValue != null)
                {
                    Client              selectedClt  = (Client)View.getLBoxClient().SelectedValue;
                    BoughtProduct       selectedPdt  = (BoughtProduct)View.getLBoxProduct().SelectedValue;
                    List <TimeInterest> TimeInterest = selectedPdt.Product.TimeInterests;
                    int     periode         = (int)(DateTime.Today.Date - selectedPdt.StartDate).TotalDays / 30;
                    Decimal TimeInterestPdt = Utils.FindTimeInterestSection(selectedPdt.StartDate, DateTime.Today, selectedPdt.Product.TimeInterests).Interest;
                    Decimal SillInterestPdt = Utils.FindSillInterestSection(selectedPdt.Price, selectedPdt.Product.SillInterests).Interest;
                    Decimal InterestRate    = 0;
                    Decimal InterestPdt     = 0;
                    if (TimeInterestPdt != 0)
                    {
                        InterestRate = (TimeInterestPdt + 100) * (SillInterestPdt + 100) / 100 - 100;
                        InterestPdt  = InterestRate / 100 * selectedPdt.Price;
                    }

                    DialogResult d = MessageBox.Show("You will have an interest rate : " + InterestRate.ToString("0.##") + " % and amount : " + InterestPdt.ToString("0.##") + ", are you sure to sell them now?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (d == DialogResult.Yes)
                    {
                        selectedClt.BoughtProductList.Remove(selectedPdt);
                        selectedClt.AccountList[0].Balance = selectedClt.AccountList[0].Balance + InterestPdt;
                        using (var context = new Model.Context())
                        {
                            Cursor.Current = Cursors.WaitCursor;                 // waiting animation cursor
                            context.Database.Initialize(force: false);           // connect to db
                            List <Client> clients = context.Clients
                                                    .Include(c => c.AccountList) // get related entities
                                                    .Include(bpl => bpl.BoughtProductList)
                                                    .Include("BoughtProductList.Product")
                                                    .ToList();
                            Client clientInDb = clients.Where(c => c.Id == selectedClt.Id).SingleOrDefault();

                            BoughtProduct productS = context.BoughtProducts.Where(c => c.Id == selectedPdt.Id).SingleOrDefault();
                            context.BoughtProducts.Remove(productS);
                            clientInDb.BoughtProductList.Remove(selectedPdt);
                            clientInDb.AccountList[0].Balance = clientInDb.AccountList[0].Balance + InterestPdt;
                            //Console.Write(context.Clients.Find(VMMain.Client.Id).FirstName);
                            context.SaveChanges();
                        }
                        this.loadClientDetail(selectedClt);
                    }
                }
                else
                {
                    this.VMMain.UIMainForm.genMsgBox("You haven't chosen a product yet.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                this.VMMain.UIMainForm.genMsgBox("You haven't chosen a client yet.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 18
0
 public Documento GetDocumento(string nombre, Proyecto p)
 {
     using (var db = new Model.Context())
     {
         return(db.DocumentoSet
                .Single(b => b.Nombre
                        .Equals(nombre) &&
                        b.ProyectoId.Equals(p.Id)));
     }
 }
Exemplo n.º 19
0
        /**
         * Functions for 3 buttons, add, modify and choose client
         */
        public bool addClient(string firstName, string lastName, string idCardNumber)
        {
            bool isSuccess = true;

            if (firstName == "" || lastName == "" || idCardNumber == "")
            {
                VMMain.UIMainForm.genMsgBox("Please enter all 3 textboxes.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                isSuccess = false;
            }
            else if (firstName.Length > 20 || lastName.Length > 20)
            {
                VMMain.UIMainForm.genMsgBox("First name and last name should less than 20 characters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                isSuccess = false;
            }
            else if (idCardNumber.Length > 20)
            {
                VMMain.UIMainForm.genMsgBox("ID card number should less than 20 characters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                isSuccess = false;
            }
            else
            {
                // creaete a client by input
                Client clt = new Client(firstName, lastName, idCardNumber);

                // create a default account
                Account acc = new Account();
                acc.Client      = clt;
                acc.Number      = DateTime.Now.ToString("yyyyMMddHHmmssf"); // use time of now , a unique number
                acc.status      = 1;
                acc.Balance     = 0M;
                clt.AccountList = new List <Account>();
                clt.AccountList.Add(acc);


                using (var context = new Model.Context())
                {
                    Cursor.Current = Cursors.WaitCursor;        // waiting animation cursor
                    context.Database.Initialize(force: false);  // connect to db
                    context.Clients.Add(clt);
                    try
                    {
                        context.SaveChanges();  // save change
                        getDataFromDb();        // refresh the list
                    }
                    catch (Exception e)
                    {
                        VMMain.HandleException(e, this.VMMain.UIMainForm);
                        isSuccess = false;
                    }
                    Cursor.Current = Cursors.Arrow;             // get back to normal cursor
                }
            }
            return(isSuccess);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Gibt alle Nutzer zurück
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">Liste aller Nutzer</param>
        private void dataGridNutzerDaten_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Model.T_NUTZER selectedItem = this.dataGridNutzerDaten.SelectedItem as Model.T_NUTZER;

            if (selectedItem != null)
            {
                using (Model.Context context = new Model.Context())
                {
                    this.gridNutzerDaten.DataContext = context.T_NUTZER.Where(q => q.NUT_ID == selectedItem.NUT_ID).First();
                }
            }
        }
Exemplo n.º 21
0
        public void generateChart()
        {
            Dictionary <DateTime, decimal> chartData = new Dictionary <DateTime, decimal>();

            // get list of bought product
            using (var context = new Model.Context())
            {
                Cursor.Current = Cursors.WaitCursor;        // waiting animation cursor
                context.Database.Initialize(force: false);  // connect to db

                /*List<BoughtProduct> bpList = context.BoughtProducts.ToList();
                 * foreach (BoughtProduct bp in bpList)
                 * {
                 *  chartData.Add(bp.BuyingDate, bp.Price);
                 * }*/

                DateTime last3Day = DateTime.Today.AddMonths(-3).AddDays(-3);
                foreach (DateTime day in EachDay(DateTime.Today.AddMonths(-3), DateTime.Today))
                {
                    List <BoughtProduct> bps = context.BoughtProducts
                                               .Where(bp => bp.BuyingDate > last3Day && bp.BuyingDate < day).ToList();
                    decimal sum = 0;
                    foreach (BoughtProduct bp in bps)
                    {
                        sum = sum + bp.Price;
                    }
                    chartData.Add(day, sum);
                    Console.WriteLine("day = " + day + "sum = " + sum);

                    last3Day = day;
                }


                Cursor.Current = Cursors.Arrow;             // get back to normal cursor
            }

            // sort dictionary by date
            // ref: http://stackoverflow.com/questions/289/how-do-you-sort-a-dictionary-by-value
            var sortedDict = from entry in chartData orderby entry.Key ascending select entry;
            // convert IEnumerable to dictionary
            // ref: http://stackoverflow.com/questions/3066182/convert-an-iorderedenumerablekeyvaluepairstring-int-into-a-dictionarystrin
            Dictionary <DateTime, decimal> sortedChartData = sortedDict.ToDictionary(pair => pair.Key, pair => pair.Value);

            System.Windows.Forms.DataVisualization.Charting.Chart chartTA = View.getChartTA();
            // binding data
            chartTA.Series[0].Points.DataBindXY(sortedChartData.Keys, sortedChartData.Values);

            // reset linetension property to make line not too smooth
            // ref: http://stackoverflow.com/questions/38080022/spline-chart-smooth-corners
            chartTA.Series[0].SetCustomProperty("LineTension", "0.3");
        }
Exemplo n.º 22
0
 // Agregar una etiqueta a la lista
 // params: objeto de la clase AccesoDatos.Model.Etiqueta
 public void AgregarEtiqueta(Model.Etiqueta etiqueta)
 {
     using (var db = new Model.Context())
     {
         try
         {
             db.EtiquetaSet.Add(etiqueta);
             db.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido agregar la etiqueta ", e);
         }
     }
 }
Exemplo n.º 23
0
 // Obtener una Palabra de la lista según filtro aplicado (propiedad nombre)
 // params: objeto de la clase AccesoDatos.Model.Palabra
 public Model.Palabra ListaPalabrasFiltro(Palabra palabra)
 {
     using (var db = new Model.Context())
     {
         try
         {
             var pal = db.PalabraSet.Single(b => b.Nombre.Equals(palabra.Nombre));
             return(pal);
         }
         catch (Exception e)
         {
             throw new Exception("No hay palabras guardados.", e);
         }
     }
 }
Exemplo n.º 24
0
 // Agregar un proyecto a la lista
 // params: objeto de la clase AccesoDatos.Model.Proyecto
 public void AgregarProyecto(Proyecto proyecto)
 {
     using (var db = new Model.Context())
     {
         try
         {
             db.ProyectoSet.Add(proyecto);
             db.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido agregar el proyecto ", e);
         }
     }
 }
Exemplo n.º 25
0
        public IActionResult Newproject(Project project)
        {
            var context    = new Model.Context();
            var newproject = new Model.Projects();

            newproject.ConnectionString = project.ConnectionString;
            newproject.ContextName      = project.Context;
            newproject.ProjectName      = project.Name;
            newproject.OwnerId          = context.User.Where(c => c.LoginName == User.Identity.Name).FirstOrDefault().Id;

            context.Add(newproject);

            context.SaveChanges();
            return(Ok());
        }
Exemplo n.º 26
0
 // Agregar un documento a la lista
 // params: objeto de la clase AccesoDatos.Model.Documento
 public void AgregarDocumento(Documento documento)
 {
     using (var db = new Model.Context())
     {
         try
         {
             db.DocumentoSet.Add(documento);
             db.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido agregar el documento", e);
         }
     }
 }
Exemplo n.º 27
0
 // Agregar una palabra a la lista
 // params: objeto de la clase AccesoDatos.Model.Palabra
 public void AgregarPalabra(Palabra palabra)
 {
     using (var db = new Model.Context())
     {
         try
         {
             db.PalabraSet.Add(palabra);
             db.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido agregar la palabra ", e);
         }
     }
 }
Exemplo n.º 28
0
 public Control
     (string rootPackageName
     , string projectName
     , string outputDirectory
     , Model.Context ctx = null
     )
 {
     _RootPackageNameField = rootPackageName;
     _ProjectNameField     = projectName;
     _OutputDirectoryField = outputDirectory;
     if (ctx != null)
     {
         Context = ctx;
     }
 }
Exemplo n.º 29
0
 // Elimina una cita de la lista
 // params: objeto de la clase AccesoDatos.Model.Cita
 public void EliminarCita(Model.Cita cita)
 {
     using (var db = new Model.Context())
     {
         try
         {
             var citaTmp = db.CitaSet.FirstOrDefault(x => x.Id == cita.Id);
             db.CitaSet.Remove(citaTmp);
             db.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido eliminar la cita ", e);
         }
     }
 }
Exemplo n.º 30
0
 // Elimina un proyecto de la lista
 // params: objeto de la clase AccesoDatos.Model.Proyecto
 public void EliminarProyecto(Proyecto proyecto)
 {
     using (var db = new Model.Context())
     {
         try
         {
             var proy = db.ProyectoSet.FirstOrDefault(x => x.Id == proyecto.Id);
             db.ProyectoSet.Remove(proy);
             db.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido eliminar el proyecto ", e);
         }
     }
 }
Exemplo n.º 31
0
 // Elimina un etiqueta de la lista
 // params: objeto de la clase AccesoDatos.Model.Etiqueta
 public void EliminarEtiqueta(Model.Etiqueta etiqueta)
 {
     using (var db = new Model.Context())
     {
         try
         {
             var etiq = db.EtiquetaSet.FirstOrDefault(x => x.Id == etiqueta.Id);
             db.EtiquetaSet.Remove(etiq);
             db.SaveChanges();
         }
         catch (Exception e)
         {
             throw new Exception("No se ha podido eliminar la etiqueta ", e);
         }
     }
 }
        public List <Model.Context> GetSelectedItems()
        {
            List <Model.Context> result = new List <Model.Context>();

            uint i = _resultView.SelectedRowIndexes.FirstIndex;

            while (i != NSRange.NSNotFoundRange.location)
            {
                Model.Context context = _results.Items[(int)i];

                result.Add(context);
                i = _resultView.SelectedRowIndexes.IndexGreaterThanIndex(i);
            }

            return(result);
        }
Exemplo n.º 33
0
        // Agregar una nube a la lista 
        // params: objeto de la clase AccesoDatos.Model.Nube
        public void AgregarNube(Model.Nube nube)
        {
            using (var db = new Model.Context())
            {
                try
                {
                    db.NubeSet.Add(nube);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    throw new Exception("No se ha podido agregar la nube ", e);
                }
            }

        }
Exemplo n.º 34
0
 public Model.Nube NubeFiltro(Documento d, Proyecto proyecto)
 {
     using (var db = new Model.Context())
     {
         ObservableCollection<Model.Nube> nubes = new ObservableCollection<Nube>();
         try
         {
             return db.NubeSet.Single(b => b.ProyectoId.Equals(proyecto.Id) && b.DocumentoId.Equals(d.Id));
             
         }
         catch (Exception e)
         {
             throw new Exception("No hay nubes guardadas.", e);
         }
     }
 }
Exemplo n.º 35
0
        public List <Model.Etiqueta> ListaEtiquetasList()
        {
            ObservableCollection <Etiqueta> etiquetas = new ObservableCollection <Etiqueta>();

            using (var db = new Model.Context())
            {
                try
                {
                    return(db.EtiquetaSet.OrderBy(b => b.Id).ToList());
                }
                catch (Exception e)
                {
                    throw new Exception("No hay etiquetas guardadas.", e);
                }
            }
        }
Exemplo n.º 36
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Model.T_REPARATUR currentReparatur = this.gridReparaturDaten.DataContext as Model.T_REPARATUR;

            List<Model.TZ_ARBEITLISTE> al = this.dataGridArbeit.DataContext as List<Model.TZ_ARBEITLISTE>;

            if (currentReparatur != null)
            {
                using (Model.Context context = new Model.Context())
                {
                    Model.T_REPARATUR reparaturToSave;

                    if (!currentReparatur.isNew)
                    {
                        reparaturToSave = context.T_REPARATUR.Where(q => q.REP_ID == currentReparatur.REP_ID).FirstOrDefault();

                        if (reparaturToSave != null)
                        {
                            foreach (Model.TZ_ARBEITLISTE arbl in al)
                            {
                                if (arbl.ABL_ID > 0)
                                {
                                    context.ApplyCurrentValues<Model.TZ_ARBEITLISTE>("TZ_ARBEITLISTE", arbl);
                                }
                                else
                                {
                                    context.AddToTZ_ARBEITLISTE(arbl);
                                }
                            }
                            context.ApplyCurrentValues<Model.T_REPARATUR>("T_REPARATUR", currentReparatur);
                            context.SaveChanges();
                        }
                    }
                    else
                    {
                        context.AddToT_REPARATUR(currentReparatur);
                        context.SaveChanges();
                    }
                }
                this.dataGridReparaturDaten.DataContext = getReparaturen();
            }
        }
Exemplo n.º 37
0
        /// <summary>
        /// Löscht ein Fahrzeug aus dem Model
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            Model.T_FAHRZEUG currentFahrzeug = this.gridFahrzeug.DataContext as Model.T_FAHRZEUG;

            if (currentFahrzeug != null)
            {
                using (Model.Context context = new Model.Context())
                {
                    Model.T_FAHRZEUG fahrzeugToDelete = context.T_FAHRZEUG.Where(q => q.FZG_ID == currentFahrzeug.FZG_ID).FirstOrDefault();

                    if (fahrzeugToDelete != null)
                    {
                        context.T_FAHRZEUG.DeleteObject(context.T_FAHRZEUG.Where(q => q.FZG_ID == fahrzeugToDelete.FZG_ID).FirstOrDefault());
                        context.SaveChanges();
                    }
                }
                this.gridFahrzeug.DataContext = new Model.T_FAHRZEUG();
                this.datagridFahrzeugDaten.DataContext = getFahrzeuge();
            }
        }
Exemplo n.º 38
0
        /// <summary>
        /// Löscht einen Nutzer aus dem Model
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            Model.T_NUTZER currentNutzer = this.gridNutzerDaten.DataContext as Model.T_NUTZER;

            if (currentNutzer != null)
            {
                using (Model.Context context = new Model.Context())
                {
                    Model.T_NUTZER nutzerToDelete = context.T_NUTZER.Where(q => q.NUT_ID == currentNutzer.NUT_ID).First();

                    if (nutzerToDelete != null)
                    {
                        context.T_NUTZER.DeleteObject(context.T_NUTZER.Where(q => q.NUT_ID == nutzerToDelete.NUT_ID).First());
                        context.SaveChanges();
                    }
                }
                this.gridNutzerDaten.DataContext = new Model.T_NUTZER();
                this.dataGridNutzerDaten.DataContext = getNutzer();
            }
        }
Exemplo n.º 39
0
        /// <summary>
        /// Löscht eine Tätigkeit aus dem Model
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            Model.TR_ARBEIT currentArbeit = this.gridArbeitsDaten.DataContext as Model.TR_ARBEIT;

            if (currentArbeit != null)
            {
                using (Model.Context context = new Model.Context())
                {
                    Model.TR_ARBEIT arbeitToDelete = context.TR_ARBEIT.Where(q => q.ARB_ID == currentArbeit.ARB_ID).First();

                    if (arbeitToDelete != null)
                    {
                        context.TR_ARBEIT.DeleteObject(context.TR_ARBEIT.Where(q => q.ARB_ID == arbeitToDelete.ARB_ID).First());
                        context.SaveChanges();
                    }
                }
                this.gridArbeitsDaten.DataContext = new Model.TR_MATERIAL();
                this.dataGridArbeitsDaten.DataContext = getArbeit();
            }
        }
Exemplo n.º 40
0
        /// <summary>
        /// Löscht ein Material aus dem Model
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            Model.TR_MATERIAL currentMaterial = this.gridMaterialDaten.DataContext as Model.TR_MATERIAL;

            if (currentMaterial != null)
            {
                using (Model.Context context = new Model.Context())
                {
                    Model.TR_MATERIAL materialToDelete = context.TR_MATERIAL.Where(q => q.MAT_ID == currentMaterial.MAT_ID).First();

                    if (materialToDelete != null)
                    {
                        context.TR_MATERIAL.DeleteObject(context.TR_MATERIAL.Where(q => q.MAT_ID == materialToDelete.MAT_ID).First());
                        context.SaveChanges();
                    }
                }
                this.gridMaterialDaten.DataContext = new Model.TR_MATERIAL();
                this.dataGridMaterialDaten.DataContext = getMaterial();
            }
        }
Exemplo n.º 41
0
        /// <summary>
        /// Gibt alle Fahrzeugmarken zurück
        /// </summary>
        /// <returns>Liste der Fahrzeugmarken</returns>
        private List<Model.TR_FAHRZEUGMARKE> getFahrzeugmarkeCombo()
        {
            List<Model.TR_FAHRZEUGMARKE> marken = new List<Model.TR_FAHRZEUGMARKE>();
            using (Model.Context context = new Model.Context())
            {
                marken.AddRange(context.TR_FAHRZEUGMARKE.Distinct().ToList());
            }

            return marken;
        }
Exemplo n.º 42
0
 /// <summary>
 /// Gibt alle Tätigkeiten zurück
 /// </summary>
 /// <returns>Liste der Tätigkeiten</returns>
 private List<Model.TR_ARBEIT> getArbeit()
 {
     List<Model.TR_ARBEIT> arbeit = new List<Model.TR_ARBEIT>();
     using(Model.Context context = new Model.Context())
     {
         arbeit = context.TR_ARBEIT.ToList();
     }
     return arbeit;
 }
Exemplo n.º 43
0
        /// <summary>
        /// Gibt alle Tätigkeiten zurück
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">Liste aller Tätigkeiten</param>
        private void dataGridArbeitsDaten_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Model.TR_ARBEIT selectedItem = this.dataGridArbeitsDaten.SelectedItem as Model.TR_ARBEIT;

            if (selectedItem != null)
            {
                using (Model.Context context = new Model.Context())
                {
                    this.gridArbeitsDaten.DataContext = context.TR_ARBEIT.Where(q => q.ARB_ID == selectedItem.ARB_ID).First();
                }
            }
        }
Exemplo n.º 44
0
        /// <summary>
        /// Liefert alle Reparaturen
        /// </summary>
        /// <returns>Reparaturenliste</returns>
        private List<Model.T_REPARATUR> getReparaturen()
        {
            List<Model.T_REPARATUR> reparaturen; // = new List<Model.T_FAHRZEUG>();
            using (Model.Context context = new Model.Context())
            {
                // Fahrzeuge holen
                reparaturen = context.T_REPARATUR.ToList();

                // ... deren Entitäten laden
                reparaturen.Where(q => q.T_FAHRZEUGReference != null).ToList().ForEach(q => q.T_FAHRZEUGReference.Load());
            }
            return reparaturen.ToList();
        }
Exemplo n.º 45
0
        /// <summary>
        /// Speichert Änderungen eines Fahrzeugdatensatzes im Model
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Model.T_FAHRZEUG currentFahrzeug = this.gridFahrzeug.DataContext as Model.T_FAHRZEUG;

            if (currentFahrzeug != null)
            {
                using (Model.Context context = new Model.Context())
                {
                    Model.T_FAHRZEUG fahrzeugToSave;

                    if (!currentFahrzeug.isNew)
                    {
                        fahrzeugToSave = context.T_FAHRZEUG.Where(q => q.FZG_ID == currentFahrzeug.FZG_ID).FirstOrDefault();

                        if (fahrzeugToSave != null)
                        {
                            context.ApplyCurrentValues<Model.T_FAHRZEUG>("T_FAHRZEUG", currentFahrzeug);
                            context.SaveChanges();
                        }
                    }
                    else
                    {
                        context.AddToT_FAHRZEUG(currentFahrzeug);
                        context.SaveChanges();
                    }
                }

                this.datagridFahrzeugDaten.DataContext = getFahrzeuge();
            }
        }
Exemplo n.º 46
0
 /// <summary>
 /// Gibt alles Material zurück
 /// </summary>
 /// <returns>Liste des Materials</returns>
 private List<Model.TR_MATERIAL> getMaterial()
 {
     List<Model.TR_MATERIAL> material = new List<Model.TR_MATERIAL>();
     using(Model.Context context = new Model.Context())
     {
         material = context.TR_MATERIAL.ToList();
     }
     return material;
 }
Exemplo n.º 47
0
        /// <summary>
        /// Gibt alle Fahrzeugarten zurück
        /// </summary>
        /// <returns>Liste der Fahrzeugarten</returns>
        private List<Model.TR_FAHRZEUGART> getFahrzeugarten()
        {
            List<Model.TR_FAHRZEUGART> arten = new List<Model.TR_FAHRZEUGART>();
            using (Model.Context context = new Model.Context())
            {
                arten.AddRange(context.TR_FAHRZEUGART.Distinct().ToList());
            }

            return arten;
        }
Exemplo n.º 48
0
        /// <summary>
        /// Lädt die Detailansicht anhand der Datagridauswahl
        /// </summary>
        /// <param name="sender">Senderobjekt Datagrid</param>
        /// <param name="e">Argument des Senderobjekts</param>
        private void gridFahrzeugDaten_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Model.T_FAHRZEUG selectedItem = this.datagridFahrzeugDaten.SelectedItem as Model.T_FAHRZEUG;

            if (selectedItem != null)
            {
                using (Model.Context context = new Model.Context())
                {
                    this.gridFahrzeug.DataContext = context.T_FAHRZEUG.Where(q => q.FZG_ID == selectedItem.FZG_ID).FirstOrDefault();
                }
            }
        }
Exemplo n.º 49
0
        /// <summary>
        /// Gibt alle Materialien zurück
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e">Liste aller Materialien</param>
        private void dataGridMaterialDaten_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Model.TR_MATERIAL selectedItem = this.dataGridMaterialDaten.SelectedItem as Model.TR_MATERIAL;

            if (selectedItem != null)
            {
                using (Model.Context context = new Model.Context())
                {
                    this.gridMaterialDaten.DataContext = context.TR_MATERIAL.Where(q => q.MAT_ID == selectedItem.MAT_ID).First();
                }
            }
        }
Exemplo n.º 50
0
        /// <summary>
        /// Gibt alle Fahrzeugnutzer zurück
        /// </summary>
        /// <returns>Liste der Fahrzeugnutzer</returns>
        private List<Model.T_NUTZER> getFahrzeugnutzerCombo()
        {
            List<Model.T_NUTZER> nutzer = new List<Model.T_NUTZER>();
            using (Model.Context context = new Model.Context())
            {
                nutzer.AddRange(context.T_NUTZER.ToList());
            }

            return nutzer;
        }
Exemplo n.º 51
0
        /// <summary>
        /// Gibt alle Fahrzeugtypen zurück
        /// </summary>
        /// <returns>Liste der Fahrzeugtypen</returns>
        private List<Model.TZ_FAHRZEUGTYP> getFahrzeugtypCombo()
        {
            List<Model.TZ_FAHRZEUGTYP> typen = new List<Model.TZ_FAHRZEUGTYP>();
            using (Model.Context context = new Model.Context())
            {
                typen.AddRange(context.TZ_FAHRZEUGTYP.Distinct().ToList());
            }

            return typen;
        }
Exemplo n.º 52
0
        /// <summary>
        /// Gibt alle Fahrzeuge zurück
        /// </summary>
        /// <returns>Liste der Fahrzeuge</returns>
        private List<Model.T_FAHRZEUG> getFahrzeuge()
        {
            List<Model.T_FAHRZEUG> fahrzeuge; // = new List<Model.T_FAHRZEUG>();
            using (Model.Context context = new Model.Context())
            {
                // Fahrzeuge holen
                fahrzeuge = context.T_FAHRZEUG.ToList();

                // ... deren Entitäten laden
                fahrzeuge.Where(q => q.TZ_FAHRZEUGTYPReference != null).ToList().ForEach(q => q.TZ_FAHRZEUGTYPReference.Load());
                fahrzeuge.Where(q => q.TR_FAHRZEUGARTReference != null).ToList().ForEach(q => q.TR_FAHRZEUGARTReference.Load());
                fahrzeuge.Where(q => q.T_NUTZERReference != null).ToList().ForEach(q => q.T_NUTZERReference.Load());
                fahrzeuge.Where(q => q.TZ_FAHRZEUGTYP != null && q.TZ_FAHRZEUGTYP.TR_FAHRZEUGMARKEReference != null).ToList()
                                .ForEach(q => q.TZ_FAHRZEUGTYP.TR_FAHRZEUGMARKEReference.Load());
            }
            return fahrzeuge.ToList();
        }
Exemplo n.º 53
0
        /// <summary>
        /// Liefert alle Arbeitslisten
        /// </summary>
        /// <returns>Arbeitsliste</returns>
        private List<Model.TZ_ARBEITLISTE> getArbeitliste()
        {
            List<Model.TZ_ARBEITLISTE> arbeitliste; // = new List<Model.T_FAHRZEUG>();
            using (Model.Context context = new Model.Context())
            {
                // Fahrzeuge holen
                arbeitliste = context.TZ_ARBEITLISTE.ToList();

                // Entitäten laden
                arbeitliste.Where(q => q.TR_ARBEITReference != null).ToList().ForEach(q => q.TR_ARBEITReference.Load());
            }
            return arbeitliste.ToList();
        }