Exemplo n.º 1
0
        public int xuLySoLuong(int idNUT, int soLuong)
        {
            NuocUongThe nut = new NuocUongThe();

            nut         = dsnuRepository.GetBy(idNUT);
            nut.SoLuong = soLuong;
            NuocUong nu = new NuocUong();

            nu = nuRepository.GetBy(nut.IdNU);
            var tongTien = nu.DonGia * soLuong;

            nut.TongTien = tongTien;
            dsnuRepository.Update(nut);
            return(tongTien);
        }
Exemplo n.º 2
0
        public string xuLyXoaNU(int idThe, int idNUT)
        {
            string      code = "";
            NuocUongThe nut  = dsnuRepository.GetBy(idNUT);

            dsnuRepository.Remove(nut);
            var dsnu = dsnuRepository.GetAll();
            var nus  = nuRepository.GetAll();

            code = code + "<table class='table'>";
            code = code + "<thead>";
            code = code + "<tr>";
            code = code + "<th>Nuoc uong</th>";
            code = code + "<th>So luong</th>";
            code = code + "<th>Tong tien</th>";
            code = code + "</tr>";
            code = code + "</thead>";
            foreach (var nut1 in dsnu)
            {
                if (nut1.IdThe == idThe)
                {
                    int donGia = 0;
                    code = code + "<tr>";
                    foreach (var nu in nus)
                    {
                        if (nut1.IdNU == nu.Id)
                        {
                            code   = code + "<td>" + nu.TenNU + "</td>";
                            donGia = nu.DonGia;
                            break;
                        }
                    }
                    code = code + "<td>";
                    code = code + "<input name='giam' type='button' value='-' onclick='giamSoLuong(" + donGia + ", " + nut1.Id + ");'>";
                    code = code + "<input id='soLuong " + nut1.Id + "' type='text' value='" + nut1.SoLuong + "' style='text-align: center; width: 30px;' onchange='tongTien(" + donGia + ", " + nut.Id + ");'>";
                    code = code + "<input name='tang' type='button' value='+' onclick='tangSoLuong(" + donGia + ", " + nut1.Id + ");'>";
                    code = code + "</td>";
                    code = code + "<td id='tongTien " + nut1.Id + "'>" + nut1.TongTien + "</td>";
                    code = code + "<td><input type='button' value='Xoa' onclick='xoaNU(" + idThe + ", " + @nut1.Id + ")'></td>";
                    code = code + "</tr>";
                }
            }
            code = code + "</table>";
            return(code);
        }
Exemplo n.º 3
0
 public void Update(NuocUongThe nut)
 {
     context.DSNU.Update(nut);
     context.SaveChanges();
 }
Exemplo n.º 4
0
 public void Remove(NuocUongThe nut)
 {
     context.DSNU.Remove(nut);
     context.SaveChanges();
 }
Exemplo n.º 5
0
 public void Add(NuocUongThe nut)
 {
     context.DSNU.Add(nut);
     context.SaveChanges();
 }
Exemplo n.º 6
0
        public string xuLyThemNuocUong(int idNU, int idThe)
        {
            string code  = "";
            var    dsnu  = dsnuRepository.GetAll();
            var    nus   = nuRepository.GetAll();
            int    idNUT = 0;

            foreach (var nut in dsnu)
            {
                if (nut.IdNU == idNU && nut.IdThe == idThe)
                {
                    idNUT = nut.Id;
                }
            }
            if (idNUT == 0)
            {
                var         nu  = nuRepository.GetBy(idNU);
                NuocUongThe nut = new NuocUongThe();
                nut.IdThe    = idThe;
                nut.IdNU     = idNU;
                nut.SoLuong  = 1;
                nut.TongTien = nu.DonGia;
                dsnuRepository.Add(nut);
            }
            else
            {
                var nu  = nuRepository.GetBy(idNU);
                var nut = dsnuRepository.GetBy(idNUT);
                nut.SoLuong  = nut.SoLuong + 1;
                nut.TongTien = nu.DonGia * nut.SoLuong;
                dsnuRepository.Update(nut);
            }
            dsnu = dsnuRepository.GetAll();
            code = code + "<table class='table'>";
            code = code + "<thead>";
            code = code + "<tr>";
            code = code + "<th>Nuoc uong</th>";
            code = code + "<th>So luong</th>";
            code = code + "<th>Tong tien</th>";
            code = code + "</tr>";
            code = code + "</thead>";
            foreach (var nut in dsnu)
            {
                if (nut.IdThe == idThe)
                {
                    int donGia = 0;
                    code = code + "<tr>";
                    foreach (var nu in nus)
                    {
                        if (nut.IdNU == nu.Id)
                        {
                            code   = code + "<td>" + nu.TenNU + "</td>";
                            donGia = nu.DonGia;
                            break;
                        }
                    }
                    code = code + "<td>";
                    code = code + "<input name='giam' type='button' value='-' onclick='giamSoLuong(" + donGia + ", " + nut.Id + ");'>";
                    code = code + "<input id='soLuong " + nut.Id + "' type='text' value='" + nut.SoLuong + "' style='text-align: center; width: 30px;' onchange='tongTien(" + donGia + ", " + nut.Id + ");'>";
                    code = code + "<input name='tang' type='button' value='+' onclick='tangSoLuong(" + donGia + ", " + nut.Id + ");'>";
                    code = code + "</td>";
                    code = code + "<td id='tongTien " + nut.Id + "'>" + nut.TongTien + "</td>";
                    code = code + "<td><input type='button' value='Xoa' onclick='xoaNU(" + idThe + ", " + nut.Id + ")'></td>";
                    code = code + "</tr>";
                }
            }
            code = code + "</table>";
            return(code);
        }