private void PhucVu_Load(object sender, EventArgs e) { //loi chao labelChao.Text = DangNhap._manhanvien; lbBan.Text = DSBan._ban; int ban = int.Parse(lbBan.Text); //neu ban chua dat if (DSBan.mang[ban - 1, 1] == -1) { btnLapHoaDonMoi.Visible = true; btnGiaiPhongBan.Visible = false; } else //neu ban da co { btnLapHoaDonMoi.Visible = false; btnGiaiPhongBan.Visible = true; //load ds loai dataGridView1.DataSource = LoaiMon_BUS.LoadDSLoaiMon(); //load mon an trong hd vao data3 dataGridView3.DataSource = CTHD_BUS.LoadCTHDTheoMHD(DSBan.mang[ban - 1, 1]); //cap nhat lb MHD lbMHD.Text = DSBan.mang[ban - 1, 1].ToString(); //cap nhat tong tien float kq = 0; int dong = dataGridView3.RowCount; for (int i = 0; i < dong; i++) { kq += float.Parse(dataGridView3.Rows[i].Cells[1].Value.ToString()) * float.Parse(dataGridView3.Rows[i].Cells[2].Value.ToString()); } txtTongTien.Text = kq.ToString(); } }
private void btnThemMon_Click(object sender, EventArgs e) { if (txtSoLuong.Text == "") { MessageBox.Show("Vui lòng nhập số lượng!"); } //Them mon vao cthd CTHD_DTO cthd = new CTHD_DTO(int.Parse(lbMHD.Text), lbMon.Text, float.Parse(lbDonGia.Text), int.Parse(txtSoLuong.Text)); bool kq = CTHD_BUS.ThemCTHD(cthd); if (kq == false) { MessageBox.Show("loi!"); } else { dataGridView3.DataSource = CTHD_BUS.LoadCTHDTheoMHD(int.Parse(lbMHD.Text)); } //hien thi ds //cap nhat tong tien float tongtien = 0; int dong = dataGridView3.RowCount; for (int i = 0; i < dong; i++) { tongtien += float.Parse(dataGridView3.Rows[i].Cells[1].Value.ToString()) * float.Parse(dataGridView3.Rows[i].Cells[2].Value.ToString()); } txtTongTien.Text = tongtien.ToString(); }