Пример #1
0
        // Button thêm phiếu nhập
        private void gunaAdvenceButton4_Click(object sender, EventArgs e)
        {
            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 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     = DateTime.Parse(dtpNgayNhap.Text.ToString());
            phieunhap.Donvicungcap = txtCungCap.Text.ToString();
            phieunhap.Thukho       = txtThuKho.Text.ToString();
            if (PhieuNhap_BUS.ThemPhieuNhap(phieunhap))
            {
                LoadPhieuNhap();
                MessageBox.Show("Đã Thêm");
                return;
            }
            MessageBox.Show("Thêm thất bại !");
        }
Пример #2
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            PhieuNhap_DTO a = new PhieuNhap_DTO();

            a.NgayLap  = dtNgayLAp.Value.ToShortDateString();
            a.TongTien = 0;
            if (DateTime.Compare(dtNgayLAp.Value, DateTime.Now) > 0)
            {
                MessageBox.Show("Ngày lập phải sớm hơn ngày hiện tại");
                return;
            }
            pn.ThemPhieuNhap(a);
            MessageBox.Show("Thêm thành công");
            RefToMom.load();
        }
Пример #3
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 !");
            }
        }