Пример #1
0
 /*
  * Chargement de la Form FactoryAdd
  * Population de la combobox avec la liste de FactoryType
  */
 private void frmFactoryAdd_Load(object sender, EventArgs e)
 {
     try
     {
         factoryTypeList = new List<FactoryTypeBO>();
         using (FactoryTypeIFACClient proxyFactoryType = new FactoryTypeIFACClient())
         {
             factoryTypeList = proxyFactoryType.selectAll();
             cbxFactoryType.DataSource = factoryTypeList;
             cbxFactoryType.DisplayMember = "name";
             cbxFactoryType.ValueMember = "id_factory_type";
             cbxFactoryType.Text = " - Choose - ";
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #2
0
        /*
         * Chargement de la Form frmFactoryManage
         */
        private void frmFactoryManage_Load(object sender, EventArgs e)
        {
            try
            {
                // Update status Factory si la date de prod + 1 heure est passée ou pas
                using (FactoryIFACClient proxyFactory = new FactoryIFACClient())
                {
                    factory = proxyFactory.findFactory(factory.id_factory);

                    /*
                     * Check le status de Factory
                     * Si true: Vérifie que la date de production est passée -> oui: factory_stock = toy_current_production, toy_current_production = 0 et status updaté + affichage Jouets produits
                     *                                                       -> non: les boutons Launch Production et Sale Stock sont bloqués
                     * Sinon: ne fait rien
                     */
                    if (proxyFactory.checkStatus(factory))
                    {
                        DateTime timeNow = Utilities.getDate();
                        DateTime timeProd = (DateTime)factory.toy_production_time;
                        if (Utilities.compareDate(timeProd, timeNow))
                        {
                            btnProduct.Enabled = false;
                            btnProduct.Text = STATUS_PRODUCTION;
                            btnSale.Enabled = false;
                            btnSale.Text = STATUS_PRODUCTION;
                        }
                        else
                        {
                            String production_result = factory.toy_current_production.ToString();
                            factory.factory_stock = factory.factory_stock + factory.toy_current_production;
                            factory.toy_current_production = 0;
                            factory.status = STATUS_OK;
                            proxyFactory.updateFactory(factory);
                            MessageBox.Show("Votre usine a produit " + production_result + " jouets.");
                        }
                    }
                }

                // Affiche les informations: Nom Jouets, Prix Production, Stock et Prix Vente
                using (FactoryTypeIFACClient proxyFactoryType = new FactoryTypeIFACClient())
                {
                    listFactoryType = new List<FactoryTypeBO>();
                    listFactoryType = proxyFactoryType.selectAll();

                    factoryType = listFactoryType.Find(type => type.id_factory_type == factory.type);
                    lblToys.Text = factoryType.name;
                    lblProductionPrice.Text = factoryType.toy_production_price.ToString();
                    lblStock.Text = factory.factory_stock.ToString();
                    lblSalesPrice.Text = factoryType.toy_sales_prices.ToString();
                }
            }
            catch (Exception)
            {
                throw;
            }
        }