コード例 #1
0
        private void BtnListHoaDon_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Form form = this.CheckExists(typeof(FormListHoaDon));

            if (form != null)
            {
                form.Activate();
            }
            else
            {
                FormListHoaDon f = new FormListHoaDon();
                f.MdiParent = this;
                f.Show();
            }
        }
コード例 #2
0
        private void BtnLuu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (btn_ThemPN == true)
            {
                if (txtMaPN.Text.Trim().ToString() == "")
                {
                    MessageBox.Show("bạn chưa điền mã DDH", "", MessageBoxButtons.OK);
                }
                else if (DateEditNgay.Text.Trim().ToString() == "" || txtmasoDDH.Text.Trim().ToString() == "" || txtMaKho.Text.Trim() == "")
                {
                    MessageBox.Show("bạn chưa điền đầy đủ thông tin", "", MessageBoxButtons.OK);
                }
                else if (FormListHoaDon.kiemTraMaKho(txtMaKho.Text.Trim().ToString()) == 0)
                {
                    MessageBox.Show("mã kho bạn nhập không có ở chi nhánh này ", "", MessageBoxButtons.OK);
                }
                else if (KiemTraDDHDaNhap(txtmasoDDH.Text.Trim().ToString()) == 1)
                {
                    MessageBox.Show(" đơn đặt hàng này đã nhập hàng ", "", MessageBoxButtons.OK);
                }
                else
                {      // txtMaNV.Text = Program.username;
                       //MessageBox.Show(txtMaNV.Text);
                       //dataSetQLVT.EnforceConstraints = false;
                    try
                    {
                        ((DataRowView)phieuNhapBindingSource.Current)["MAKHO"] = txtMaKho.Text;
                        phieuNhapBindingSource.EndEdit(); //k cho chỉnh sửa nữa
                        phieuNhapBindingSource.ResetCurrentItem();
                        this.phieuNhapTableAdapter.Connection.ConnectionString = Program.connstr;
                        this.phieuNhapTableAdapter.Update(this.dataSetQLVT); // Đẩy về CSDL

                        MessageBox.Show("Thêm phiếu nhập thành công", "", MessageBoxButtons.OK);
                        ResetDefault();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Lỗi thêm đơn đặt hàng. Xin thử lại, lỗi :\n" + ex.Message, "",
                                        MessageBoxButtons.OK);
                    }
                }
            }
            else if (btn_ThemCTPN == true)
            {
                if (FormListHoaDon.kiemTraMaVT(txtMaVT.Text.Trim().ToString()) == 1)
                {
                    try
                    {
                        cTPNBindingSource.EndEdit(); //k cho chỉnh sửa nữa
                        cTPNBindingSource.ResetCurrentItem();
                        this.cTPNTableAdapter.Connection.ConnectionString = Program.connstr;
                        this.cTPNTableAdapter.Update(this.dataSetQLVT); // Đẩy về CSDL
                        capNhatSoLuongVatTu(txtMaVT.Text.Trim().ToString(), Int32.Parse(SpinEditSoLuong.Text.ToString()));
                        MessageBox.Show("thêm chi tiết PN thành công", "", MessageBoxButtons.OK);

                        ResetDefault();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Lỗi thêm chi tiết đơn đặt hàng. Xin thử lại, lỗi :\n" + ex.Message, "",
                                        MessageBoxButtons.OK);
                    }
                }
                else
                {
                    MessageBox.Show("MÃ VẬT TƯ NHẬP SAI", "", MessageBoxButtons.OK);
                }
            }
        }