Exemplo n.º 1
0
        private void simpleButton3_Click(object sender, EventArgs e)
        {
            if (cmbTen.Text == "" & txtSoLuong.Text == "")
            {
                MessageBox.Show("Bạn phải chọn từ Combobox một sản phẩm và nhập vào Textbox một giá trị");
            }
            else if (cmbTen.Text == "")
            {
                MessageBox.Show("Bạn phải chọn từ Combobox một sản phẩm !");
            }
            else if (txtSoLuong.Text == "")
            {
                MessageBox.Show("Bạn phải nhập một giá trị vào Textbox !");
                txtSoLuong.Focus();
            }
            else
            {
                if (trangthai == false)
                {
                    maban = convertToMaBan(cmbBan.Text);
                    magoimon1();
                    try
                    {
                        danhsachgoimonBS bs = new danhsachgoimonBS();
                        bs.themvao_ds_goimon(magm, convertToMaSP(cmbTen.Text), Convert.ToInt32(txtSoLuong.Text));
                    }
                    catch
                    {
                        MessageBox.Show("Đã có lỗi xảy ra trong quá trình thêm");
                    }
                }
                else if (trangthai == true)
                {
                    try
                    {
                        goiMonBS bs = new goiMonBS();
                        bs.danhsach_goimon_themBS(Convert.ToString(ma_goi_mon), convertToMaSP(cmbTen.Text), Convert.ToInt32(txtSoLuong.Text));

                        MessageBox.Show(Convert.ToString(ma_goi_mon));
                        MessageBox.Show(convertToMaSP(cmbTen.Text));
                        MessageBox.Show(txtSoLuong.Text);
                    }
                    catch
                    {
                        MessageBox.Show("Có lỗi xảy ra trong quá trình thêm");
                    }
                }
            }



            loadds_goiMon(laymagoimon());
            lbGia.Text = "" + Convert.ToString(thanhtoan(laymagoimon())) + " vnđ";
        }
Exemplo n.º 2
0
        private void magoimon1()
        {
            danhsachgoimonBS bs = new danhsachgoimonBS();

            List <danhsachGoiMon> ds = bs.lay_magoimon(maban);

            for (int i = 0; i < ds.Count; i++)
            {
                magm = ds[i].ma_goi_mon.ToString();
            }
        }
Exemplo n.º 3
0
        private void loadds_goiMon(string ma)
        {
            listView1.Items.Clear();
            danhsachgoimonBS bs = new danhsachgoimonBS();

            List <danhsachGoiMon> ds = bs.load_ds_goimon(ma);

            for (int i = 0; i < ds.Count; i++)
            {
                listView1.Items.Add(ds[i].ma_sp.ToString());
                listView1.Items[i].SubItems.Add(ds[i].soluong.ToString());
                listView1.Items[i].SubItems.Add(ds[i].ma_sp1.ToString());
                listView1.Items[i].SubItems.Add(ds[i].gia.ToString());
            }
        }
Exemplo n.º 4
0
        private decimal thanhtoan(string ma)
        {
            int                   soluong  = 0;
            decimal               gia      = 0;
            decimal               tongtien = 0;
            danhsachgoimonBS      bs       = new danhsachgoimonBS();
            List <danhsachGoiMon> ds       = bs.load_ds_goimon(ma);

            for (int i = 0; i < ds.Count; i++)
            {
                soluong = Convert.ToInt32(ds[i].soluong.ToString());

                gia = Convert.ToDecimal(ds[i].gia.ToString());

                tongtien += (soluong * gia);
            }
            return(tongtien);
        }