public frmNhapKhoToTrinh(enumButton2 stt, string Ma_Phieu_Nhap,frmDanhSachPhieuNhap pn )
        {
            InitializeComponent();

            //Setup một số component
            InitFormComponent();

            if (stt == enumButton2.Sua)
            {
                txtMaPhieuNhap.Text = Ma_Phieu_Nhap;

                btnSua_Click(this, EventArgs.Empty);
            }
            else if (stt == enumButton2.Them)
            {
                btnThem_Click(this, EventArgs.Empty);
            }
            else
                if (stt == enumButton2.None)
                {
                    txtMaPhieuNhap.Text = Ma_Phieu_Nhap;
                    button2_Click(this, EventArgs.Empty);
                }
            this.ds = pn;
        }
        public frmBuTruPhieu(frmDanhSachPhieuNhap dspn, string maphieu , string loaiPhieu)
        {
            InitializeComponent();
            this.maphieu = maphieu;

            this.dspn = dspn;
            this.LoaiPhieu = loaiPhieu;
            Load_Data();
        }
Пример #3
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtMaPhieuNhap.Text.Trim() == "")
            {
                MessageBox.Show("Mã phiếu bắt buộc nhập!");
                return;
            }
            if (cbKhoNhan.Text == "" )
            {
                MessageBox.Show("Chưa nhập kho hoặc mã phiếu");
                return;
            }

            DatabaseHelper help = new DatabaseHelper();
            help.ConnectDatabase();
            //switch (staTus)
            switch (PanelButton.getClickStatus())
            {

                #region "Thêm"
                case enumButton2.Them:
                    using (var dbcxtransaction = help.ent.Database.BeginTransaction())
                    {
                        try
                        {

                            clsPhieuNhapKho phieunhap = new clsPhieuNhapKho();
                            phieunhap.Ma_phieu_nhap = txtMaPhieuNhap.Text;
                            if (!phieunhap.CheckTonTaiSoDK(txtMaPhieuNhap.Text))
                            {

                                phieunhap.Kho_nhan = cbKhoNhan.Text;
                                phieunhap.Kho_xuat_ra = txtXuatTaiKho.Text;
                                phieunhap.Da_phan_kho = false;

                                  phieunhap.ID_Loai_Phieu_Nhap = null;
                                phieunhap.Ma_phieu_nhap = txtMaPhieuNhap.Text;
                                phieunhap.Dia_chi = txtDiaChi.Text;
                                phieunhap.Ly_do = txtLyDo.Text;
                                phieunhap.Ngay_lap = dtNgayNhap.Value;
                                phieunhap.Cong_trinh = txtCongTrinh.Text;
                                phieunhap.Da_phan_kho = false;
                                phieunhap.ID_khoNhan = (int)cbKhoNhan.SelectedValue;
                                if (rdoKNMN.Checked == true)
                                    phieunhap.isKNMN = true;
                                if (rdoKNTN.Checked == true)
                                    phieunhap.isKNTN = true;
                                if (rdoKCTN.Checked == true)
                                    phieunhap.isKCTN = true;
                                if (rdoKCMuonNo.Checked == true)
                                    phieunhap.isKCMN = true;

                                phieunhap.isNhapNgoai = true;
                                phieunhap.Ten_kho_muon = cbKhoNgoai.Text;
                                if (phieunhap.Insert(help) == 1)
                                {

                                    //DataTable chiTietPhieuNhap = new clsChi_Tiet_Phieu_Nhap_Vat_Tu().GetAll(phieuNhap.ID_phieu_nhap);
                                    for (int i = 0; i < dataTable1.Rows.Count; i++)
                                    {
                                        clsChi_Tiet_Phieu_Nhap_Vat_Tu chitiet = new clsChi_Tiet_Phieu_Nhap_Vat_Tu();
                                        //    chitiet.ID_chi_tiet_phieu_nhap = int.Parse(gridMaster.Rows[i].Cells["ID_chi_tiet_phieu_nhap"].ToString());
                                        chitiet.Ma_phieu_nhap = (txtMaPhieuNhap.Text);
                                        chitiet.ID_Don_vi_tinh = int.Parse(dataTable1.Rows[i]["ID_Don_vi_tinh"].ToString());
                                        chitiet.Ma_vat_tu = (dataTable1.Rows[i]["Ma_vat_tu"].ToString());
                                        chitiet.ID_Chat_luong = int.Parse(dataTable1.Rows[i]["ID_Chat_luong"].ToString());
                                        // chitiet.So_luong_yeu_cau = decimal.Parse(dataTable1.Rows[i]["So_luong_yeu_cau"].ToString());
                                        chitiet.So_luong_thuc_lanh = decimal.Parse(dataTable1.Rows[i]["so_luong_thuc_lanh"].ToString());
                                        chitiet.Don_gia = decimal.Parse(dataTable1.Rows[i]["Don_gia"].ToString());
                                        chitiet.Thanh_tien = decimal.Parse(dataTable1.Rows[i]["Thanh_tien"].ToString());
                                        chitiet.Da_duyet = false;
                                        if (chitiet.Insert(help) == 0)
                                            dbcxtransaction.Rollback();

                                    }

                                    dbcxtransaction.Commit();

                                    PanelButton.ResetClickStatus();

                                    //setInputComponentStatus(true);
                                    enableInputForm();

                                    PanelButton.ResetButton();
                                    frmDanhSachPhieuNhap dspn = new frmDanhSachPhieuNhap(txtMaPhieuNhap.Text);
                                    dspn.Show();

                                }
                                else
                                    dbcxtransaction.Rollback();

                            }
                            else
                            {
                                MessageBox.Show("mã phiếu nhập này đã tồn tại trong csdl!");
                                button2_Click(this, EventArgs.Empty);
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(Utilities.clsThamSoUtilities.COException(ex));
                            dbcxtransaction.Rollback();
                        }
                    }
                    break;
                #endregion
                #region "Sua"
                case enumButton2.Sua:
                    {
                        using (var dbcxtransaction = help.ent.Database.BeginTransaction())
                        {
                            try
                            {
                                clsPhieuNhapKho phieunhap = new clsPhieuNhapKho();
                                phieunhap.Ma_phieu_nhap = txtMaPhieuNhap.Text;
                                {

                                    // phieunhap.

                                    //  phieunhap.ID_Loai_Phieu_Nhap = Int32.Parse(cbLoaiPhieuNhan.SelectedValue.ToString());
                                    phieunhap.Ma_phieu_nhap = txtMaPhieuNhap.Text;
                                    phieunhap.Dia_chi = txtDiaChi.Text;
                                    phieunhap.Ly_do = txtLyDo.Text;
                                    phieunhap.Ngay_lap = dtNgayNhap.Value;
                                    //     phieunhap.So_hoa_don = txtSoHD.Text;
                                    phieunhap.Cong_trinh = txtCongTrinh.Text;

                                    //if (rdoKNMN.Checked == true)
                                    //    phieunhap.isChoMuonNgoai = true;

                                    if (rdoKNMN.Checked == true)
                                        phieunhap.isKNMN = true;
                                    if (rdoKNTN.Checked == true)
                                        phieunhap.isKNTN = true;
                                    if (rdoKCTN.Checked == true)
                                        phieunhap.isKCTN = true;
                                    if (rdoKCMuonNo.Checked == true)
                                        phieunhap.isKCMN = true;

                                    phieunhap.isNhapNgoai = true;
                                    //if (isLoaiPhieu == "TN")
                                    //    phieunhap.isTraNo = true;
                                    //  phieunhap.isGoiDau = chbNGD.Checked;
                                    phieunhap.ID_khoNhan = (int)cbKhoNhan.SelectedValue;
                                    DataTable temp = phieunhap.GetThongTinPhieuMuonNo(phieunhap.Ma_phieu_nhap);
                                    Phieu_Nhap_Kho nk = new Phieu_Nhap_Kho();

                                    nk.Ma_phieu_nhap = phieunhap.Ma_phieu_nhap;
                                    nk.ID_phieu_nhap = int.Parse(temp.Rows[0]["ID_phieu_nhap"].ToString());

                                    nk.Cong_trinh = phieunhap.Cong_trinh;
                                    nk.Da_phan_kho = phieunhap.Da_phan_kho;
                                    nk.Dia_Chi = phieunhap.Dia_chi;
                                    nk.ID_Loai_Phieu_Nhap = phieunhap.ID_Loai_Phieu_Nhap;
                                    nk.Kho_nhan = phieunhap.Kho_nhan;
                                    nk.ID_kho = phieunhap.ID_khoNhan;
                                    nk.Kho_xuat_ra = phieunhap.Kho_xuat_ra;
                                  //  nk.isKNTN = phieunhap.isTraNo;
                                    nk.isToTrinh = phieunhap.isToTrinh;
                                    nk.Ly_do = phieunhap.Ly_do;
                                    nk.Ngay_lap = phieunhap.Ngay_lap;
                                    nk.So_hoa_don = phieunhap.So_hoa_don;
                                    nk.isKNMN = phieunhap.isKNMN;
                                    nk.isKNTN = phieunhap.isKNTN;
                                    nk.isKCTN = phieunhap.isKCTN;
                                    nk.isKCMN = phieunhap.isKCMN;
                                    nk.isNVMN = phieunhap.isNVMN;

                                    nk.isNhapNgoai = true;

                                    if (phieunhap.Update(nk) == 1)
                                    {

                                        clsChi_Tiet_Phieu_Nhap_Vat_Tu pn = new clsChi_Tiet_Phieu_Nhap_Vat_Tu();
                                        pn.Ma_phieu_nhap = phieunhap.Ma_phieu_nhap;

                                        pn.remove(pn.Ma_phieu_nhap);
                                        for (int i = 0; i < dataTable1.Rows.Count; i++)
                                        {

                                            clsChi_Tiet_Phieu_Nhap_Vat_Tu chitiet = new clsChi_Tiet_Phieu_Nhap_Vat_Tu();
                                            chitiet.Ma_phieu_nhap = (txtMaPhieuNhap.Text);
                                            chitiet.ID_Don_vi_tinh = int.Parse(dataTable1.Rows[i]["ID_Don_vi_tinh"].ToString());
                                            chitiet.Ma_vat_tu = (dataTable1.Rows[i]["Ma_vat_tu"].ToString());
                                            chitiet.ID_Chat_luong = int.Parse(dataTable1.Rows[i]["ID_Chat_luong"].ToString());
                                            chitiet.So_luong_thuc_lanh = decimal.Parse(dataTable1.Rows[i]["so_luong_thuc_lanh"].ToString());
                                            chitiet.Don_gia = decimal.Parse(dataTable1.Rows[i]["Don_gia"].ToString());
                                            chitiet.Thanh_tien = decimal.Parse(dataTable1.Rows[i]["Thanh_tien"].ToString());
                                            chitiet.Da_duyet = false;
                                            chitiet.ID_Chat_luong = int.Parse(cbChatLuong.SelectedValue.ToString());
                                            if (chitiet.Insert(help) == 0)
                                                dbcxtransaction.Rollback();

                                        }

                                        dbcxtransaction.Commit();

                                        PanelButton.ResetClickStatus();

                                        //setInputComponentStatus(true);
                                        enableInputForm();

                                        PanelButton.ResetButton();
                                    }
                                    else
                                        dbcxtransaction.Rollback();
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(Utilities.clsThamSoUtilities.COException(ex));
                                dbcxtransaction.Rollback();
                            }
                        }
                        this.ds.LoadData();
                        break;
                    }
                #endregion

            }
        }
Пример #4
0
        private void danhSáchPhiếuNhậpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Utilities.clsThamSoUtilities.isSectionLogin == true)
            {
                frmDanhSachPhieuNhap frm = new frmDanhSachPhieuNhap();
                frm.Name = "Danh sách phiếu nhập vật tư";

                foreach (Form f in this.MdiChildren)
                {
                    if (f.Name == frm.Name)
                    {
                        f.Activate();
                        return;
                    }

                }

                frm.MdiParent = this;
                frm.WindowState = FormWindowState.Maximized;
                frm.Show();

            }
        }