public ActionResult <List <Brand> > Index()
        {
            BrandDAO     dao       = new BrandDAO(_db);
            List <Brand> allBrands = dao.GetAll();

            return(allBrands);
        }
Exemple #2
0
        /// <summary>
        /// 获取品牌信息列表
        /// </summary>
        /// <param name="entity">参数:Brand实体</param>
        /// <param name="pageIndex">参数:当前页</param>
        /// <param name="pageSize">参数:分页个数</param>
        /// <param name="rowCount">参数:数据集的总数</param>
        /// <returns>返回Brand实体信息</returns>
        public BrandViewEntity[] GetList(BrandViewEntity entity, int pageIndex, int pageSize, out int rowCount)
        {
            List <IWhereCondition> wheres = new List <IWhereCondition>();

            if (entity != null && entity.BrandLevel != null && Convert.ToInt32(entity.BrandLevel) > 0)
            {
                wheres.Add(new EqualsCondition()
                {
                    FieldName = "b.BrandLevel", Value = entity.BrandLevel
                });
            }
            if (entity != null && !string.IsNullOrEmpty(entity.BrandName))
            {
                wheres.Add(new LikeCondition()
                {
                    FieldName = "b.BrandName", HasLeftFuzzMatching = true, HasRightFuzzMathing = true, Value = entity.BrandName
                });
            }

            List <OrderBy> orderbys = new List <OrderBy>();

            orderbys.Add(new OrderBy()
            {
                FieldName = "CreateTime", Direction = OrderByDirections.Desc
            });

            PagedQueryResult <BrandViewEntity> pEntity = new BrandDAO(this.CurrentUserInfo).GetList(wheres.ToArray(), orderbys.ToArray(), pageIndex, pageSize);

            rowCount = pEntity.RowCount;
            return(pEntity.Entities);
        }
Exemple #3
0
        /// <summary>
        /// Créer la marque lorsque l'on clique sur le bouton valider
        /// </summary>
        /// <param name="Sender"></param>
        /// <param name="Event"></param>
        private void OkButton_Click(object Sender, EventArgs Event)
        {
            int IntRef;

            if (int.TryParse(RefTextBox.Text, out IntRef))
            {
                if (NameTextBox.Text != "")
                {
                    if (BrandDAO.GetBrandById(IntRef) == null)
                    {
                        Brand NewBrand = new Brand(IntRef, NameTextBox.Text);
                        BrandDAO.AddBrand(NewBrand);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Ref existe déjà", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Les champs doivent etre remplient", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Référence doit etre un chiffre", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #4
0
 protected void lv_ThongTinSP_ItemInserting(object sender, ListViewInsertEventArgs e)
 {
     if (this.objCheckPermision.Permission(this.objCheckPermision.LayQuyen("strThuongHieu_Them")))
     {
         var t0  = new Brand();
         var txt = (e.Item.FindControl("txtName")) as TextBox;
         if (txt != null)
         {
             t0.Name = txt.Text;
         }
         txt = (e.Item.FindControl("txtNote")) as TextBox;
         if (txt != null)
         {
             t0.Name = txt.Text;
         }
         BrandDAO.Insert(t0);
         this.lv_ThongTinSP.EditIndex = -1;
         this.BinList();
     }
     else
     {
         this.iRightAccess.Visible = false;
         this.objControl.LoadMyControl(this.idNotPermissionAccess, NotPermissControl);
     }
 }
Exemple #5
0
        /// <summary>
        /// Supprime l'élement sélectionné du bon tableau
        /// </summary>
        /// <param name="NodeName"></param>
        /// <param name="SelectedItem"></param>
        private void DeleteItemListView(String NodeName, ListViewItem SelectedItem)
        {
            switch (NodeName)
            {
            case "Articles":
                ArticleDAO.DeleteArticle(SelectedItem.SubItems[2].Text);
                UpdateListView("Articles");
                break;

            case "Marques":
                BrandDAO.DeleteBrand(int.Parse(SelectedItem.SubItems[1].Text));
                UpdateListView("Marques");
                break;

            case "Familles":
                FamilyDAO.DeleteFamily(int.Parse(SelectedItem.SubItems[1].Text));
                UpdateListView("Familles");
                break;

            case "Sous familles":
                SubFamilyDAO.DeleteSubFamily(int.Parse(SelectedItem.SubItems[1].Text));
                UpdateListView("Sous familles");
                break;

            default:
                break;
            }
        }
Exemple #6
0
        public ActionResult <List <Brand> > Index()
        {
            BrandDAO     dao       = new BrandDAO(_db);
            List <Brand> allBrands = dao.GetAll();

            Console.WriteLine("in here");
            Console.WriteLine(allBrands.Count);
            return(allBrands);
        }
Exemple #7
0
        public async Task <bool> Delete(Brand Brand)
        {
            BrandDAO BrandDAO = await DataContext.Brand.Where(x => x.Id == Brand.Id).FirstOrDefaultAsync();

            DataContext.Brand.Remove(BrandDAO);
            await DataContext.SaveChangesAsync();

            return(true);
        }
Exemple #8
0
        public async Task <bool> Update(Brand Brand)
        {
            BrandDAO BrandDAO = DataContext.Brand.Where(x => x.Id == Brand.Id).FirstOrDefault();

            BrandDAO.Id         = Brand.Id;
            BrandDAO.Name       = Brand.Name;
            BrandDAO.CategoryId = Brand.CategoryId;
            await DataContext.SaveChangesAsync();

            return(true);
        }
Exemple #9
0
 public static async Task Execute(Brand brand)
 {
     try
     {
         await BrandDAO.RegisterBrand(brand);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemple #10
0
 /// <summary>
 /// Si les modifications sont valides change la marque concernée à l'appuie sur le bouton valider
 /// </summary>
 /// <param name="Sender"></param>
 /// <param name="Event"></param>
 private void OkButton_Click(object Sender, EventArgs Event)
 {
     if (NameTextBox.Text != "")
     {
         BrandDAO.EditBrand(int.Parse(BrandNameLabel.Text), NameTextBox.Text);
         this.Close();
     }
     else
     {
         MessageBox.Show("Les champs doivent etre remplient", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #11
0
        public ActionResult FormDeleteBrand()
        {
            BrandDAO dao = new BrandDAO();

            var model = dao.getAllBrands();

            if (model == null)
            {
                return(RedirectToAction("Index", "Home", new { area = "" }));
            }
            return(View(model));
        }
Exemple #12
0
        public async Task <bool> Create(Brand Brand)
        {
            BrandDAO BrandDAO = new BrandDAO();

            BrandDAO.Id         = Brand.Id;
            BrandDAO.Name       = Brand.Name;
            BrandDAO.CategoryId = Brand.CategoryId;

            await DataContext.Brand.AddAsync(BrandDAO);

            await DataContext.SaveChangesAsync();

            Brand.Id = BrandDAO.Id;
            return(true);
        }
Exemple #13
0
        public static async Task ValidateNew(string cnpj)
        {
            try
            {
                Validate(cnpj);
                var exists = await BrandDAO.CheckBrandCnpjExist(cnpj);

                if (exists)
                {
                    throw new ValidationException("CNPJ", "Esse CNPJ de marca já está cadastrado");
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #14
0
        /// <summary>
        /// Créé une nouvelle marque à partir de son nom
        /// </summary>
        /// <param name="NameBrandToSet"></param>
        public Brand(String NameBrandToSet)
        {
            NameBrand = NameBrandToSet;
            RefBrand  = -1;

            int TestRef = -1;

            // Recherche d'un id inutilisé
            while (RefBrand == -1)
            {
                TestRef++;

                if (BrandDAO.GetBrandById(TestRef) == null)
                {
                    RefBrand = TestRef;
                }
            }
        }
Exemple #15
0
        protected void lv_ThongTinSP_ItemDeleting(object sender, ListViewDeleteEventArgs e)
        {
            if (this.objCheckPermision.Permission(this.objCheckPermision.LayQuyen("strThuongHieu_Xoa")))
            {
                var hdf = (this.lv_ThongTinSP.Items[e.ItemIndex].FindControl("hfID")) as HiddenField;

                if (hdf != null)
                {
                    BrandDAO.Delete(Int32.Parse(hdf.Value));
                    this.lv_ThongTinSP.EditIndex = -1;
                    this.BinList();
                }
            }
            else
            {
                this.iRightAccess.Visible = false;
                this.objControl.LoadMyControl(this.idNotPermissionAccess, NotPermissControl);
            }
        }
Exemple #16
0
        /// <summary>
        /// Constructeur de la fenetre
        /// </summary>
        public AddArticleForm()
        {
            InitializeComponent();

            // rempli la combo box marque avec la liste des marques existante
            Brand[] AllBrand = BrandDAO.GetAllBrands();
            foreach (Brand B in AllBrand)
            {
                BrandComboBox.Items.Add(B);
            }

            // rempli la combo box famille avec la liste des familles existante
            Family[] AllFamily = FamilyDAO.GetAllFamilies();
            foreach (Family F in AllFamily)
            {
                FamilyComboBox.Items.Add(F);
            }

            //attend qu'une famille soit sélectionnée
            SubFamilyComboBox.Items.Add("Selectionnez d'abord une famille");
        }
Exemple #17
0
        public ActionResult DeleteBrand(string brand)
        {
            string   rs   = "";
            BrandDAO dao  = new BrandDAO();
            User     user = Session["User"] as User;

            if (user == null || user.LEVEL.Equals("10") == false)
            {
                rs = "user";
            }
            else if (brand == null)
            {
                rs = "null";
            }
            else if (ToolsOfAdmin.checkNull(brand) == false)
            {
                rs = "null";
            }
            else if (ToolsOfAdmin.oneWord(brand) == false)
            {
                rs = "word";
            }
            else if (dao.checkExit(brand) == false)
            {
                rs = "exit";
            }
            else
            {
                var check = dao.delBrand(brand);
                if (check == false)
                {
                    rs = "fail";
                }
                else
                {
                    rs = "success";
                }
            }
            return(Json(new { result = rs }, JsonRequestBehavior.AllowGet));
        }
Exemple #18
0
 protected void lbtnUpdate_Click(object sender, EventArgs e)
 {
     if (this.objCheckPermision.Permission(this.objCheckPermision.LayQuyen("strThuongHieu_Sua")))
     {
         try
         {
             foreach (ListViewDataItem lvit in this.lv_ThongTinSP.Items)
             {
                 string BranchID;
                 if (((HiddenField)lvit.FindControl("hfID")).Value != "")
                 {
                     BranchID = ((HiddenField)lvit.FindControl("hfID")).Value;
                 }
                 else
                 {
                     this.ltr_Notice.Text = this.objComm.ShowNotice(
                         false, "Cập nhật thông tin thất bại.\nLỗi trong quá trình nhận dạng chi nhánh");
                     return;
                 }
                 Brand t0 = BrandDAO.Get(Int32.Parse(BranchID));
                 t0.Name = ((TextBox)lvit.FindControl("txtName")).Text;
                 t0.Note = ((TextBox)lvit.FindControl("txtNote")).Text;
                 ProductDAO.Update();
             }
             this.ltr_Notice.Text = this.objComm.ShowNotice(true, "Cập nhật thông tin thành công!");
         }
         catch (Exception ex)
         {
             this.ltr_Notice.Text = this.objComm.ShowNotice(
                 false, "Cập nhật thông tin thất bại. Chi tiết lỗi: " + ex.Message);
         }
     }
     else
     {
         this.objComm.wr(
             "<script language='javascript'>alert('Bạn không có quyền thực hiện chức năng này.');location.href='thong-tin-san-pham';</script>");
     }
 }
        /// <summary>
        /// Constructeur de la fenetre qui initialise tout les champs à partir des données de l'article modifié
        /// </summary>
        /// <param name="SelectedItem"></param>
        public ModifyArticleForm(ListViewItem SelectedItem)
        {
            InitializeComponent();

            // rempli la combo box marque avec la liste des marques existante
            int Index      = 0;
            int IndexBrand = 0;

            Brand[] AllBrand = BrandDAO.GetAllBrands();
            foreach (Brand B in AllBrand)
            {
                BrandComboBox.Items.Add(B);
                if (B.ToString() == SelectedItem.SubItems[3].Text)
                {
                    IndexBrand = Index;
                }
                Index++;
            }

            BrandComboBox.SelectedIndex = IndexBrand;

            // rempli la combo box famille avec la liste des familles existante
            Index = 0;
            int IndexFamily = 0;

            Family[] AllFamily = FamilyDAO.GetAllFamilies();
            foreach (Family F in AllFamily)
            {
                FamilyComboBox.Items.Add(F);
                if (F.ToString() == SelectedItem.SubItems[4].Text)
                {
                    IndexFamily = Index;
                }
                Index++;
            }

            FamilyComboBox.SelectedIndex = IndexFamily;

            // rempli la combo box sous famille avec la liste des sous familles appartenant à la famille selectionnée
            Index = 0;
            int IndexSubFamily = 0;

            SubFamilyComboBox.Items.Clear();
            SubFamily[] AllLinkedSubFamilies = FamilyDAO.GetAllSubFamilies((Family)FamilyComboBox.SelectedItem);
            foreach (SubFamily SF in AllLinkedSubFamilies)
            {
                SubFamilyComboBox.Items.Add(SF);
                if (SF.ToString() == SelectedItem.SubItems[4].Text)
                {
                    IndexSubFamily = Index;
                }
                Index++;
            }

            SubFamilyComboBox.SelectedIndex = IndexSubFamily;

            // initialise les champs avec les données de l'article modifié
            ArticleNameLabel.Text   = SelectedItem.SubItems[2].Text;
            DescriptionTextBox.Text = SelectedItem.SubItems[1].Text;
            PriceHTTextBox.Text     = SelectedItem.SubItems[6].Text;
            QuantityTextBox.Text    = SelectedItem.SubItems[0].Text;
        }
Exemple #20
0
 private void BinList()
 {
     this.lv_ThongTinSP.DataSource = BrandDAO.Get();
     this.lv_ThongTinSP.DataBind();
 }
Exemple #21
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public BrandBLL(LoggingSessionInfo pUserInfo)
 {
     this.CurrentUserInfo = pUserInfo;
     this._currentDAO     = new BrandDAO(pUserInfo);
 }
Exemple #22
0
        public Brand GetBrandById(int Id)
        {
            BrandDAO brandDAO = new BrandDAO();

            return(brandDAO.GetBrandById(Id));
        }
Exemple #23
0
        public int CreateBrandGet(Brand brand)
        {
            BrandDAO brandDAO = new BrandDAO();

            return(brandDAO.CreateBrandGet(brand));
        }
Exemple #24
0
        public void UpdateBrand(Brand brand)
        {
            BrandDAO brandDAO = new BrandDAO();

            brandDAO.UpdateBrand(brand);
        }
Exemple #25
0
 private static IEnumerable <Brand> GetBrands()
 {
     return(BrandDAO.GetBrands());
 }
Exemple #26
0
 public Brand()
 {
     lBrandDAO = new BrandDAO();
 }
Exemple #27
0
        public void DeleteBrand(int Id)
        {
            BrandDAO brandDAO = new BrandDAO();

            brandDAO.DeleteBrand(Id);
        }
Exemple #28
0
        /// <summary>
        /// Recréer les tableaux en fonctions des données de la bdd pour le mettre à jour
        /// </summary>
        /// <param name="NodeName"></param>
        private void UpdateListView(String NodeName)
        {
            int ColumnsWidth = 0;

            // reinitialise le trie
            MainListView.ListViewItemSorter = null;

            // choisi quel tableau mettre à jour ou créer
            switch (NodeName)
            {
            case "Articles":
                Article[] Articles = ArticleDAO.GetAllArticles();

                MainListView.Columns.Clear();
                MainListView.Items.Clear();
                MainListView.Groups.Clear();
                ColumnsWidth = MainListView.Width / 7;
                MainListView.Columns.Add("Quantité", ColumnsWidth);
                MainListView.Columns.Add("Description", ColumnsWidth);
                MainListView.Columns.Add("Référence", ColumnsWidth);
                MainListView.Columns.Add("Marque", ColumnsWidth);
                MainListView.Columns.Add("Famille", ColumnsWidth);
                MainListView.Columns.Add("Sous-Famille", ColumnsWidth);
                MainListView.Columns.Add("Prix H.T.", ColumnsWidth);
                foreach (Article A in Articles)
                {
                    string[] ArticleToAdd = new string[7];

                    ListViewItem ArticleItem;
                    // ajoute les items a la ListView
                    ArticleToAdd[0] = A.Quantity.ToString();
                    ArticleToAdd[1] = A.Description;
                    ArticleToAdd[2] = A.RefArticle;
                    ArticleToAdd[3] = A.RefBrand.ToString();
                    ArticleToAdd[4] = A.RefSubFamily.RefFamily.ToString();
                    ArticleToAdd[5] = A.RefSubFamily.ToString();
                    ArticleToAdd[6] = A.PriceHT.ToString();
                    ArticleItem     = new ListViewItem(ArticleToAdd);
                    MainListView.Items.Add(ArticleItem);
                }
                break;

            case "Marques":
                Brand[] Brands = BrandDAO.GetAllBrands();

                MainListView.Columns.Clear();
                MainListView.Items.Clear();
                MainListView.Groups.Clear();
                ColumnsWidth = MainListView.Width / 2;
                MainListView.Columns.Add("Nom", ColumnsWidth);
                MainListView.Columns.Add("Référence", ColumnsWidth);
                foreach (Brand B in Brands)
                {
                    string[] BrandToAdd = new string[2];

                    ListViewItem BrandItem;
                    // ajoute les items a la ListView
                    BrandToAdd[0] = B.NameBrand;
                    BrandToAdd[1] = B.RefBrand.ToString();
                    BrandItem     = new ListViewItem(BrandToAdd);
                    MainListView.Items.Add(BrandItem);
                }
                break;

            case "Familles":
                Family[] Families = FamilyDAO.GetAllFamilies();

                MainListView.Columns.Clear();
                MainListView.Items.Clear();
                MainListView.Groups.Clear();
                ColumnsWidth = MainListView.Width / 2;
                MainListView.Columns.Add("Nom", ColumnsWidth);
                MainListView.Columns.Add("Référence", ColumnsWidth);
                foreach (Family F in Families)
                {
                    string[] FamilyToAdd = new string[2];

                    ListViewItem FamilyItem;
                    // ajoute les items a la ListView
                    FamilyToAdd[0] = F.NameFamily;
                    FamilyToAdd[1] = F.RefFamily.ToString();
                    FamilyItem     = new ListViewItem(FamilyToAdd);
                    MainListView.Items.Add(FamilyItem);
                }
                break;

            case "Sous familles":
                SubFamily[] SubFamilies = SubFamilyDAO.GetAllSubFamilies();

                MainListView.Columns.Clear();
                MainListView.Items.Clear();
                MainListView.Groups.Clear();
                ColumnsWidth = MainListView.Width / 3;
                MainListView.Columns.Add("Nom", ColumnsWidth);
                MainListView.Columns.Add("Référence", ColumnsWidth);
                MainListView.Columns.Add("Familles", ColumnsWidth);
                foreach (SubFamily SF in SubFamilies)
                {
                    string[] SubFamilyToAdd = new string[3];

                    ListViewItem SubFamilyItem;
                    // ajoute les items a la ListView
                    SubFamilyToAdd[0] = SF.NameSubFamily;
                    SubFamilyToAdd[1] = SF.RefSubFamily.ToString();
                    SubFamilyToAdd[2] = SF.RefFamily.ToString();
                    SubFamilyItem     = new ListViewItem(SubFamilyToAdd);
                    MainListView.Items.Add(SubFamilyItem);
                }
                break;

            default:
                break;
            }
        }
Exemple #29
0
        public void CreateBrand(Brand brand)
        {
            BrandDAO brandDAO = new BrandDAO();

            brandDAO.CreateBrand(brand);
        }
Exemple #30
0
        public DataTable GetBrandAll(string lang)
        {
            BrandDAO brandDAO = new BrandDAO();

            return(brandDAO.GetBrandAll(lang));
        }