Exemplo n.º 1
0
        public bool themCT_PhieuDatBan(DTO_CT_PhieuDatBan ct_pdb)
        {
            //ket noi
            SQLiteConnection connect = db.getConnection();

            connect.Open();
            try
            {
                string        SQL = string.Format("INSERT INTO PhieuDatBan(matieccuoi,mamonan,ghichu) VALUES('{0}', '{1}', '{2}');", ct_pdb.MaTiecCuoi, ct_pdb.MaMonAn, ct_pdb.GhiChu);
                SQLiteCommand cmd = new SQLiteCommand(SQL, connect);
                if (cmd.ExecuteNonQuery() > 0)
                {
                    Console.WriteLine($"THEM PHIEU DAT MON THANH CONG");
                    return(true);
                }
            }
            catch (Exception e)
            {
            }
            finally
            {
                //dong ket noi
                connect.Close();
            }
            return(false);
        }
        private void btnChonMon_Click(object sender, EventArgs e)
        {
            //kiểm tra box rỗng
            if (txtDonGiaYeuCau.Text == string.Empty)
            {
                txtDonGiaYeuCau.Text = lblDonGiaMacDinh.Text.Substring(0, lblDonGiaMacDinh.Text.Length - 4);
            }
            //Check giá trị món ăn đặt
            if (!CheckRightTienDatCoc(txtDonGiaYeuCau.Text))
            {
                MessageBox.Show("Đơn giá đặt món ăn phải là bội số của 500 đồng", "Thông báo");
                return;
            }
            if (txtSoLuongBan.Text == "")
            {
                MessageBox.Show("Số lượng bàn không được để trống", "Thông báo");
                return;
            }
            int index = cboDanhSachMonAn.SelectedIndex;

            if (!lstMonAnInsert.Contains(Int32.Parse(dtMonAn.Rows[index][0].ToString())))
            {
                DTO_CT_PhieuDatBan phieudatban = new DTO_CT_PhieuDatBan();
                //phieudatban.MaPhieuDatBan = ???
                //phieudichvu.MaTiecCuoi = ???
                try
                {
                    phieudatban.MaMonAn = Int32.Parse(dtMonAn.Rows[index][0].ToString());
                    if (txtDonGiaYeuCau.Text == string.Empty)
                    {
                        txtDonGiaYeuCau.Text = lblDonGiaMacDinh.Text.Substring(0, lblDonGiaMacDinh.Text.Length - 4);
                        phieudatban.DonGia   = Convert.ToDecimal(txtDonGiaYeuCau.Text);
                    }
                    else
                    {
                        phieudatban.DonGia = Convert.ToDecimal(txtDonGiaYeuCau.Text);
                    }
                    phieudatban.SoLuong = Int32.Parse(txtSoLuongBan.Text);
                    lstChiTietDatBan.Add(phieudatban);
                    //add danh sách món ăn đã chọn
                    DTO_MonAn monan = new DTO_MonAn();
                    monan.MaMonAn  = Int32.Parse(dtMonAn.Rows[index][0].ToString());
                    monan.TenMonAn = dtMonAn.Rows[index][1].ToString();
                    monan.DonGia   = phieudatban.DonGia;
                    monan.HinhAnh  = dtMonAn.Rows[index][3].ToString();
                    lstMonAnInsert.Add(monan.MaMonAn);
                    InsertNewMonAn(monan);
                }
                catch (Exception ex)
                {
                    return;
                }
            }
            else
            {
                MessageBox.Show("Món ăn này đã được đặt ", "Thông báo");
            }
        }
Exemplo n.º 3
0
        public List <DTO_CT_PhieuDatBan> LoadDuLieuMA()
        {
            List <DTO_CT_PhieuDatBan> listSDT = new List <DTO_CT_PhieuDatBan>();

            SQLiteDataAdapter da    = new SQLiteDataAdapter("SELECT * FROM PhieuDatBan", db.getConnection());
            DataTable         table = new DataTable();

            foreach (DataRow item in table.Rows)
            {
                DTO_CT_PhieuDatBan SDT = new DTO_CT_PhieuDatBan(item);
                listSDT.Add(SDT);
            }
            return(listSDT);
        }
Exemplo n.º 4
0
        public static bool InsertChiTietDatBan(DTO_CT_PhieuDatBan ctphieudatban)
        {
            string sTruyVan = string.Format("Insert into CT_PHIEUDATBAN(MaPhieuDatBan, MaMonAn,DonGia, SoLuong, GhiChu) values({0},{1},{2},{3},N'{4}')",
                                            ctphieudatban.MaPhieuDatBan, ctphieudatban.MaMonAn, ctphieudatban.DonGia, ctphieudatban.SoLuong, ctphieudatban.GhiChu);

            try
            {
                int state = DatabaseHelper.ExcuteSql(sTruyVan);
                if (state > 0)
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(false);
        }
Exemplo n.º 5
0
        private void btn_Chon_Click(object sender, EventArgs e)
        {
            DTO_CT_PhieuDatBan r = new DTO_CT_PhieuDatBan(MaTiecCuoi, textBoxMaMonAn.Text, textBoxGhiChu.Text);

            //Console.WriteLine($" ma tiec cuoi = {this.MaTiecCuoi}");
            if (busTC.themCT_PhieuDatBan(r))
            {
                maMonAn = "";
                donGia  = "";
                ghiChu  = "";
                dgv_DaDat.DataSource = busTC.getMonAnDaDat(MaTiecCuoi);

                //MessageBox.Show("Đặt món ăn thành công");
                resetForm();
            }
            else
            {
                MessageBox.Show("Món đã được đặt rồi");
            }
        }
Exemplo n.º 6
0
 public static bool InsertChiTietDatBan(DTO_CT_PhieuDatBan ctphieudatban)
 {
     return(DAO_NhanDatTiecCuoi.InsertChiTietDatBan(ctphieudatban));
 }
Exemplo n.º 7
0
 public bool themCT_PhieuDatBan(DTO_CT_PhieuDatBan ct_pdb)
 {
     return(dalTiecCuoi.themCT_PhieuDatBan(ct_pdb));
 }