示例#1
0
        void xoasp(int idsp)
        {
            int index = -1;

            foreach (SanPhamGoi_DTO spdg in listSPTong)
            {
                if (spdg.Id == idsp)
                {
                    index = listSPTong.IndexOf(spdg);
                }
            }
            if (index != -1)
            {
                listSPTong.RemoveAt(index);

                CTHD_DAO.Instance.deleteCTHD(idban, idsp);

                fldagoi.Controls.Clear();

                foreach (SanPhamGoi_DTO spdg in listSPTong)
                {
                    UCSpDG uCSp = new UCSpDG();
                    uCSp.Name1   = spdg.Name;
                    uCSp.Sl      = spdg.Sl;
                    uCSp.Idsp    = spdg.Id;
                    uCSp.delete += xoasp;
                    uCSp.loadinfo();
                    fldagoi.Controls.Add(uCSp);
                }



                if (listdg.Count == 0)
                {
                    HoaDon_DAO.Instance.deleteHD(idban);
                    Ban_DAO.Instance.updateTable(idban, 0);
                    changestt(true);
                }
            }
        }
示例#2
0
        void load()
        {
            flMenu.Controls.Clear();
            listMenu.Clear();
            listMenu = Sanpham_DAO.Instance.getlist();
            foreach (SanPham_DTO sp in listMenu)
            {
                UCMenu uCMenu = new UCMenu();
                uCMenu.Name1  = sp.Name;
                uCMenu.Price  = sp.Dongia;
                uCMenu.Sl     = sp.Sl;
                uCMenu.Idban  = idban;
                uCMenu.Id     = sp.Id;
                uCMenu.addsp += AddSP;
                uCMenu.loadinfo();
                flMenu.Controls.Add(uCMenu);
            }

            listCT = CTHD_DAO.Instance.getbyid(idban);
            foreach (CTHD_DTO hd in listCT)
            {
                SanPhamGoi_DTO sp = new SanPhamGoi_DTO(hd.IdSP, idban, hd.SL1, hd.Name);
                listdg.Add(sp);
            }


            foreach (SanPhamGoi_DTO spdg in listdg)
            {
                UCSpDG uCSp = new UCSpDG();
                uCSp.Name1   = spdg.Name;
                uCSp.Sl      = spdg.Sl;
                uCSp.Idsp    = spdg.Id;
                uCSp.delete += xoasp;
                uCSp.loadinfo();
                fldagoi.Controls.Add(uCSp);

                listSPTong.Add(spdg);
            }
        }
示例#3
0
        public void AddSP(int idsp, int sl, string name)
        {
            bool flag  = true;
            int  index = 0;

            foreach (SanPhamGoi_DTO spg in listSPTong)
            {
                if (idsp == spg.Id)
                {
                    index = listSPTong.IndexOf(spg);
                    flag  = false;
                }
            }

            if (flag)
            {
                SanPhamGoi_DTO sp = new SanPhamGoi_DTO(idsp, idban, sl, name);
                //listSP.Add(sp);
                listSPTong.Add(sp);
            }
            else
            {
                listSPTong[index].Sl = sl;
            }

            fldagoi.Controls.Clear();
            foreach (SanPhamGoi_DTO spdg in listSPTong)
            {
                UCSpDG uCSp = new UCSpDG();
                uCSp.Name1   = spdg.Name;
                uCSp.Sl      = spdg.Sl;
                uCSp.Idsp    = spdg.Id;
                uCSp.delete += xoasp;
                uCSp.loadinfo();
                fldagoi.Controls.Add(uCSp);
            }
        }