Example #1
0
        private void toolLuuThem_Click(object sender, EventArgs e)
        {
            ctrl = new PhieuNhapController();

            status = Controll.AddNew;

            txtMaPhieu.Text   = ThamSo.LayMaPhieuNhap().ToString();
            numTongTien.Value = 0;
            numDaTra.Value    = 0;
            numConNo.Value    = 0;
            ctrlMaSP.HienThiChiTietPhieuNhap(txtMaPhieu.Text, dataGridView);
            this.Allow(true);
        }
Example #2
0
        void ThemMoi()
        {
            DataRow row = ctrl.NewRow();

            row["ID"]              = txtMaPhieu.Text;
            row["NGAY_NHAP"]       = dtNgayNhap.Value.Date;
            row["TONG_TIEN"]       = numTongTien.Value;
            row["ID_NHA_CUNG_CAP"] = cmbNhaCungCap.SelectedValue;
            row["DA_TRA"]          = numDaTra.Value;
            row["CON_NO"]          = numConNo.Value;
            ctrl.Add(row);

            PhieuNhapController ctrlPN = new PhieuNhapController();

            if (ctrlPN.LayPhieuNhap(txtMaPhieu.Text) != null)
            {
                MessageBox.Show("Mã Phiếu nhập này đã tồn tại !", "Phieu Nhap", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (ThamSo.LaSoNguyen(txtMaPhieu.Text))
            {
                long so = Convert.ToInt64(txtMaPhieu.Text);
                if (so >= ThamSo.LayMaPhieuNhap())
                {
                    ThamSo.GanMaPhieuNhap(so + 1);
                }
            }

            ctrl.Save();
            ctrlMaSP.Save();

            SanPhamController ctrlSP = new SanPhamController();

            foreach (DataGridViewRow view in dataGridView.Rows)
            {
                ctrlSP.CapNhatGiaNhap(Convert.ToString(view.Cells["colSanPham"].Value),
                                      Convert.ToInt64(view.Cells["colDonGiaNhap"].Value),
                                      Convert.ToInt64(view.Cells["colSoLuong"].Value));
            }
        }
Example #3
0
        private void frmNhapHang_Load(object sender, EventArgs e)
        {
            ctrlSanPham.HienthiAutoComboBox(cmbSanPham);
            ctrlSanPham.HienthiDataGridViewComboBoxColumn(colSanPham);
            ctrlNCC.HienthiAutoComboBox(cmbNhaCungCap);



            ctrl.HienthiPhieuNhap(bindingNavigator, txtMaPhieu, cmbNhaCungCap, dtNgayNhap, numTongTien, numDaTra, numConNo);
            bindingNavigator.BindingSource.CurrentChanged -= new EventHandler(BindingSource_CurrentChanged);
            bindingNavigator.BindingSource.CurrentChanged += new EventHandler(BindingSource_CurrentChanged);

            ctrlMaSP.HienThiChiTietPhieuNhap(txtMaPhieu.Text, dataGridView);

            if (status == Controll.AddNew)
            {
                txtMaPhieu.Text = ThamSo.LayMaPhieuNhap().ToString();
                Allow(true);
            }
            else
            {
                Allow(false);
            }
        }