private void LoadData(int id)
        {
            try
            {
                xRPDataContext dts = new xRPDataContext();
                this.currentPhieuXuat = (from t in dts.Qlvt_PhieuXuats where t.ID == id select t).FirstOrDefault();

                if (this.currentPhieuXuat != null)
                {
                    ltPrint.Text  = "<li class=\"menu-item icon-only\" id=\"Li1\"><input type=\"button\" class=\"menu-bar-item-button icon-printer\" id=\"btnPrint\" title=\"In dữ liệu\" /></li>";
                    ltAccept.Text = "<li class=\"menu-item icon-only\" id=\"btn-accept\"><a title=\"Duyệt\" class=\"menu-bar-item-button icon icon-tfs-build-reason-batchedci\" href=\"javascript:duyetPhieuXuat('" + ID_PhieuXuat + "');\"></a></li>";

                    ltTitle.Text = "Chỉnh sửa phiếu xuất: " + this.currentPhieuXuat.MaHieuPhieuXuat;
                    if (this.currentPhieuXuat.Xoa.HasValue && this.currentPhieuXuat.Xoa.Value)
                    {
                        Response.Redirect(Util.SERVER_NAME + "/Business/QuanLyVatTu/Default.aspx?page=pktx", false);
                    }

                    this.txtMaPhieu.Text   = this.currentPhieuXuat.MaHieuPhieuXuat;
                    this.txtNgayXuat.Value = string.Format("{0:dd/MM/yyyy}", this.currentPhieuXuat.NgayXuat);


                    if (this.currentPhieuXuat.MaKhoVatTu.HasValue)
                    {
                        this.slcKhoChua.Value = this.currentPhieuXuat.MaKhoVatTu.Value.ToString();
                        var kc = dts.Qlvt_KhoVatTus.Where(t => t.ID == this.currentPhieuXuat.MaKhoVatTu.Value).FirstOrDefault();
                        if (kc != null)
                        {
                            this.lblKhoChua.Text = kc.MaHieuKho.Trim() + " - " + kc.TenKhoVatTu;
                        }
                    }

                    if (this.currentPhieuXuat.MaKhoVatTuDen.HasValue)
                    {
                        this.slcKhoDen.Value = this.currentPhieuXuat.MaKhoVatTuDen.Value.ToString();
                        var kd = dts.Qlvt_KhoVatTus.Where(t => t.ID == this.currentPhieuXuat.MaKhoVatTuDen.Value).FirstOrDefault();
                        if (kd != null)
                        {
                            this.txtKhoDen.Text = kd.MaHieuKho.Trim() + " - " + kd.TenKhoVatTu;
                        }
                    }

                    if (this.currentPhieuXuat.MaTinhChatNhapXuat.HasValue)
                    {
                        this.ddlTinhChat.SelectedValue = this.currentPhieuXuat.MaTinhChatNhapXuat.Value.ToString();
                        var tinhChat = dts.Sp_Qlvt_TinhChatNhapXuat_Select(1, currentPhieuXuat.MaTinhChatNhapXuat.Value, (int?)null, (int?)null).FirstOrDefault();

                        this.slcKhachHang.Value = this.currentPhieuXuat.MaDonViNhan.HasValue ? this.currentPhieuXuat.MaDonViNhan.Value.ToString() : "";
                        if (this.currentPhieuXuat.MaDonViNhan.HasValue && tinhChat != null && tinhChat.NoiBo.HasValue && tinhChat.NoiBo.Value)
                        {
                            var kh = dts.Sys_DanhMucDonVis.Where(t => t.ID == this.currentPhieuXuat.MaDonViNhan.Value).FirstOrDefault();
                            if (kh != null)
                            {
                                this.txtKhachHang.Value = (kh.MaHieuDonVi == null ? "" : (kh.MaHieuDonVi.Trim() + " - ")) + kh.TenDonVi;
                            }
                        }
                        if (this.currentPhieuXuat.MaDonViNhan.HasValue && tinhChat != null && tinhChat.NoiBo.HasValue && !tinhChat.NoiBo.Value)
                        {
                            var kh = dts.Qldh_KhachHangs.Where(t => t.ID == this.currentPhieuXuat.MaDonViNhan.Value).FirstOrDefault();
                            if (kh != null)
                            {
                                this.txtKhachHang.Value = kh.TenKhachHang;
                            }
                        }
                        if (this.currentPhieuXuat.MaDonViNhan.HasValue && tinhChat != null && tinhChat.TenTinhChatNhapXuat == "Xuất trả lại")
                        {
                            var kh = dts.Qlvt_NhaCungCaps.Where(t => t.ID == this.currentPhieuXuat.MaDonViNhan.Value).FirstOrDefault();
                            if (kh != null)
                            {
                                this.txtKhachHang.Value = kh.TenNhaCungCap;
                            }
                        }
                    }
                    this.txtGhiChu.Text = this.currentPhieuXuat.GhiChu;
                    if (this.currentPhieuXuat.TinhTrang == 1)
                    {
                        Response.Redirect("Default.aspx?page=vdktx&id=" + this.currentPhieuXuat.ID);
                    }
                }
                else
                {
                    this.txtNgayXuat.Value = string.Format("{0:dd/MM/yyyy}", DateTime.Now);
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.StackTrace);
                Response.Write(ex.Message);
            }
        }
Esempio n. 2
0
        private void LoadData(int id)
        {
            try
            {
                xRPDataContext dts = new xRPDataContext();
                this.currentPhieuXuat = (from t in dts.Qlvt_PhieuXuats where t.ID == id select t).FirstOrDefault();

                if (this.currentPhieuXuat != null)
                {
                    ltPrint.Text = "<li class=\"menu-item icon-only\" id=\"Li1\"><input type=\"button\" class=\"menu-bar-item-button icon-printer\" id=\"btnPrint\" title=\"In dữ liệu\" /></li>";
                    ltTitle.Text = "Xem phiếu xuất: " + this.currentPhieuXuat.MaHieuPhieuXuat;
                    if (this.currentPhieuXuat.Xoa.HasValue && this.currentPhieuXuat.Xoa.Value)
                    {
                        Response.Redirect(Util.SERVER_NAME + "/Business/QuanLyVatTu/Default.aspx?page=pktx", false);
                    }

                    this.txtMaPhieu.Text  = this.currentPhieuXuat.MaHieuPhieuXuat;
                    this.txtNgayXuat.Text = string.Format("{0:dd/MM/yyyy}", this.currentPhieuXuat.NgayXuat);


                    if (this.currentPhieuXuat.MaKhoVatTu.HasValue)
                    {
                        var kc = dts.Qlvt_KhoVatTus.Where(t => t.ID == this.currentPhieuXuat.MaKhoVatTu.Value).FirstOrDefault();
                        if (kc != null)
                        {
                            this.lblKhoChua.Text = kc.MaHieuKho.Trim() + " - " + kc.TenKhoVatTu;
                        }
                    }

                    if (this.currentPhieuXuat.MaKhoVatTuDen.HasValue)
                    {
                        var kd = dts.Qlvt_KhoVatTus.Where(t => t.ID == this.currentPhieuXuat.MaKhoVatTuDen.Value).FirstOrDefault();
                        if (kd != null)
                        {
                            this.txtKhoDen.Text = kd.MaHieuKho.Trim() + " - " + kd.TenKhoVatTu;
                        }
                    }

                    if (this.currentPhieuXuat.MaTinhChatNhapXuat.HasValue)
                    {
                        this.ddlTinhChat.Text = this.currentPhieuXuat.MaTinhChatNhapXuat.Value.ToString();
                        var tinhChat = dts.Sp_Qlvt_TinhChatNhapXuat_Select(1, currentPhieuXuat.MaTinhChatNhapXuat.Value, (int?)null, (int?)null).FirstOrDefault();
                        this.ddlTinhChat.Text = tinhChat.TenTinhChatNhapXuat;
                        if (this.currentPhieuXuat.MaDonViNhan.HasValue && tinhChat != null && tinhChat.NoiBo.HasValue && tinhChat.NoiBo.Value)
                        {
                            var kh = dts.Sys_DanhMucDonVis.Where(t => t.ID == this.currentPhieuXuat.MaDonViNhan.Value).FirstOrDefault();
                            if (kh != null)
                            {
                                this.txtKhachHang.Text = (kh.MaHieuDonVi == null ? "" : (kh.MaHieuDonVi.Trim() + " - ")) + kh.TenDonVi;
                            }
                        }
                        if (this.currentPhieuXuat.MaDonViNhan.HasValue && tinhChat != null && tinhChat.NoiBo.HasValue && !tinhChat.NoiBo.Value)
                        {
                            var kh = dts.Qldh_KhachHangs.Where(t => t.ID == this.currentPhieuXuat.MaDonViNhan.Value).FirstOrDefault();
                            if (kh != null)
                            {
                                this.txtKhachHang.Text = kh.TenKhachHang;
                            }
                        }
                        if (tinhChat.NoiBo.Value)
                        {
                            lblKhachHang.InnerText = "Phòng ban/đơn vị";
                            this.txtKhoDen.Visible = true;
                        }
                        else
                        {
                            lblKhachHang.InnerText = "Khách hàng";
                            this.txtKhoDen.Visible = false;
                        }
                        if (tinhChat.DieuChuyen.HasValue && tinhChat.DieuChuyen.Value)
                        {
                            lblKhoDen.InnerText = "Kho đến";
                            txtKhoDen.Visible   = true;
                            rKhoDen.Visible     = true;
                        }
                        else
                        {
                            lblKhoDen.InnerText = "";
                            txtKhoDen.Visible   = false;
                            rKhoDen.Visible     = false;
                        }
                    }
                    this.txtGhiChu.Text = this.currentPhieuXuat.GhiChu.Replace("\n", "<br/>");
                }
                else
                {
                    this.txtNgayXuat.Text = string.Format("{0:dd/MM/yyyy}", DateTime.Now);
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.StackTrace);
                Response.Write(ex.Message);
            }
        }