private void SaveBtn_OnClick(object sender, RoutedEventArgs e)
        {
            var patientViewModel = PatientInfo.DataContext as PatientViewModel;

            if (patientViewModel != null && (string.IsNullOrEmpty(
                                                 patientViewModel.Name) || string.IsNullOrWhiteSpace(patientViewModel.Name) ||
                                             string.IsNullOrEmpty(patientViewModel.Disease) || string.IsNullOrWhiteSpace(patientViewModel.Disease)))
            {
                MessageBox.Show("Name or Disease is null", "Attention!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            _cfg = AutomapperConfig.Config <PatientViewModel, Patient>();
            var patient = _cfg.CreateMapper().Map <Patient>(patientViewModel);

            using (var db = new ObjectContext())
            {
                if (patient.Id == 0)
                {
                    db.Patients.Add(patient);
                    db.SaveChanges();
                }

                else
                {
                    db.Patients.AddOrUpdate(patient);
                    db.SaveChanges();
                }

                InvoiceDg.ItemsSource = db.Patients.ToList();
            }
        }
        private void SaveBtn_OnClick(object sender, RoutedEventArgs e)
        {
            var supplierViewModel = CustomerInfo.DataContext as SupplierViewModel;

            if (supplierViewModel != null && (string.IsNullOrEmpty(
                                                  supplierViewModel.FirstName) || string.IsNullOrWhiteSpace(supplierViewModel.FirstName) ||
                                              string.IsNullOrEmpty(supplierViewModel.LastName) || string.IsNullOrWhiteSpace(supplierViewModel.LastName)))
            {
                MessageBox.Show("Name or First Name is null", "Attention!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            _cfg = AutomapperConfig.Config <SupplierViewModel, Supplier>();
            var supplier = _cfg.CreateMapper().Map <Supplier>(supplierViewModel);

            using (var db = new ObjectContext())
            {
                if (supplier.Id == 0)
                {
                    db.Suppliers.Add(supplier);
                    db.SaveChanges();
                }

                else
                {
                    db.Suppliers.AddOrUpdate(supplier);
                    db.SaveChanges();
                }

                InvoiceDg.ItemsSource = db.Suppliers.ToList();
            }
        }
Ejemplo n.º 3
0
        private void SaveBtn_OnClick(object sender, RoutedEventArgs e)
        {
            var customeriew = CustomerInfo.DataContext as CustomerViewModel;

            if (customeriew != null && (string.IsNullOrEmpty(
                                            customeriew.FirstName) || string.IsNullOrWhiteSpace(customeriew.FirstName) ||
                                        string.IsNullOrEmpty(customeriew.LastName) || string.IsNullOrWhiteSpace(customeriew.LastName)))
            {
                MessageBox.Show("Nom ou Prénom est null", "Attention!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            _cfg = AutomapperConfig.Config <CustomerViewModel, Customer>();
            var customer = _cfg.CreateMapper().Map <Customer>(customeriew);

            using (var db = new ObjectContext())
            {
                if (customer.Id == 0)
                {
                    db.InsertWithIdentity(customer);
                }
                else
                {
                    db.Update(customer);
                }
                InvoiceDg.ItemsSource = db.Customers.ToList();
            }
        }
        private void SaveBtn_OnClick(object sender, RoutedEventArgs e)
        {
            var categoryViewModel = CategoryInfo.DataContext as CategoryViewModel;

            if (categoryViewModel != null && (string.IsNullOrEmpty(
                                                  categoryViewModel.Name) || string.IsNullOrWhiteSpace(categoryViewModel.Name)))
            {
                MessageBox.Show("Name  is null", "Attention!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            _cfg = AutomapperConfig.Config <CategoryViewModel, Category>();
            var category = _cfg.CreateMapper().Map <Category>(categoryViewModel);

            using (var db = new ObjectContext())
            {
                if (category.Id == 0)
                {
                    db.Categories.Add(category);
                    db.SaveChanges();
                }
                else
                {
                    db.Categories.AddOrUpdate(category);
                    db.SaveChanges();
                }

                CategoryDg.ItemsSource = db.Categories.ToList();
            }
        }
        private void SaveBtn_OnClick(object sender, RoutedEventArgs e)
        {
            var model = EmployeeInfo.DataContext as EmployeeViewModel;

            if (model != null && (string.IsNullOrEmpty(
                                      model.FullName) || string.IsNullOrWhiteSpace(model.FullName) ||
                                  string.IsNullOrEmpty(model.UserName) || string.IsNullOrWhiteSpace(model.UserName)))
            {
                MessageBox.Show("Name or Username is null", "Attention!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            _cfg = AutomapperConfig.Config <EmployeeViewModel, Employee>();
            var employee = _cfg.CreateMapper().Map <Employee>(model);

            using (var db = new ObjectContext())
            {
                if (employee.Id == 0)
                {
                    db.Employees.Add(employee);
                    db.SaveChanges();
                }
                else
                {
                    db.Employees.AddOrUpdate(employee);
                    db.SaveChanges();
                }
                InvoiceDg.ItemsSource = db.Employees.ToList();
            }
        }
Ejemplo n.º 6
0
        private void SaveBtn_OnClick(object sender, RoutedEventArgs e)
        {
            var productViewModel = CustomerInfo.DataContext as ProductViewModel;

            if (productViewModel != null && (string.IsNullOrEmpty(
                                                 productViewModel.Name) || string.IsNullOrWhiteSpace(productViewModel.Name)))
            {
                MessageBox.Show("Désignation produit est null", "Attention!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            _cfg = AutomapperConfig.Config <ProductViewModel, Product>();
            var product = _cfg.CreateMapper().Map <Product>(productViewModel);

            product.CreationDate = DateTime.Now;
            switch (CbMeasureUnit.Text)
            {
            case "Kilogramme":
                product.MesureUnit = MesureUnit.Kilogramme;
                break;

            case "Carton":
                product.MesureUnit = MesureUnit.Carton;
                break;

            case "Litre":
                product.MesureUnit = MesureUnit.Litre;
                break;

            case "Paquet":
                product.MesureUnit = MesureUnit.Paquet;
                break;

            case "Boite":
                product.MesureUnit = MesureUnit.Boite;
                break;

            default: product.MesureUnit = MesureUnit.Autre;
                break;
            }

            using (var db = new ObjectContext())
            {
                if (db.Products.Count() > 5)
                {
                    MessageBox.Show("Evaluation", "Vous pouvez pas ajouter plus de 5 produits dans cette version");
                    return;
                }
                if (product.Id == 0)
                {
                    db.InsertWithIdentity(product);
                }
                else
                {
                    db.Update(product);
                }
                InvoiceDg.ItemsSource = db.Products.ToList();
            }
        }
Ejemplo n.º 7
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     AutomapperConfig.Config();
 }
        private void SaveBtn_OnClick(object sender, RoutedEventArgs e)
        {
            var medicineViewModel = CustomerInfo.DataContext as MedicineViewModel;

            if (medicineViewModel != null && (string.IsNullOrEmpty(
                                                  medicineViewModel.Name) || string.IsNullOrWhiteSpace(medicineViewModel.Name)))
            {
                MessageBox.Show("Medicine is null", "Attention!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            _cfg = AutomapperConfig.Config <MedicineViewModel, Medicine>();
            var medicine = _cfg.CreateMapper().Map <Medicine>(medicineViewModel);

            medicine.CreatedAt = DateTime.Now;
            switch (CbMedicineType.Text)
            {
            case "Tablet":
                medicine.MedicineType = MedicineType.Tablet;
                break;

            case "Injection":
                medicine.MedicineType = MedicineType.Injection;
                break;

            case "Cream":
                medicine.MedicineType = MedicineType.Cream;
                break;

            case "Ointment":
                medicine.MedicineType = MedicineType.Ointment;
                break;

            case "Syrup":
                medicine.MedicineType = MedicineType.Syrup;
                break;

            case "Other":
                medicine.MedicineType = MedicineType.Other;
                break;
            }

            using (var db = new ObjectContext())
            {
                if (medicine.Id == 0)
                {
                    db.Medicines.Add(medicine);
                    db.SaveChanges();
                }
                else
                {
                    db.Medicines.AddOrUpdate(medicine);
                    db.SaveChanges();
                }

                InvoiceDg.ItemsSource = db.Medicines.ToList();
            }
        }
 private void InvoiceDg_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!(InvoiceDg.SelectedItem is Patient patient))
     {
         return;
     }
     _cfg = AutomapperConfig.Config <Patient, PatientViewModel>();
     PatientInfo.DataContext = _cfg.CreateMapper().Map <PatientViewModel>(patient);
 }
 private void InvoiceDg_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!(InvoiceDg.SelectedItem is Employee employee))
     {
         return;
     }
     _cfg = AutomapperConfig.Config <Employee, EmployeeViewModel>();
     EmployeeInfo.DataContext = _cfg.CreateMapper().Map <EmployeeViewModel>(employee);
 }
Ejemplo n.º 11
0
 private void InvoiceDg_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!(InvoiceDg.SelectedItem is Product product))
     {
         return;
     }
     _cfg = AutomapperConfig.Config <Product, ProductViewModel>();
     CustomerInfo.DataContext = _cfg.CreateMapper().Map <ProductViewModel>(product);
 }
 private void InvoiceDg_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!(InvoiceDg.SelectedItem is Medicine medicine))
     {
         return;
     }
     _cfg = AutomapperConfig.Config <Medicine, MedicineViewModel>();
     CustomerInfo.DataContext = _cfg.CreateMapper().Map <MedicineViewModel>(medicine);
 }
Ejemplo n.º 13
0
 private void InvoiceDg_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!(InvoiceDg.SelectedItem is Customer custmer))
     {
         return;
     }
     _cfg = AutomapperConfig.Config <Customer, CustomerViewModel>();
     CustomerInfo.DataContext = _cfg.CreateMapper().Map <CustomerViewModel>(custmer);
 }
 private void CategoryDg_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (!(CategoryDg.SelectedItem is Category category))
     {
         return;
     }
     _cfg = AutomapperConfig.Config <Category, CategoryViewModel>();
     CategoryInfo.DataContext = _cfg.CreateMapper().Map <CategoryViewModel>(category);
 }
        public TransferExcelServiceTest()
        {
            // Конфигурация конвертера типов
            AutomapperConfig.Config();
            var webHost = WebHost.CreateDefaultBuilder()
                          .UseStartup <Api.Startup>()
                          .Build();

            _serviceProvider = new Utils.DependencyResolverHelpercs(webHost);
        }
Ejemplo n.º 16
0
        private void SaveBtn_OnClick(object sender, RoutedEventArgs e)
        {
            var stockViewModel = CustomerInfo.DataContext as StockViewModel;

            if (stockViewModel != null && (stockViewModel.MedicineId == 0 || stockViewModel.Quentity == 0))
            {
                MessageBox.Show("Product specification or stock quantity is zero", "Attention!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            _cfg = AutomapperConfig.Config <StockViewModel, Stock>();
            var stock = _cfg.CreateMapper().Map <Stock>(stockViewModel);

            using (var db = new ObjectContext())
            {
                if (stock.Id == 0)
                {
                    if (db.Stocks.Any(s => s.MedicineId == stock.MedicineId && s.ExpireDate == stock.ExpireDate && s.SupplierId == stock.SupplierId))
                    {
                        var st = db.Stocks.SingleOrDefault(s =>
                                                           s.MedicineId == stock.MedicineId && s.ExpireDate == stock.ExpireDate &&
                                                           s.SupplierId == stock.SupplierId);
                        if (st != null)
                        {
                            stock.Id = st.Id;
                            //     stock.Quentity = st.Quentity;
                        }
                        db.Stocks.AddOrUpdate(stock);
                        db.SaveChanges();
                    }
                    else
                    {
                        db.Stocks.Add(stock);
                        db.SaveChanges();
                    }
                }
                else
                {
                    var old = db.Stocks.FirstOrDefault(x => x.Id == stock.Id);
                    if (old != null && (old.Id == stock.Id && old.MedicineId == stock.MedicineId && old.ExpireDate == stock.ExpireDate))
                    {
                        //   stock.Quentity += old.Quentity;
                        db.Stocks.AddOrUpdate(stock);
                        db.SaveChanges();
                    }
                    else
                    {
                        stock.Id = 0;
                        db.Stocks.Add(stock);
                        db.SaveChanges();
                    }
                }

                InvoiceDg.ItemsSource = db.Stocks.Where(x => x.Quentity > 0).Include(s => s.Medicine).Include(s => s.Supplier).ToList();
            }
        }
Ejemplo n.º 17
0
        private void SaveBtn_OnClick(object sender, RoutedEventArgs e)
        {
            var stockViewModel = CustomerInfo.DataContext as StockViewModel;

            if (stockViewModel != null && (stockViewModel.Product_Id == 0 || stockViewModel.Qnt == 0))
            {
                MessageBox.Show("Désignation produit ou quntité stock est null", "Attention!", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            _cfg = AutomapperConfig.Config <StockViewModel, Stock>();
            var stock = _cfg.CreateMapper().Map <Stock>(stockViewModel);

            stock.CreationDate = DateTime.Now;
            using (var db = new ObjectContext())
            {
                var product = db.Products.FirstOrDefault(x => x.Id == stock.Product_Id);

                if (stock.Id == 0)
                {
                    var last = db.Stocks.OrderByDescending(x => x.Id).FirstOrDefault();
                    stock.Id = last?.Id + 1 ?? 1;
                    db.InsertWithInt64Identity(stock);

                    if (product != null)
                    {
                        product.Qnt += stock.Qnt;
                        db.Update(product);
                    }
                }
                else
                {
                    var old = db.Stocks.FirstOrDefault(x => x.Id == stock.Id);
                    db.Update(stock);
                    if (product != null)
                    {
                        if (old != null)
                        {
                            product.Qnt += (stock.Qnt - old.Qnt);
                        }
                        db.Update(product);
                    }
                }

                InvoiceDg.ItemsSource = db.Stocks.LoadWith(x => x.Product).LoadWith(x => x.Supplier)
                                        .ToList();
            }
        }
Ejemplo n.º 18
0
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            var jsonFormatter = config.Formatters.JsonFormatter;

            jsonFormatter.SerializerSettings.ContractResolver      = new CamelCasePropertyNamesContractResolver();
            jsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;

            config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));

            AutomapperConfig.Config();
        }
Ejemplo n.º 19
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseHttpsRedirection();

            app.UseRouting();



            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
            // Конфигурация конвертера типов
            AutomapperConfig.Config();
        }