예제 #1
0
        // Methode qui retourne un bool en fonctione du status Factory
        public static bool CheckStatus(FactoryBO factory)
        {
            try
            {
                List<FactoryBO> listResult = new List<FactoryBO>();
                FactoryBO result = new FactoryBO();
                FactoryDAL dal = new FactoryDAL(CUtil.GetConnexion());

                listResult = dal.FactoryBO_FindById(factory.id_factory).ToList();
                result = listResult.FirstOrDefault();

                if (result.status == "true")
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception)
            {

                throw;
            }
        }
예제 #2
0
 /*
  * Initialisation de la Form frmFactoryManage
  */
 public frmFactoryManage(frmVillage frmVillage, UserBO user, FactoryBO factory)
 {
     InitializeComponent();
     this.frmVillage = frmVillage;
     this.user = user;
     this.factory = factory;
 }
예제 #3
0
 // Implémentation méthode createFactory Interface Factory
 public void createFactory(FactoryBO factory)
 {
     try
     {
         FactoryBL.Insert(factory);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #4
0
 // Implémentation méthode checkStatus Interface Factory
 public bool checkStatus(FactoryBO factory)
 {
     try
     {
         return FactoryBL.CheckStatus(factory);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #5
0
        /*
         * Initialisation de la Form frmFactory avec Factory en paramètre
         */
        public frmFactory(frmVillage frmVillage, UserBO user, FactoryBO factory)
        {
            InitializeComponent();
            this.frmVillage = frmVillage;
            this.user = user;
            this.factory = factory;

            btnAdd.Visible = false;

            pictureBox.Image = Resource.Factory;
            pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
        }
예제 #6
0
 // Méthode qui retourne la dernière Factory créée
 public static FactoryBO FindLast()
 {
     try
     {
         FactoryBO result = new FactoryBO();
         FactoryDAL dal = new FactoryDAL(CUtil.GetConnexion());
         result = dal.FactoryBO_FindLast().FirstOrDefault();
         return result;
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #7
0
        // Méthode Insert Factory
        public static FactoryBO Insert(FactoryBO factory)
        {
            try
            {
                FactoryDAL dal = new FactoryDAL(CUtil.GetConnexion());
                dal.FactoryBO_Insert(
                    factory.type,
                    factory.factory_stock,
                    factory.factory_location,
                    factory.toy_production_time,
                    factory.toy_current_production,
                    factory.status
                    );
                return factory;
            }
            catch (Exception)
            {

                throw;
            }
        }
예제 #8
0
        // Implémentation méthode productToys Interface Factory
        public void productToys(FactoryBO factory, UserBO user)
        {
            try
            {
                // Recherche FactoryType en fonction de Factory
                FactoryTypeBO factoryType = new FactoryTypeBO();
                factoryType = FactoryTypeBL.FindById(factory.type);

                // Update du capital en fonction des info FactoryType
                int newCapital = user.capital - factoryType.toy_production_price;
                user.capital = newCapital;
                UserBL.Update(user);

                // Update du status Factory
                factory.status = "true";
                FactoryBL.Update(factory);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #9
0
        /*
         * Ajout d'une factory
         */
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                FactoryBO factory = new FactoryBO();
                ManageFactoryBO manageFactory = new ManageFactoryBO();
                List<ManageVillageBO> manageVillageList = new List<ManageVillageBO>();
                UserBO user = new UserBO();
                int price = Int32.Parse(lblFactoryPrice.Text);
                int capital;

                // Récupération de l'user et calcul du capital final
                using (UserIFACClient proxyUser = new UserIFACClient())
                {
                    user = proxyUser.findById(id_user);
                    capital = user.capital - price;
                }

                /*
                 * Si capital calculé plus grand que la capital minimum (500)
                 * True: Création factory, création lien factory->village, update user
                 * False: Afficher message "Plus assez d'argent..."
                 */
                if (Utilities.checkCapital(capital))
                {
                    // Création et récupération factory
                    using (FactoryIFACClient proxyFactory = new FactoryIFACClient())
                    {
                        factory.type = Int32.Parse(cbxFactoryType.SelectedValue.ToString());
                        factory.factory_location = position;
                        factory.toy_production_time = DateTime.Now;
                        factory.status = "false";
                        proxyFactory.createFactory(factory);
                        factory = proxyFactory.getLastFactory();
                    }

                    // Création du lien factory->village
                    using (ManageFactoryIFACClient proxyManageFactory = new ManageFactoryIFACClient())
                    {
                        manageFactory.id_village = id_village;
                        manageFactory.id_factory = factory.id_factory;
                        proxyManageFactory.createManageFactory(manageFactory);
                    }

                    // Update de l'user et rechargement de la Form Village
                    using (UserIFACClient proxyUser = new UserIFACClient())
                    {
                        user.capital = capital;
                        proxyUser.updateUser(user);
                        frmVillage.reload(user);
                    }
                    this.Dispose();
                    MessageBox.Show("Factory successfully created.");
                }
                else
                {
                    this.Dispose();
                    MessageBox.Show("Vous n'avez plus assez d'argent, économisez !");
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #10
0
 // Implémentation méthode updateFactory Interface Factory
 public void updateFactory(FactoryBO factory)
 {
     try
     {
         FactoryBL.Update(factory);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #11
0
        // Implémentation méthode salesProduct Interface Factory
        public void salesProduct(FactoryBO factory, UserBO user)
        {
            try
            {
                // Recherche FactoryType en fonction de Factory
                FactoryTypeBO factoryType = new FactoryTypeBO();
                factoryType = FactoryTypeBL.FindById(factory.type);

                // Update du capital en fonction des info FactoryType et du stock
                int newCapital = user.capital + factory.factory_stock * factoryType.toy_sales_prices;
                user.capital = newCapital;
                UserBL.Update(user);

                // Remise à zéro du stock
                factory.factory_stock = 0;
                FactoryBL.Update(factory);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #12
0
        // Méthode retourne la Factory en fonction de ID Factory
        public static FactoryBO SearchById(int id_factory)
        {
            try
            {
                List<FactoryBO> listResult = new List<FactoryBO>();
                FactoryBO result = new FactoryBO();
                FactoryDAL dal = new FactoryDAL(CUtil.GetConnexion());

                listResult = dal.FactoryBO_FindById(id_factory).ToList();
                result = listResult.FirstOrDefault();
                return result;
            }
            catch (Exception)
            {

                throw;
            }
        }
예제 #13
0
        // Méthode Update Factory
        public static void Update(FactoryBO factory)
        {
            try
            {
                FactoryDAL dal = new FactoryDAL(CUtil.GetConnexion());
                dal.FactoryBO_Update(
                    factory.id_factory,
                    factory.type,
                    factory.factory_stock,
                    factory.factory_location,
                    factory.toy_production_time,
                    factory.toy_current_production,
                    factory.status
                    );
            }
            catch (Exception)
            {

                throw;
            }
        }
예제 #14
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;
            }
        }