private void btnThem_Click(object sender, EventArgs e)
        {
            HangHoaBUS   hhBUS = new HangHoaBUS();
            string       tenhh = hhBUS.LoadTenhhTheoMaHH((int)cboTenHangHoa.SelectedValue);
            ListViewItem lvi   = new ListViewItem(tenhh);

            lvi.SubItems.Add(nmrSoLuong.Value.ToString());
            lvi.SubItems.Add(((int)cboTenHangHoa.SelectedValue).ToString());

            if (lvwChiTietDDh.Items.Count != 0)
            {
                bool flag = true;
                foreach (ListViewItem item in lvwChiTietDDh.Items)
                {
                    if (item.SubItems[2].Text == ((int)cboTenHangHoa.SelectedValue).ToString())
                    {
                        MessageBox.Show("Hàng hóa đã được thêm gòi nha đừng thêm nữa, ahihi!", "Nhắc nhẹ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        flag = false;
                    }
                }
                if (flag == true)
                {
                    lvwChiTietDDh.Items.Add(lvi);
                }
            }
            else
            {
                lvwChiTietDDh.Items.Add(lvi);
            }
        }
示例#2
0
 private void btnThem_Click(object sender, EventArgs e)
 {
     if (txtGia.Text == "")
     {
         MessageBox.Show(Instance.TBChuaNhapGia, Instance.CanhBao, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else if (!IsNumber(txtGia.Text))
     {
         MessageBox.Show(Instance.TBNhapGiaChuaDungDinhDang, Instance.CanhBao, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         HangHoaBUS   hhBUS = new HangHoaBUS();
         string       tenhh = hhBUS.LoadTenhhTheoMaHH((int)cmbTenHangHoa.SelectedValue);
         ListViewItem lvi   = new ListViewItem(tenhh);
         lvi.SubItems.Add(nmrSoLuong.Value.ToString());
         lvi.SubItems.Add(txtGia.Text);
         double thanhTien = Convert.ToDouble(nmrSoLuong.Value.ToString()) * Convert.ToDouble(txtGia.Text);
         lvi.SubItems.Add(thanhTien.ToString());
         lvi.SubItems.Add(((int)cmbTenHangHoa.SelectedValue).ToString());
         if (lvwChiTietPhieuNhap.Items.Count != 0)
         {
             bool flag = true;
             foreach (ListViewItem item in lvwChiTietPhieuNhap.Items)
             {
                 if (item.SubItems[4].Text == ((int)cmbTenHangHoa.SelectedValue).ToString())
                 {
                     MessageBox.Show(Instance.TBHHDaTonTai, Instance.CanhBao, MessageBoxButtons.OK, MessageBoxIcon.Information);
                     flag = false;
                 }
             }
             if (flag == true)
             {
                 lvwChiTietPhieuNhap.Items.Add(lvi);
             }
         }
         else
         {
             lvwChiTietPhieuNhap.Items.Add(lvi);
         }
     }
 }
 private void btnThem_Click(object sender, EventArgs e)
 {
     if (txtGia.Text == "")
     {
         MessageBox.Show("Bạn chưa nhập giá", "Nhắc nhẹ", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else if (!IsNumber(txtGia.Text))
     {
         MessageBox.Show("Nhập giá chưa đúng định dạng, giá phải là số (số nguyên hoặc số thực)", "Nhắc nhẹ", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         HangHoaBUS   hhBUS = new HangHoaBUS();
         string       tenhh = hhBUS.LoadTenhhTheoMaHH((int)cmbTenHangHoa.SelectedValue);
         ListViewItem lvi   = new ListViewItem(tenhh);
         lvi.SubItems.Add(nmrSoLuong.Value.ToString());
         lvi.SubItems.Add(txtGia.Text);
         double thanhTien = Convert.ToDouble(nmrSoLuong.Value.ToString()) * Convert.ToDouble(txtGia.Text);
         lvi.SubItems.Add(thanhTien.ToString());
         lvi.SubItems.Add(((int)cmbTenHangHoa.SelectedValue).ToString());
         if (lvwChiTietPhieuNhap.Items.Count != 0)
         {
             bool flag = true;
             foreach (ListViewItem item in lvwChiTietPhieuNhap.Items)
             {
                 if (item.SubItems[3].Text == ((int)cmbTenHangHoa.SelectedValue).ToString())
                 {
                     MessageBox.Show("Hàng hóa đã được thêm gòi nha đừng thêm nữa, ahihi!", "Nhắc nhẹ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     flag = false;
                 }
             }
             if (flag == true)
             {
                 lvwChiTietPhieuNhap.Items.Add(lvi);
             }
         }
         else
         {
             lvwChiTietPhieuNhap.Items.Add(lvi);
         }
     }
 }