public static void AddMealProduct(Nullable<int> idMeal, string name, Nullable<long> quant, int id)
 {
     using (Model1Container db = new Model1Container())
     {
         Nullable<int> prodId;
         if (name!=null)
         {
             prodId = (from prods in db.Product
                           where prods.Name.Equals(name)
                           select prods.ProductPK).FirstOrDefault();
         }
         else
             prodId = null;
         if (id == 0)
         {
             db.MealProducts.Add(new MealProducts()
             {
                 MealFK = idMeal,
                 ProductFK = prodId,
                 Quantity = quant
             });
             db.SaveChanges();
         }
         else
         {
             MealProducts mp = db.MealProducts.Where(c => c.MealProducts1 == id).FirstOrDefault();
             mp.MealFK = idMeal;
             mp.ProductFK = prodId;
             mp.Quantity = quant;
             db.SaveChanges();
         }
     }
 }
        public ProductSearched(ProductsSet product)
        {
            InitializeComponent();

            _product = product;
            _dataDC = ModelSingleton.getDataDC;

            product.Descripcion = "";

            cbProducto.ItemsSource = _dataDC.ProductsSet.Select(S => S.Producto).Distinct().ToList();
            cbModelo.ItemsSource = _dataDC.ProductsSet.Select(S => S.Modelo).Distinct().ToList();
            cbMarca.ItemsSource = _dataDC.ProductsSet.Select(S => S.Marca).Distinct().ToList();
            this.DataContext = product;

            for ( int añoindex = 1900; añoindex < 2025; añoindex++)
            {

                cbYear.Items.Add(añoindex);
            }
            if (product.Año != null){
                cbYear.SelectedItem = product.Año;
            }
            _product.PrivateDescription = "";
            _product.Kilometer = 0;
            _product.Hours = 0;
        }
Exemple #3
0
        public Index()
        {
            this.Dispatcher.UnhandledException += OnDispatcherUnhandledException;
            InitializeComponent();
             RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;

             Product_List.LWidth = 500;
             Product_List.LHeight = 400;
             Provider_List.LWidth = 500;
             Provider_List.LHeight = 400;
             Client_List.LWidth = 500;
             Client_List.LHeight = 400;
             _dataDC = ModelSingleton.getDataDC;
             startrutines.Database_Backup();
             ProductSearch = new ObservableProductSearch(_dataDC);
             UpdateNotificationList();

             string[] todos = new string[] { "Todos" };

             cbProducto.ItemsSource = _dataDC.ProductsSet.Select(S => S.Producto).Distinct().Union(todos).ToList();
             cbMarca.ItemsSource = _dataDC.ProductsSet.Select(S => S.Marca).Distinct().Union(todos).ToList();
             cbModelo.ItemsSource = _dataDC.ProductsSet.Select(S => S.Modelo).Distinct().Union(todos).ToList();
             int añoindex;
             for (añoindex = 1900; añoindex < 2025; añoindex++)
             {

                 cbfromyear.Items.Add(añoindex);
             }
        }
 public List<ExtendedInformation> SelectAllCountries()
 {
     using (var con = new Model1Container())
     {
         return (from info in con.ExtendedInformationSet
                 select info).ToList();
     }
 }
 public static String[] SelectAllUsers()
 {
     using (var dbContext = new Model1Container()) {
         var users = (from log in dbContext.Logs
                      select log.OwnerName).Distinct();
         return users.ToArray();
     }
 }
 private void Insert()
 {
     using (var con = new Model1Container())
     {
         con.ExtendedInformationSet.Add(_information);
         con.SaveChanges();
     }
 }
        public List<TravelOffer> SelectAllOffers()
        {
            using (var con = new Model1Container())
            {

                return (from offer in con.TravelOfferSet.Include("Category")
                        select offer).ToList();
            }
        }
 public static String[] SelectAllJobs(String user)
 {
     using (var dbContext = new Model1Container()) {
         var jobs = (from log in dbContext.Logs
                     where log.OwnerName == user
                     select log.JobName).Distinct();
         return jobs.ToArray();
     }
 }
 public static String[] SelectAllJobs(String user, DateTime fromDate, DateTime toDate)
 {
     using (var dbContext = new Model1Container()) {
         var jobs = (from log in dbContext.Logs
                     where log.OwnerName == user && log.Action == "submitted" && log.Time > fromDate && log.Time < toDate
                     select log.JobName).Distinct();
         return jobs.ToArray();
     }
 }
        public DragDropImage(string Product)
        {
            InitializeComponent();
            _productID = Product;
            _dataDC = new Model1Container();
            imagelist = new ObservableProductImage(_dataDC, _productID);

            ImageList.ItemsSource = imagelist;
        }
 public IList<account> GetAccounts()
 {
     if (!cachedList.Any())
     {
         using (var context = new Model1Container(sqlConn))
             cachedList= context.account.Where(acnt => acnt.customer_id != 1 && acnt.status == "A").ToList();
     }
     return cachedList;
 }
 public static int AddMenu(DateTime dateSt, DateTime dateEn)
 {
     using (Model1Container db = new Model1Container())
     {
         Menu newM = new Menu() { DateStart = dateSt, DateFinish = dateEn };
         db.Menu.Add(newM);
         db.SaveChanges();
         AddMenuDay((Nullable<int>)newM.MenuPK, dateSt);
         return newM.MenuPK;
     }
 }
 private void Update()
 {
     using (var con = new Model1Container())
     {
         var infoEntity =
             con.ExtendedInformationSet.Single(
                 o => o.ExtendetInformationId == _information.ExtendetInformationId);
                 con.Entry(infoEntity).CurrentValues.SetValues(_information);
         con.SaveChanges();
     }
 }
        public UCProviderList()
        {
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                _dataDC = ModelSingleton.getDataDC;
                InitializeComponent();
                lpr = new ObservableProveedor(_dataDC);

                this.DataContext = lpr;
                providerSet1ViewSource.ItemsSource = lpr;
            }
        }
Exemple #15
0
        private static void Main(string[] args)
        {
            var text =
                System.IO.File.ReadAllText(
                    @"C:\Users\jmclaughlin\Documents\PipeDelimitedImportProject\PipeDelimitedFile.dat");

            using (var context = new Model1Container())
            {
                NoEnumStrategy(text, context);
                context.SaveChanges();
            }
        }
Exemple #16
0
 static void NoInitializerStrategy(string text, Model1Container context)
 {
     foreach (var fileImportLine in text.Split('\r'))
     {
         var fields = fileImportLine.Split('|');
         var fileImport = new FileImports();
         fileImport.email = fields[(int)TextFields.Email];
         fileImport.firstName = fields[(int)TextFields.FirstName];
         fileImport.lastName = fields[(int)TextFields.LastName];
         fileImport.phoneNumber = fields[(int)TextFields.PhoneNumber];
         context.FileImports1.Add(fileImport);
     }
 }
Exemple #17
0
 static void NoEnumStrategy(string text, Model1Container context)
 {
     foreach (var fileImportLine in text.Split('\r'))
     {
         var fields = fileImportLine.Split('|');
         var fileImport = new FileImports();
         fileImport.email = fields[3];
         fileImport.firstName = fields[0];
         fileImport.lastName = fields[1];
         fileImport.phoneNumber = fields[2];
         context.FileImports1.Add(fileImport);
     }
 }
        public static void LogAction(Job job, String action)
        {
            using (var dbContext = new Model1Container()) {
                Log log = new Log();
                log.Action = action;
                log.JobName = job.Name;
                log.OwnerName = job.Owner;
                log.Time = DateTime.Now;

                dbContext.Logs.AddObject(log);
                dbContext.SaveChanges();
            }
        }
Exemple #19
0
 static void LinqStrategy(string text, Model1Container context)
 {
     foreach (var fileImport in text.Split('\r').Select(t => t.Split('|')).Select(items => new FileImports
     {
         email = items[(int)TextFields.Email],
         firstName = items[(int)TextFields.FirstName],
         lastName = items[(int)TextFields.LastName],
         phoneNumber = items[(int)TextFields.PhoneNumber]
     }))
     {
         context.FileImports1.Add(fileImport);
     }
 }
Exemple #20
0
        public UCClientList()
        {
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {

                InitializeComponent();
                _dataDC = ModelSingleton.getDataDC;
                lcl = new ObservableClient(_dataDC);

                this.DataContext = lcl;
                clientSet1ViewSource.ItemsSource = lcl;
            }
        }
Exemple #21
0
        public Client(ClientSet client)
        {
            this.InitializeComponent();
            _dataDC = ModelSingleton.getDataDC;
            lps = new ObservableProductSearch(_dataDC);
            lvProductSearched.ItemsSource = lps.Where(S => S.Enbusca == true.ToString() && S.Proveedor_ID == client.Id).ToList();
            _client = client;
            this.DataContext = client;

            UpdateRequestedProductList();
            Update_ListSoldProducts();
            // Insert code required on object creation below this point.
        }
        public UCProductList()
        {
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                _dataDC = ModelSingleton.getDataDC;
                InitializeComponent();

                lp = new ObservableProduct(_dataDC);
                this.DataContext = lp;
                ProductsSetListView.Width = this.Width;

                ProductsSetListView.ItemsSource = lp;
            }
        }
 public static void AddMenuDay(Nullable<int> idMenu, DateTime dateSt)
 {
     string[] days = new string[7];
     days = Enum.GetNames(typeof(Days));
     using (Model1Container db = new Model1Container())
     {
         MenuDay[] newMD = new MenuDay[7];
         for (int i = 0; i < 7; i++)
         {
             newMD[i] = new MenuDay() { MenuFK = idMenu, Date_ = dateSt.AddDays(i), Day = days[i] };
             db.MenuDay.Add(newMD[i]);
             db.SaveChanges();
         }
     }
 }
 void mi_View(object sender, RoutedEventArgs e)
 {
     MenuItem mi = sender as MenuItem;
     ContextMenu cm = mi.Parent as ContextMenu;
     TextBlock curTvi = (TextBlock)cm.PlacementTarget;
     int mealId;
     using (Model1Container db = new Model1Container())
     {
         mealId = (from meal in db.Meal
                   where meal.Name.Equals(curTvi.Text)
                   select meal.MealPK).FirstOrDefault();
     }
     AddMealView am = new AddMealView(mealId);
     am.ShowDialog();
 }
Exemple #25
0
 static void NoLinqStrategy(string text, Model1Container context)
 {
     foreach (var fileImportLine in text.Split('\r'))
     {
         var fields = fileImportLine.Split('|');
         var fileImport = new FileImports
         {
             email = fields[(int)TextFields.Email],
             firstName = fields[(int)TextFields.FirstName],
             lastName = fields[(int)TextFields.LastName],
             phoneNumber = fields[(int)TextFields.PhoneNumber]
         };
         context.FileImports1.Add(fileImport);
     }
 }
        public static String[] SelectJobStatuses(String user, DateTime fromDate, DateTime toDate)
        {
            using (var dbContext = new Model1Container()) {
                var actions = from c in dbContext.Logs
                              where c.OwnerName == user && c.Time > fromDate && c.Time < toDate
                              group c by c.Action into g
                              select new { g.Key, Count = g.Count() };
                List<String> list = new List<String>();
                foreach (var action in actions) {
                    list.Add(action.Key + ": " + action.Count);
                }

                return list.ToArray();
            }
        }
 public ShowMealViewModel(int id)
 {
     Id = id;
     using (Model1Container db = new Model1Container())
     {
         var _groups = (from groups in db.GroupMeal
                        select groups.Name).ToList<string>();
         Groups = new ObservableCollection<string>(_groups);
     }
     Ingreds = new IngredViewModel(id);
     using (Model1Container db = new Model1Container())
     {
         _products = new ObservableCollection<Product>((from prods in db.Product
                                                                                      select prods).ToList());
     }
 }
        public MenuBookViewModel()
        {
            using (Model1Container db = new Model1Container())
            {
                _groups = (from groups in db.GroupMeal
                               select new MealGroup()
                               {
                                   Name = groups.Name,
                                   ID = groups.GroupMealPK
                               }).ToList<MealGroup>();
            }

            AddMeal = new Command(arg => AddMealMethod());
            ViewMeal = new Command(arg => ViewMealMethod());
            CorrectMeal = new Command(arg => CorrectMealMethod());
        }
Exemple #29
0
        public MainWindow()
        {
            InitializeComponent();

            OurLocalDataProvider = new NorthwindEntities();
            //Query to model of database (example)
            //-------------------------------------
            CustomersDataGrid.DataContext = OurLocalDataProvider.Customers.
                Where(res => res.Country == "Mexico").
                ToList();
            //-------------------------------------

            //adding new row to database in table 'Customers' (example)
            //--------------------------------------------------------
            try
            {
                Customers NewCustomer = new Customers()
                {
                    Address = "TestAddress",
                    City = "Test",
                    CompanyName = "Test",
                    ContactName = "Test",
                    ContactTitle = "Test",
                    Country = "Test",
                    CustomerID = "Test",
                    Fax = "Test",
                    Phone = "Test",
                    PostalCode = "Test",
                    Region = "Test"
                };
                OurLocalDataProvider.Customers.Add(NewCustomer);
                OurLocalDataProvider.SaveChanges();
            }
            catch (Exception excep)
            {
                MessageBox.Show(excep.Message);
            }
            //--------------------------------------------------------
            Model1Container CreatedDB = new Model1Container();
            CreatedDB.JobsSet.Add(new Jobs() {  Job = "SuperJob", Salary = 10000 });
            CreatedDB.JobsSet.Add(new Jobs() { Job = "MegaJob", Salary = 15000 });
            CreatedDB.JobsSet.Add(new Jobs() { Job = "EpicJob", Salary = 20000 });
            CreatedDB.PeoplesSet.Add(new Peoples() { JobId = 1, Email = "Email_1", Name = "Name_1", SpecialCode = 19 });
            CreatedDB.PeoplesSet.Add(new Peoples() { JobId = 1, Email = "Email_2", Name = "Name_2", SpecialCode = 67 });
            CreatedDB.PeoplesSet.Add(new Peoples() { JobId = 1, Email = "Email_3", Name = "Name_3", SpecialCode = 34 });
            CreatedDB.SaveChanges();
        }
        public static int AddMeal(string name, string groupName)
        {
            using (Model1Container db = new Model1Container())
            {
                var groupId = (from groups in db.GroupMeal
                              where groups.Name.Equals(groupName)
                              select groups.GroupMealPK).FirstOrDefault();

                Meal newM = db.Meal.Where(c => c.Name == name).FirstOrDefault();
                newM = new Meal() { Name = name, GroupMealFK = groupId};
                db.Meal.Add(newM);
                db.SaveChanges();
                db.MealProducts.Add(new MealProducts() { MealFK = newM.MealPK });
                db.SaveChanges();
                return newM.MealPK;
            }
        }
Exemple #31
0
        static void Main()
        {
            Model1Container model = new Model1Container();

            // création repositories

            SectionRepository   repoSect      = new SectionRepository(model);
            StudentRepository   repoStud      = new StudentRepository(model);
            CourseRepository    repoCourse    = new CourseRepository(model);
            ProfessorRepository repoProfessor = new ProfessorRepository(model);

            // ajout de 2 sections
            Section sectInfo = new Section {
                Name = "Info"
            };

            repoSect.Save(sectInfo, s => s.Name.Equals(sectInfo.Name));
            Section sectDiet = new Section {
                Name = "Diet"
            };

            repoSect.Save(sectDiet, s => s.Name.Equals(sectDiet.Name));

            // renvoyer toutes les sections

            IList <Section> sections = repoSect.GetAll().ToList();

            Console.WriteLine("----------- SECTIONS --------------------");
            foreach (Section s in sections)
            {
                Console.WriteLine(s.Name);
            }
            Console.WriteLine("-----------------------------------------");


            // ajout de 3 étudiants
            Student studinfo = new Student
            {
                Firstname  = "studinfo",
                Name       = "studinfo",
                Section    = sectInfo,
                YearResult = 100
            };

            Student studdiet = new Student
            {
                Firstname  = "studdiet",
                Name       = "studdiet",
                Section    = sectDiet,
                YearResult = 150
            };


            Student studinfo2 = new Student
            {
                Firstname  = "studinfo2",
                Name       = "studinfo2",
                Section    = sectInfo,
                YearResult = 110
            };

            repoStud.Save(studinfo, s => s.Name.Equals(studinfo.Name) && s.Firstname.Equals(studinfo.Firstname));
            repoStud.Save(studinfo2, s => s.Name.Equals(studinfo2.Name) && s.Firstname.Equals(studinfo2.Firstname));
            repoStud.Save(studdiet, s => s.Name.Equals(studdiet.Name) && s.Firstname.Equals(studdiet.Firstname));

            IList <Student> studs = repoStud.GetStudentBySectionOrderByYearResult();

            foreach (Student s in studs)
            {
                Console.WriteLine("SECTION : " + s.Section.Name + " STUD : " + s.Name + " YEAR_RESULT : " + s.YearResult);
            }



            // créer 2 professeurs
            Professor profDiet = new Professor {
                Firstname = "profDiet", Name = "profDiet", Section = sectDiet
            };

            repoProfessor.Save(profDiet, p => p.Name.Equals(profDiet.Name));
            Professor profInfo = new Professor {
                Firstname = "profInfo", Name = "profInfo", Section = sectInfo
            };

            repoProfessor.Save(profInfo, p => p.Name.Equals(profInfo.Name));

            // créer 3 cours
            Course techCulinaire = new Course {
                Name = "Technique Culinaire", Professor = profDiet
            };

            repoCourse.Save(techCulinaire, c => c.Name.Equals(techCulinaire.Name));
            Course mathDiet = new Course {
                Name = "Math", Professor = profDiet
            };

            repoCourse.Save(mathDiet, c => c.Name.Equals(mathDiet.Name));
            Course mathInfo = new Course {
                Name = "Math", Professor = profInfo
            };

            repoCourse.Save(mathInfo, c => c.Name.Equals(mathInfo.Name));

            // liste des cours de la section diet
            IList <Course> courses = repoCourse.GetCoursesForSection("Diet");

            Console.WriteLine("Cours de la section Diet : ");
            foreach (Course c in courses)
            {
                Console.WriteLine("COURS : " + c.Name + "PROFESSOR " + c.Professor.Firstname);
            }

            Console.ReadLine();
        }
Exemple #32
0
 public FilmRepository(Model1Container _cont)
 {
     db = _cont;
 }
Exemple #33
0
 public UserToCustomerRepos(Model1Container model, bool checkInputs = true, bool allowCascade = false) : base(model, checkInputs, allowCascade)
 {
 }
Exemple #34
0
 public AuthanticateController()
 {
     this.context = new Model1Container();
 }
Exemple #35
0
 public HomeController()
 {
     _db = new Model1Container();
 }
Exemple #36
0
 public CashierRepository(Model1Container _cont)
 {
     db = _cont;
 }
Exemple #37
0
 public Repos(Model1Container model, bool checkInputs = true, bool allowCascade = false)
 {
     cont         = model;
     CheckInputs  = checkInputs;
     AllowCascade = allowCascade;
 }
Exemple #38
0
 public void Sterge(string path)
 {
     using (var context = new Model1Container())
     {
     }
 }
Exemple #39
0
        private static int AddGame(DateTime date, string gameID, string homeTeam, string awayTeam, Model1Container dbContext)
        {
            var game = new Game
            {
                Description = gameID,
                GameDate    = date,
                AwayTeam    = awayTeam,
                HomeTeam    = homeTeam
            };

            dbContext.Games.AddObject(game);
            try
            {
                dbContext.SaveChanges();
            }
            catch (Exception ex)
            {
                string err = string.Format("Error saving gameID {0}: {1}", gameID, ex.ToString());
                Console.WriteLine(err);
                log.Error(err);
            }
            return(game.Id);
        }
 public AddressRepos(Model1Container model, bool checkInputs = true, bool allowCascade = false) : base(model, checkInputs, allowCascade)
 {
 }
Exemple #41
0
        private static void AddAtBats(XmlNodeList inningHalves, int dbGameID, short inningNum, Model1Container dbContext)
        {
            foreach (XmlNode halfInning in inningHalves)
            {
                var inningHalf = halfInning.Name;
                foreach (XmlNode atBatNode in halfInning.ChildNodes)
                {
                    if (atBatNode.Name == "atbat")
                    {
                        var atBat = GetAtBatFromXml(atBatNode, dbGameID, inningNum, inningHalf);

                        dbContext.AtBats.AddObject(atBat);
                        dbContext.SaveChanges();
                        int dbAtBatID = atBat.Id;

                        AddPitches(atBatNode, dbAtBatID, dbContext);
                    }
                }
            }
        }
Exemple #42
0
 public BaseRepository(Model1Container dbContext)
 {
     _dbContext = dbContext;
 }
Exemple #43
0
 public UserManager()
 {
     context = new Model1Container();
 }
 public CustomerViewModel()
 {
     _modelContext = new Model1Container();
 }
 public SalesEntryViewModel()
 {
     _modelContext = new Model1Container();
 }
Exemple #46
0
 public DataManager()
 {
     cont = new Model1Container();
     InitializeRepos();
 }
Exemple #47
0
 public LoadProjectWindow()
 {
     InitializeComponent();
     model1 = new Model1Container();
 }
Exemple #48
0
 public AccountController()
 {
     _db = new Model1Container();
 }
Exemple #49
0
 public static void SaveModelToXML(this Model1Container model, string xmlfilePath)
 {
     ///some code
 }