Ejemplo n.º 1
0
 public static bool ThemPhieuNhap(PhieuNhap_DTO phieunhap)
 {
     return(DSphieunhap_DAO.ThemPhieuNhap(phieunhap));
 }
Ejemplo n.º 2
0
        // Button thêm phiếu nhập
        private void gunaAdvenceButton4_Click(object sender, EventArgs e)
        {
            if (TKDN.Substring(0, 2) == "NV")
            {
                MessageBox.Show("Chỉ có chức vụ quản lý mới được sử dụng chức năng này.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                if (cBMaNL.Text == "")
                {
                    MessageBox.Show("Vui lòng chọn mã nguyên liệu !");
                    return;
                }
                if (txtSoLuong.Text == "")
                {
                    MessageBox.Show("Vui lòng nhập Số lượng !");
                    return;
                }
                if (txtDonGia.Text == "")
                {
                    MessageBox.Show("Vui Lòng nhập đơn giá !");
                    return;
                }
                if (txtCungCap.Text == "")
                {
                    MessageBox.Show("Vui lòng nhập Đơn vị cung cấp !");
                    return;
                }
                if (txtThuKho.Text == "")
                {
                    MessageBox.Show("Vui lòng nhập Nhân viên thủ kho !");
                    return;
                }


                PhieuNhap_DTO phieunhap = new PhieuNhap_DTO();
                phieunhap.MaNL  = int.Parse(cBMaNL.Text.ToString());
                phieunhap.TenNL = txtTenNL.Text.ToString();
                phieunhap.DonVi = txtDonVi.Text.ToString();
                try
                {
                    phieunhap.Soluong = int.Parse(txtSoLuong.Text.ToString());
                }
                catch (Exception)
                {
                    MessageBox.Show("Dữ liệu nhập có lỗi. Xin kiểm tra lại", "thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                phieunhap.Dongia       = int.Parse(txtDonGia.Text.ToString());
                phieunhap.Ngaynhap     = dtpNgayNhap.Text.ToString();
                phieunhap.Donvicungcap = txtCungCap.Text.ToString();
                phieunhap.Thukho       = txtThuKho.Text.ToString();
                if (PhieuNhap_BUS.ThemPhieuNhap(phieunhap))
                {
                    txtMaPN.Text    = "";
                    cBMaNL.Text     = "";
                    txtTenNL.Text   = "";
                    txtDonVi.Text   = "";
                    txtSoLuong.Text = "";
                    txtDonGia.Text  = "";

                    txtCungCap.Text = "";
                    txtThuKho.Text  = "";
                    LoadPhieuNhap();
                    MessageBox.Show("Đã Thêm");
                    return;
                }
                MessageBox.Show("Thêm thất bại !");
            }
        }