Example #1
0
        public async Task <ActionResult <CategorieClient> > PostCategorieClient(CategorieClient categorieClient)
        {
            _context.CategorieClients.Add(categorieClient);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCategorieClient", new { id = categorieClient.Id }, categorieClient));
        }
Example #2
0
        public static void TotalRemiseContenuDoc(Contenu c, CategorieClient ca)
        {
            if ((ca != null) ? c != null : false)
            {
                ArticleCom a = c.Article;
                if (a != null)
                {
                    //Gestion Remise Sur l'article par le plan tarifaire
                    Article a_ = a.Article;
                    if ((a_ != null) ? ((a_.Plans != null) ? a_.Plans.Count > 0 : false) : false)
                    {
                        PlanTarifaire p = a_.Plans[0];
                        c.Prix      = p.Puv;
                        c.RemiseArt = MontantRemise(p.Remise_, c.Quantite, c.PrixTotal);
                    }

                    //Gestion Remise Sur l'article par le plan de remise
                    foreach (PlanRemise p in ca.Remises)
                    {
                        if (p.Article.Equals(a))
                        {
                            c.RemiseCat = MontantRemise(p.Remise, c.Quantite, c.PrixTotal);
                            break;
                        }
                    }
                }
            }
        }
        public static List <CategorieClient> getListCategorieClient(String query)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                List <CategorieClient> l    = new List <CategorieClient>();
                NpgsqlCommand          Lcmd = new NpgsqlCommand(query, con);
                NpgsqlDataReader       lect = Lcmd.ExecuteReader();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        CategorieClient a = new CategorieClient();
                        a.Id          = Convert.ToInt64(lect["id"].ToString());
                        a.Code        = lect["code"].ToString();
                        a.Designation = lect["libelle"].ToString();
                        a.Remises     = BLL.PlanRemiseBll.Liste("select * from yvs_com_plan_remise where actif = true and categorie =" + a.Id + " and '" + DateTime.Now + "' between date_debut and date_fin ");
                        a.Update      = true;
                        l.Add(a);
                    }
                    lect.Close();
                }
                return(l);
            }
            catch (NpgsqlException e)
            {
                Messages.Exception(e);
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("CategorieId,Nom,Description")] CategorieClient categorieClient)
        {
            if (id != categorieClient.CategorieId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(categorieClient);
                    _context.Entry(categorieClient).Property(x => x.CreatedAt).IsModified = false;
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategorieClientExists(categorieClient.CategorieId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                catch (DbUpdateException)
                {
                    ModelState.AddModelError("Nom", "Cette catégorie existe déjà");
                    return(View(categorieClient));
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(categorieClient));
        }
        public ActionResult Myorder()
        {
            CategorieClient _categorieClient = new CategorieClient();

            ViewBag.listcategorie = _categorieClient.FindAll();
            return(View(Session["cart"]));
        }
Example #6
0
        public async Task <IActionResult> PutCategorieClient(int id, CategorieClient categorieClient)
        {
            if (id != categorieClient.Id)
            {
                return(BadRequest());
            }

            _context.Entry(categorieClient).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CategorieClientExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public ActionResult SearchByCatigory(int id = 0)
        {
            CategorieClient _categorieClient = new CategorieClient();

            ViewBag.listcategorie = _categorieClient.FindAll();
            ProductClient _productClient = new ProductClient();

            ViewBag.listProduct = _productClient.FindCategory(id);
            return(View("index"));
        }
        public ActionResult Index()
        {
            CategorieClient _categorieClient = new CategorieClient();

            ViewBag.listcategorie = _categorieClient.FindAll();
            ProductClient _productClient = new ProductClient();

            ViewBag.listProduct = _productClient.FindAll();
            return(View());
        }
Example #9
0
        // GET: CategorieClients
        public async Task <IActionResult> Index()
        {
            var catClient = _context.CategoriesClient;

            if (catClient.Any())
            {
                var             catClientOrderByUpdated = catClient.OrderBy(c => c.UpdatedAt);
                CategorieClient lastCatClientUpdated    = catClientOrderByUpdated.Last();
                ViewData["lastCatClientCreateUpdate"] = "Derniere catégorie de client ajoutée/modifiée : " + lastCatClientUpdated.Nom;
            }
            return(View(await catClient.ToListAsync()));
        }
Example #10
0
        public void ControleCategorieClient(CategorieClient categ, int action = 1)
        {
            InitializeConnexion();

            using (IDbCommand cmd = ImplementeConnexion.Instance.Con.CreateCommand())
            {
                cmd.CommandText = "sp_merge_categorie_client";
                cmd.CommandType = CommandType.StoredProcedure;

                SetParameter(cmd, "@code", DbType.Int32, 4, categ.Code);
                SetParameter(cmd, "@designation", DbType.String, 100, categ.Designation);
                SetParameter(cmd, "@action", DbType.Int32, 4, action);

                cmd.ExecuteNonQuery();
            }
        }
Example #11
0
        public async Task <IActionResult> Create([Bind("CategorieId,Nom,Description")] CategorieClient categorieClient)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Add(categorieClient);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                catch (DbUpdateException)
                {
                    ModelState.AddModelError("Nom", "Cette catégorie existe déjà");
                    return(View(categorieClient));
                }
            }
            return(View(categorieClient));
        }
        public static CategorieClient getAjoutCategorieClient(CategorieClient a)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                string        insert = "";
                NpgsqlCommand cmd    = new NpgsqlCommand(insert, con);
                cmd.ExecuteNonQuery();
                a.Id = getCurrent();
                return(a);
            }
            catch
            {
                return(null);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
        public static bool getUpdateCategorieClient(CategorieClient a)
        {
            NpgsqlConnection con = Connexion.Connection();

            try
            {
                string        update = "";
                NpgsqlCommand Ucmd   = new NpgsqlCommand(update, con);
                Ucmd.ExecuteNonQuery();
                return(true);
            }
            catch (Exception e)
            {
                Messages.Exception(e);
                return(false);
            }
            finally
            {
                Connexion.Deconnection(con);
            }
        }
Example #14
0
        private void ControleCategorieClient(bool save)
        {
            try
            {
                if (save)
                {
                    if (IsNotEmpty(1))
                    {
                        categClient = new CategorieClient
                        {
                            Code        = "0",
                            Designation = TxtDesignCategClient.Text.ToUpper().Trim()
                        };

                        Glossaire.Instance.ControleCategorieClient(categClient);
                    }
                    else
                    {
                        categClient = new CategorieClient
                        {
                            Code        = TxtCodeCategClient.Text.Trim(),
                            Designation = TxtDesignCategClient.Text.ToUpper().Trim()
                        };

                        Glossaire.Instance.ControleCategorieClient(categClient, 2);
                    }
                }
                else
                {
                    categClient = new CategorieClient
                    {
                        Code        = TxtCodeCategClient.Text.Trim(),
                        Designation = TxtDesignCategClient.Text.ToUpper().Trim()
                    };

                    Glossaire.Instance.ControleCategorieClient(categClient, 3);
                }

                ClearFields(1);
                LoadCombo();
                LoadGridControle(1);
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show("Une erreur est survenue pendant l'opération ! " + ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                MessageBox.Show("Une erreur est survenue pendant l'opération ! " + ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Une erreur est survenue pendant l'opération ! " + ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                if (ImplementeConnexion.Instance.Con != null)
                {
                    if (ImplementeConnexion.Instance.Con.State == System.Data.ConnectionState.Open)
                    {
                        ImplementeConnexion.Instance.Con.Close();
                    }
                }
            }
        }
 public CategorieClientBll(CategorieClient unCategorieClient)
 {
     categorie = unCategorieClient;
 }