Ejemplo n.º 1
0
 // Implémentation méthode createManageFactory Interface ManageFactory
 public void createManageFactory(ManageFactoryBO village)
 {
     try
     {
         ManageFactoryBL.Insert(village);
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 2
0
 // Méthode Insert ManageFactory
 public static void Insert(ManageFactoryBO manageFactory)
 {
     try
     {
         ManageFactoryDAL dal = new ManageFactoryDAL(CUtil.GetConnexion());
         dal.ManageFactoryBO_Insert(
             manageFactory.id_village,
             manageFactory.id_factory
             );
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 3
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;
            }
        }