Example #1
0
        public static ArrayList getAllMatHangFromNganhHang(int idNganhHang)
        {
            ArrayList dataList = new ArrayList();

            try
            {
                DataSet dataSet = MatHangDAO.getMatHangFromIdNganhHang(idNganhHang);

                foreach (DataRow row in dataSet.Tables[0].Rows)
                {
                    int    id         = Convert.ToInt32(row["id"]);
                    string tenMatHang = row["tenMatHang"].ToString();
                    //int idNganhHang1 = Convert.ToInt32(row["idNganhHang"]);
                    float   donGian = (float)Convert.ToDouble(row["donGia"]);
                    int     soLuong = Convert.ToInt32(row["soLuong"]);
                    MatHang matHang = new MatHang(id, tenMatHang, idNganhHang, donGian, soLuong);
                    dataList.Insert(0, matHang);
                }
            }
            catch (SqlException e)
            {
            }

            return(dataList);
        }
        public ActionResult Index2()
        {
            var dao   = new MatHangDAO();
            var model = dao.ShowAllGear();

            //   return View();
            return(View(model));
        }
Example #3
0
        public static bool deleteMatHang(int id)
        {
            bool kt = true;

            try
            {
                MatHangDAO.deleteMatHang(id);
            }
            catch (SqlException e)
            {
                kt = false;
            }
            return(kt);
        }
Example #4
0
        public static bool updateMatHang(MatHang matHang)
        {
            bool kt = true;

            try
            {
                MatHangDAO.updateMatHang(matHang.id, matHang.tenMatHang, matHang.idNganhHang, matHang.donGia, matHang.soLuong);
            }
            catch (SqlException e)
            {
                kt = false;
            }
            return(kt);
        }
Example #5
0
        public static bool addMatHang(MatHang matHang)
        {
            bool kt = true;

            try
            {
                MatHangDAO.addMatHang(matHang.tenMatHang, matHang.idNganhHang, matHang.donGia);
            }
            catch (SqlException e)
            {
                kt = false;
            }
            return(kt);
        }
Example #6
0
        public void getMatHangFromIdNganhHangTest()
        {
            DataSet list = MatHangDAO.getMatHangFromIdNganhHang(20);

            List <MatHang> matHang = new List <MatHang>();

            foreach (DataRow row in list.Tables[0].Rows)
            {
                int    id          = Convert.ToInt32(row["id"]);
                string tenMatHang  = row["tenMatHang"].ToString();
                int    idNganhHang = Convert.ToInt32(row["idNganhHang"]);
                float  donGian     = (float)Convert.ToDouble(row["donGia"]);
                int    soLuong     = Convert.ToInt32(row["soLuong"]);
                matHang.Add(new MatHang(id, tenMatHang, idNganhHang, donGian, soLuong));
            }

            Assert.IsTrue(matHang[0].tenMatHang == "Mì ly");
            Assert.IsTrue(matHang[1].tenMatHang == "Poca");
        }
Example #7
0
        private void btnDatMon_Click(object sender, EventArgs e)
        {
            int idtable;

            try
            {
                idtable = (int)dgvChiTietNhapMain.Tag;
            }
            catch
            {
                MessageBox.Show("Bạn cần phải lựa chọn bàn ăn trước khi thêm món", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            int mamh    = (int)cboDanhSachMatHang.SelectedValue;
            int soluong = (int)SpinEditSoLuong.Value;

            int mahdb = HoaDonBanDAO.LayHoaDonTheoBan(idtable);

            if (MatHangDAO.CheckHangTonKho(mamh, soluong) == 1)
            {
                if (mahdb == -1)
                {
                    HoaDonBanDAO.InsertHoaDonBan(idtable);
                    ChiTietBan.InsertChiTietBan(HoaDonBanDAO.LayHoaDonBanMax(), mamh, soluong);
                    mahdb = HoaDonBanDAO.LayHoaDonTheoBan(idtable);
                    ChangeImageTable(idtable, 1);
                }
                else
                {
                    ChiTietBan.InsertChiTietBan(mahdb, mamh, soluong);
                }
            }
            else
            {
                MessageBox.Show("Không đủ hàng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            HienThiHoaDon(idtable);
            TongTien(mahdb);
        }
Example #8
0
        public static MatHang getMatHang(int idNganhHang)
        {
            MatHang matHang = null;

            try
            {
                DataSet dataSet = MatHangDAO.getMatHang(idNganhHang);

                DataRow row = dataSet.Tables[0].Rows[0];

                int    id         = Convert.ToInt32(row["id"]);
                string tenMatHang = row["tenMatHang"].ToString();
                //int idNganhHang1 = Convert.ToInt32(row["idNganhHang"]);
                float donGian = (float)Convert.ToDouble(row["donGia"]);
                int   soLuong = Convert.ToInt32(row["soLuong"]);
                matHang = new MatHang(id, tenMatHang, idNganhHang, donGian, soLuong);
            }
            catch (SqlException e)
            {
            }
            return(matHang);
        }
Example #9
0
 void LayDanhSachMatHang()
 {
     cboDanhSachMatHang.DataSource    = MatHangDAO.DanhSachMatHang();
     cboDanhSachMatHang.DisplayMember = "TENMH";
     cboDanhSachMatHang.ValueMember   = "MAMH";
 }