Exemple #1
0
 private void btThem_Click(object sender, EventArgs e)
 {
     if (dg_monan_ofban.Rows.Count == 0)
     {
         MessageBox.Show("Chọn một bàn rồi thêm món.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (cbten.Text == "")
     {
         MessageBox.Show("Chưa chọn món.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         CTHD_PUBLIC cthd_public = new CTHD_PUBLIC();
         BAN_PUBLIC  b_public    = new BAN_PUBLIC();
         cthd_public.IDHOADON = idhd;
         cthd_public.IDDOUONG = int.Parse(cbiddouong.Text);
         cthd_public.SOLUONG  = (int)numericsoluongdoan.Value;
         cthd_bul.insert_cthd(cthd_public);
         b_public.IDBAN     = idban;
         b_public.TRANGTHAI = "Có người";
         ban_bul.update_trangthaiban(b_public);
         if (trangthaiban == "Trống")
         {
             taobanan();
         }
         Load_CTHD(idhd);
     }
 }
Exemple #2
0
        private void Load_CTHD(int mahoadon)
        {
            CTHD_PUBLIC cthd_public = new CTHD_PUBLIC();

            cthd_public.IDHOADON      = mahoadon;
            bindingSource1.DataSource = cthd_bul.load_cthd_thanhtoan(cthd_public);
            dg_monan_ofban.DataSource = bindingSource1;
            dinhdangluoi();
        }
Exemple #3
0
        public DataTable load_cthd_thanhtoan(CTHD_PUBLIC cthd_public)
        {
            int parameter = 1;

            string[] name   = new string[parameter];
            object[] values = new object[parameter];
            name[0]   = "@IDHOADON";
            values[0] = cthd_public.IDHOADON;
            string sql = "LOAD_CTHD_thanhtoan";

            return(ketnoi.LoadDataWithParameter(sql, name, values, parameter));
        }
Exemple #4
0
        public int delete_cthd(CTHD_PUBLIC cthd_public)
        {
            int parameter = 2;

            string[] name   = new string[parameter];
            object[] values = new object[parameter];
            name[0]   = "@IDHOADON";
            name[1]   = "@IDDOUONG";
            values[0] = cthd_public.IDHOADON;
            values[1] = cthd_public.IDDOUONG;
            string sql = "DELETE_CTHD";

            return(ketnoi.Excute_Data(sql, name, values, parameter));
        }
Exemple #5
0
 private void btXoa_Click(object sender, EventArgs e)
 {
     if (dg_monan_ofban.Rows.Count == 0)
     {
         MessageBox.Show("Chọn một bàn rồi nhấn vào danh sánh món ăn muốn xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         CTHD_PUBLIC cthd_public = new CTHD_PUBLIC();
         cthd_public.IDHOADON = MAHOADON_XOA;
         cthd_public.IDDOUONG = MADOUONG_XOA;
         cthd_bul.delete_cthd(cthd_public);
         Load_CTHD(idhd);
     }
 }
Exemple #6
0
        public int insert_cthd(CTHD_PUBLIC cthd_public)
        {
            int parameter = 3;

            string[] name   = new string[parameter];
            object[] values = new object[parameter];
            name[0]   = "@IDHOADON";
            name[1]   = "@IDDOUONG";
            name[2]   = "@SOLUONG";
            values[0] = cthd_public.IDHOADON;
            values[1] = cthd_public.IDDOUONG;
            values[2] = cthd_public.SOLUONG;
            string sql = "INSERT_CTHD";

            return(ketnoi.Excute_Data(sql, name, values, parameter));
        }
Exemple #7
0
        private void btthanhtoan_Click(object sender, EventArgs e)
        {
            HOADON_OLD_PUBLIC hd_old_public = new HOADON_OLD_PUBLIC();

            hd_old_public.IDHOADON  = idhoadon;
            hd_old_public.IDBAN     = Idban;
            hd_old_public.IDNV      = Idnv;
            hd_old_public.NGAYLAP   = DateTime.Now;
            hd_old_public.TRANGTHAI = "Rồi";
            hd_old_public.TONGTIEN  = double.Parse(txttongtien.Text);
            hd_old_bul.insert_hoadon_old(hd_old_public);
            CTHD_OLD_PUBLIC cthd_old_public = new CTHD_OLD_PUBLIC();

            for (int i = 0; i < dg_monan_ofban.Rows.Count - 1; i++)
            {
                cthd_old_public.IDHOADON_OLD = idhoadon;
                cthd_old_public.IDDOUONG     = int.Parse(dg_monan_ofban[0, i].Value.ToString());
                cthd_old_public.SOLUONG      = int.Parse(dg_monan_ofban[2, i].Value.ToString());
                cthd_old_bul.insert_cthd_old(cthd_old_public);
            }
            // delete CTHD
            CTHD_PUBLIC cthd_public = new CTHD_PUBLIC();

            for (int j = 0; j < dg_monan_ofban.Rows.Count - 1; j++)
            {
                cthd_public.IDHOADON = idhoadon;
                cthd_public.IDDOUONG = int.Parse(dg_monan_ofban[0, j].Value.ToString());
                cthd_bul.delete_cthd(cthd_public);
            }
            HOADON_PUBLIC hd_public = new HOADON_PUBLIC();

            hd_public.IDHOADON = idhoadon;
            hd_bul.delete_hoadon(hd_public);
            // update trạng thái bàn
            BAN_PUBLIC ban_public = new BAN_PUBLIC();

            ban_public.IDBAN     = idban;
            ban_public.TRANGTHAI = "Trống";
            ban_bul.update_trangthaiban(ban_public);
            inhoadon();
            this.Close();
        }
Exemple #8
0
 private void btgop_Click(object sender, EventArgs e)
 {
     if (cbbanconguoi.Text == cbbanconguoi1.Text)
     {
         MessageBox.Show("Không thể gộp 2 bàn giống nhau.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         HOADON_PUBLIC hd_public = new HOADON_PUBLIC();
         hd_public.IDBAN = int.Parse(cbmabanconguoi.Text);
         int         idhoadon    = hd_bul.load_IDHD_WITH_IDBAN(hd_public);
         CTHD_PUBLIC cthd_public = new CTHD_PUBLIC();
         cthd_public.IDHOADON = idhoadon;
         dg_cthd.DataSource   = cthd_bul.load_cthd(cthd_public);
         hd_public.IDBAN      = int.Parse(cbmabanconguoi1.Text);
         int idhoadon1 = hd_bul.load_IDHD_WITH_IDBAN(hd_public);
         cthd_public.IDHOADON = idhoadon1;
         for (int i = 0; i < dg_cthd.Rows.Count - 1; i++)
         {
             cthd_public.IDDOUONG = int.Parse(dg_cthd["IDDOUONG", i].Value.ToString());
             cthd_public.SOLUONG  = int.Parse(dg_cthd["SOLUONG", i].Value.ToString());
             cthd_bul.insert_cthd(cthd_public); // insert cthd vào bạn nhận
         }
         cthd_public.IDHOADON = idhoadon;       // set lại mã hóa đơn cũ
         for (int j = 0; j < dg_cthd.Rows.Count - 1; j++)
         {
             cthd_public.IDDOUONG = int.Parse(dg_cthd["IDDOUONG", j].Value.ToString());
             cthd_bul.delete_cthd(cthd_public);
         }
         hd_public.IDBAN = int.Parse(cbmabanconguoi.Text);
         hd_bul.delete_hoadon_with_idban(hd_public);
         BAN_PUBLIC ban_public = new BAN_PUBLIC();
         ban_public.IDBAN     = int.Parse(cbmabanconguoi.Text);
         ban_public.TRANGTHAI = "Trống";
         ban_bul.update_trangthaiban(ban_public);
         this.Close();
     }
 }
Exemple #9
0
 public DataTable load_cthd_thanhtoan(CTHD_PUBLIC cthd_public)
 {
     return(cthd_dal.load_cthd_thanhtoan(cthd_public));
 }
Exemple #10
0
 public int delete_cthd(CTHD_PUBLIC cthd_public)
 {
     return(cthd_dal.delete_cthd(cthd_public));
 }
Exemple #11
0
 public int update_cthd(CTHD_PUBLIC cthd_public)
 {
     return(cthd_dal.update_cthd(cthd_public));
 }
Exemple #12
0
 public int insert_cthd(CTHD_PUBLIC cthd_public)
 {
     return(cthd_dal.insert_cthd(cthd_public));
 }