/// <summary> /// To-Do LIST /// [ ] Vấn đề 1: Lấy DataTable chi tiết phiếu nhập (by mã phiếu nhập) --> fill vào grid /// [ ] Vấn đề 2: Lấy thông tin Phiếu (by Ma Phieu Nhap) --> Check tồn tại --> Set to FRM /// [ ] /// [ ] /// [ ] /// </summary> /// <param name="Ma_Phieu_Nhap">The ma_ phieu_ nhap.</param> private bool setFormData_By_MaPhieuNhap(string Ma_Phieu_Nhap) { clsPhieuNhapKho PhieuNhap = new clsPhieuNhapKho(); if (PhieuNhap.CheckTonTaiSoDK(Ma_Phieu_Nhap)) { //fill vào FRM DataTable tb = PhieuNhap.GetAll(Ma_Phieu_Nhap); //cbKhoNhap.SelectedValue = tb.Rows[0]["ID_kho"].ToString(); txtMaPhieuNhap.Text = Ma_Phieu_Nhap; dtNgayNhap.Text = string.Format("{0:dd/MM/yyyy}", tb.Rows[0]["Ngay_lap"]); txtLyDo.Text = tb.Rows[0]["Ly_do"].ToString(); txtCongTrinh.Text = tb.Rows[0]["cong_trinh"].ToString(); txtDiaChi.Text = tb.Rows[0]["Dia_chi"].ToString(); //Fill vào grid //DataTable chiTietPhieuNhap = new clsChi_Tiet_Phieu_Nhap_Vat_Tu().GetAll(Ma_Phieu_Nhap); //dataTable1 = chiTietPhieuNhap; //gridMaster.DataSource = dataTable1; //clsChi_Tiet_Phieu_Nhap_Vat_Tu chitiet = new clsChi_Tiet_Phieu_Nhap_Vat_Tu(); DataTable vChiTiet = (DataTable)new clsChi_Tiet_Phieu_Nhap_Vat_Tu().GetAll(Ma_Phieu_Nhap); for (int i = 0; i < vChiTiet.Rows.Count; i++) { DataRow dr = dataTable1.NewRow(); dr["ma_vat_tu"] = vChiTiet.Rows[i]["ma_vat_tu"].ToString(); dr["Ten_vat_tu"] = vChiTiet.Rows[i]["Ten_vat_tu"].ToString(); dr["Ten_Don_vi_tinh"] = vChiTiet.Rows[i]["ten_don_vi_tinh"].ToString(); dr["ID_Don_vi_tinh"] = vChiTiet.Rows[i]["ID_don_vi_tinh"].ToString(); dr["chat_luong"] = vChiTiet.Rows[i]["chat_luong"].ToString(); dr["so_luong_yeu_cau"] = vChiTiet.Rows[i]["so_luong_yeu_cau"].ToString(); dr["so_luong_thuc_lanh"] = vChiTiet.Rows[i]["so_luong_thuc_lanh"].ToString(); dr["don_gia"] = vChiTiet.Rows[i]["don_gia"].ToString(); dr["Thanh_tien"] = vChiTiet.Rows[i]["thanh_tien"].ToString(); // int.Parse(vChiTiet.Rows[i]["don_gia"].ToString()) * int.Parse(vChiTiet.Rows[i]["so_luong_thuc_lanh"].ToString()); dataTable1.Rows.Add(dr); } return true; } else return false; }
private bool initEdit() { try { clsPhieuNhapKho clsNhap = new clsPhieuNhapKho(); clsNhap.Ma_phieu_nhap = txtMaPhieuNhap.Text; if (clsNhap.CheckTonTaiSoDK(txtMaPhieuNhap.Text) == true) { DataTable tb = clsNhap.GetAll(txtMaPhieuNhap.Text.Trim()); dtNgayNhap.CustomFormat = "dd-MM-yyyy"; dtNgayNhap.Value = Convert.ToDateTime(tb.Rows[0]["Ngay_lap"].ToString()); txtLyDo.Text = tb.Rows[0]["Ly_do"].ToString(); txtCongTrinh.Text = tb.Rows[0]["cong_trinh"].ToString(); cbKhoNhan.Text = tb.Rows[0]["Ten_kho"].ToString(); txtDiaChi.Text = tb.Rows[0]["Dia_chi"].ToString(); cbLoaiPhieuNhan.SelectedValue = tb.Rows[0]["ID_Loai_Phieu_Nhap"].ToString(); rdoNhapGoiDau.Checked = bool.Parse(tb.Rows[0]["isGoiDau"].ToString()); clsChi_Tiet_Phieu_Nhap_Vat_Tu chitiet = new clsChi_Tiet_Phieu_Nhap_Vat_Tu(); DataTable vChiTiet = (DataTable)chitiet.GetAll(txtMaPhieuNhap.Text); for (int i = 0; i < vChiTiet.Rows.Count; i++) { DataRow dr =dataTable1.NewRow(); dr["ma_vat_tu"] = vChiTiet.Rows[i]["ma_vat_tu"].ToString(); dr["Ten_vat_tu"] = vChiTiet.Rows[i]["Ten_vat_tu"].ToString(); dr["ID_chat_luong"] = vChiTiet.Rows[i]["ID_chat_luong"].ToString(); dr["so_luong_yeu_cau"] = vChiTiet.Rows[i]["so_luong_yeu_cau"].ToString(); dr["so_luong_thuc_lanh"] = vChiTiet.Rows[i]["so_luong_thuc_lanh"].ToString(); dr["don_gia"] = vChiTiet.Rows[i]["don_gia"].ToString(); dr["chat_luong"] = vChiTiet.Rows[i]["chat_luong"].ToString(); dr["Thanh_tien"] = vChiTiet.Rows[i]["thanh_tien"].ToString();// int.Parse(vChiTiet.Rows[i]["don_gia"].ToString()) * int.Parse(vChiTiet.Rows[i]["so_luong_thuc_lanh"].ToString()); dr["Ten_Don_vi_tinh"] = vChiTiet.Rows[i]["ten_don_vi_tinh"].ToString(); dr["ID_Don_vi_tinh"] = vChiTiet.Rows[i]["ID_don_vi_tinh"].ToString(); dataTable1.Rows.Add(dr); } if (clsChi_Tiet_Phieu_Nhap_Vat_Tu.KTVTChuaDuyet(clsNhap.Ma_phieu_nhap) == true) { disableInputForm(); MessageBox.Show("Phiếu nhập này chứa vật tư đã phân vào kho, không thể chỉnh sữa thông tin."); return false; } return true; } else { } } catch (Exception ex) { MessageBox.Show(Utilities.clsThamSoUtilities.COException(ex)); } return false; }