コード例 #1
0
        private void btnTaoPhieuNhapHang_Click(object sender, EventArgs e)
        {
            if (lvwChiTietPhieuNhap.Items.Count == 0)
            {
                MessageBox.Show(Instance.TBChuaThemHHVaoDDH, Instance.Loi, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                double tongTien = 0;
                foreach (ListViewItem item in lvwChiTietPhieuNhap.Items)
                {
                    if (item.SubItems[2].Text == "")
                    {
                        MessageBox.Show(Instance.TBChuaNhapDayDuGia, Instance.CanhBao, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        tongTien += Convert.ToDouble(item.SubItems[1].Text) * Convert.ToDouble(item.SubItems[2].Text);
                    }
                }
                PhieuNhapHangDTO pnhDTO = new PhieuNhapHangDTO();
                pnhDTO.Manvlap  = tkGlobal.Manv;
                pnhDTO.Maddh    = Convert.ToInt32(cboDonDatHang.SelectedValue);
                pnhDTO.Mancc    = Convert.ToInt32(cboNhaCungCap.SelectedValue);
                pnhDTO.Tongtien = tongTien;

                PhieuNhapHangBUS pnhBUS = new PhieuNhapHangBUS();
                int mapnh;
                if (pnhBUS.ThemPNH(pnhDTO, out mapnh))
                {
                    foreach (ListViewItem item in lvwChiTietPhieuNhap.Items)
                    {
                        ChiTietPhieuNhapHangBUS ctBUS = new ChiTietPhieuNhapHangBUS();
                        ChiTietPhieuNhapHangDTO ctDTO = new ChiTietPhieuNhapHangDTO();

                        ctDTO.Mapnh   = mapnh;
                        ctDTO.Mahh    = Convert.ToInt32(item.SubItems[4].Text);
                        ctDTO.Soluong = Convert.ToInt32(item.SubItems[1].Text);
                        ctDTO.Gia     = Convert.ToInt32(item.SubItems[2].Text);
                        ctBUS.ThemChiTietPNH(ctDTO);
                    }
                    MessageBox.Show(Instance.TBTaoPhieuNhapThanhCong, Instance.ThanhCong, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadDsPNH();
                }
                else
                {
                    MessageBox.Show(Instance.TBTaoPhieuNhapThatBai, Instance.Loi, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #2
0
        private void btnTaoPhieuNhapHang_Click(object sender, EventArgs e)
        {
            if (lvwChiTietPhieuNhap.Items.Count == 0)
            {
                MessageBox.Show("Bạn chưa thêm hàng hóa vào đơn đặt hàng!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                double tongTien = 0;
                foreach (ListViewItem item in lvwChiTietPhieuNhap.Items)
                {
                    if (item.SubItems[2].Text == "")
                    {
                        MessageBox.Show("Bạn chưa nhập đầy đủ giá, hãy nhập thêm giá!", "Nhập thiếu thông tin", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        tongTien += Convert.ToDouble(item.SubItems[1].Text) * Convert.ToDouble(item.SubItems[2].Text);
                    }
                }
                PhieuNhapHangDTO pnhDTO = new PhieuNhapHangDTO();
                pnhDTO.Manvlap  = tkGlobal.Manv;
                pnhDTO.Maddh    = Convert.ToInt32(cboDonDatHang.SelectedValue);
                pnhDTO.Mancc    = Convert.ToInt32(cboNhaCungCap.SelectedValue);
                pnhDTO.Tongtien = tongTien;

                PhieuNhapHangBUS pnhBUS = new PhieuNhapHangBUS();
                int mapnh;
                if (pnhBUS.ThemPNH(pnhDTO, out mapnh))
                {
                    foreach (ListViewItem item in lvwChiTietPhieuNhap.Items)
                    {
                        ChiTietPhieuNhapHangBUS ctBUS = new ChiTietPhieuNhapHangBUS();
                        ChiTietPhieuNhapHangDTO ctDTO = new ChiTietPhieuNhapHangDTO();

                        ctDTO.Mapnh   = mapnh;
                        ctDTO.Mahh    = Convert.ToInt32(item.SubItems[4].Text);
                        ctDTO.Soluong = Convert.ToInt32(item.SubItems[2].Text);
                        ctDTO.Gia     = Convert.ToInt32(item.SubItems[1].Text);
                        ctBUS.ThemChiTietPNH(ctDTO);
                    }
                    MessageBox.Show("Tạo phiếu nhập thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadDsPNH();
                }
                else
                {
                    MessageBox.Show("Tạo phiếu nhập thất bại!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #3
0
ファイル: frmMuaHang.cs プロジェクト: vinhphat863/DoAnLTUDQL
 private void simpleButton3_Click(object sender, EventArgs e)
 {
     PhieuNhapHangBUS.Them(txtPhieu.Text, txtMaNCC.EditValue.ToString(), txtDiaChi.Text, txtDienThoai.Text, Ngay.DateTime, txtGhiChu.Text, txtHoaDonVAT.Text, txtPhieuVietTay.Text, txtNhanVien.EditValue.ToString(), txtKho.EditValue.ToString(), txtDieuKhoanTT.EditValue.ToString(), txtHinhThucTT.EditValue.ToString(), HanTT.DateTime);
     for (int i = 0; i < gridView2.RowCount - 1; i++)
     {
         string MaHang  = gridView2.GetRowCellValue(i, "MaHang").ToString();
         string MaDonVi = gridView2.GetRowCellValue(i, "TenDonVi").ToString();
         int    SoLuong = (int)gridView2.GetRowCellValue(i, "SoLuong");
         double DonGia  = (double)gridView2.GetRowCellValue(i, "DonGia");
         string GhiChu  = gridView2.GetRowCellValue(i, "GhiChu").ToString();
         ChiTietPhieuNhapHangBUS.Them(txtPhieu.Text, MaHang, MaDonVi, SoLuong, DonGia, GhiChu);
     }
     ClearAllTxt();
 }
コード例 #4
0
        private void dtgvPhieuNhapHang_MouseClick(object sender, MouseEventArgs e)
        {
            lvwChiTietPhieuNhap.Items.Clear();
            int mapnh = Convert.ToInt32(dtgvPhieuNhapHang.SelectedCells[0].OwningRow.Cells["colMaPNH"].Value.ToString());
            ChiTietPhieuNhapHangBUS        ctBUS = new ChiTietPhieuNhapHangBUS();
            List <ChiTietPhieuNhapHangDTO> dsct  = ctBUS.LoadDsChiTietPNHTheoMa(mapnh);

            foreach (ChiTietPhieuNhapHangDTO ct in dsct)
            {
                ListViewItem lvi = new ListViewItem(ct.Tenhh);
                lvi.SubItems.Add(ct.Gia.ToString());
                lvi.SubItems.Add(ct.Soluong.ToString());
                lvi.SubItems.Add((ct.Soluong * ct.Gia).ToString());
                lvi.SubItems.Add(ct.Mahh.ToString());
                lvwChiTietPhieuNhap.Items.Add(lvi);
            }
        }