示例#1
0
        protected void BindData(int id)
        {
            xRPDataContext dts             = new xRPDataContext();
            var            sysconfig       = dts.Sys_ThongSoHeThongs;
            string         tenCongTy       = (from t in sysconfig where t.ThongSo == "TenCongTy" select t.GiaTri).FirstOrDefault();
            string         diaChiCongTy    = (from t in sysconfig where t.ThongSo == "DiaChiCongTy" select t.GiaTri).FirstOrDefault();
            string         dienThoaiCongTy = (from t in sysconfig where t.ThongSo == "DienThoaiLienHe" select t.GiaTri).FirstOrDefault();

            lblTenCongTy.Text       = tenCongTy;
            lblDiaChiCongTy.Text    = "Địa chỉ: " + diaChiCongTy;
            lblDienThoaiCongTy.Text = "Số ĐT: " + dienThoaiCongTy;
            string ngayhomnay = new Sys_ThongSoHeThongRepository().GetThongSoHeThong("DiaPhuong", "Hà Nội") + ", ngày" + " " + DateTime.Now.Day.ToString() + " " + "tháng" + " " + DateTime.Now.Month.ToString() + " " + "năm" + " " + DateTime.Now.Year.ToString();

            lblNgayIn.Text               = ngayhomnay;
            this.currentPhieuNhap        = dts.Qlvt_PhieuNhaps.Where(x => x.ID == id).FirstOrDefault();
            this.currentKhoVatTu         = dts.Qlvt_KhoVatTus.Where(x => x.ID == currentPhieuNhap.MaKhoVatTu).FirstOrDefault();
            lblMaPhieuNhap.Text          = "Mã phiếu nhập kho: " + currentPhieuNhap.MaHieuPhieuNhap;
            lblNhapTaiKho.Text           = "Kho nhập: " + currentKhoVatTu.TenKhoVatTu;
            lblNgayNhapKho.Text          = "Ngày nhập kho: " + currentPhieuNhap.NgayNhap.Value.ToString("dd/MM/yyyy");
            lblNoiDung.Text              = "Nội dung:" + currentPhieuNhap.GhiChu;
            lblNhaCungCap.Text           = "Nhà cung cấp: " + currentPhieuNhap.Qlvt_NhaCungCap.TenNhaCungCap;
            objectDataSource1.DataSource = dts.sp_Baocao_PhieuNhapVatTu(id);
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["id"] != null)
                {
                    ID = Request.QueryString["id"].ToString();
                    string type = Request.QueryString["type"];
                    if (string.IsNullOrWhiteSpace(type) || type != "2")
                    {
                        type = "1";
                    }

                    xRPDataContext   dts  = new xRPDataContext();
                    DataTable        dt   = GetData(int.Parse(Request.QueryString["id"].ToString()));
                    var              data = dts.sp_Baocao_PhieuNhapVatTu(int.Parse(ID));
                    ReportDataSource rpt  = new ReportDataSource("dtsPhieuNhap", data);
                    rpViewer.LocalReport.DataSources.Clear();
                    rpViewer.LocalReport.DataSources.Add(rpt);
                    rpViewer.LocalReport.ReportPath = type == "1" ? "Report/QuanLyVatTu/NhapVatTu/ReportNhapKho.rdlc" : "Report/QuanLyVatTu/NhapVatTu/ReportNhapKhoNCC.rdlc";
                    rpViewer.LocalReport.Refresh();


                    this.currentPhieuNhap = (from t in dts.Qlvt_PhieuNhaps where t.ID == int.Parse(Request.QueryString["id"].ToString()) select t).FirstOrDefault();
                    this.currentKhoVatTu  = (from ds in dts.Qlvt_KhoVatTus where ds.ID == currentPhieuNhap.MaKhoVatTu select ds).FirstOrDefault();

                    string tencongty = "", diachi = "", sodienthoai = "";
                    var    listthongsoht = (from ds in dts.Sys_ThongSoHeThongs select ds).ToList();
                    foreach (var item in listthongsoht)
                    {
                        if (item.ThongSo == "TenCongTy")
                        {
                            tencongty = item.GiaTri;
                        }
                        if (item.ThongSo == "DiaChiCongTy")
                        {
                            diachi = item.GiaTri;
                        }
                        if (item.ThongSo == "DienThoaiLienHe")
                        {
                            sodienthoai = item.GiaTri;
                        }
                    }

                    //Lấy thông tin nhà cung cấp
                    var nhacungcap = (from ds in dts.Qlvt_NhaCungCaps where ds.ID == currentPhieuNhap.MaNhaCungCap select ds).FirstOrDefault();

                    ReportParameter[] p = new ReportParameter[12];
                    p[0] = new ReportParameter("maphieunhap", currentPhieuNhap.MaHieuPhieuNhap);
                    p[1] = new ReportParameter("nhaptaikho", currentKhoVatTu.TenKhoVatTu);
                    p[2] = new ReportParameter("tencongty", tencongty);
                    p[3] = new ReportParameter("diachi", diachi.ToUpper());
                    p[4] = new ReportParameter("sodienthoai", sodienthoai);
                    p[5] = new ReportParameter("ngayin", new Sys_ThongSoHeThongRepository().GetThongSoHeThong("DiaPhuong", "Hà Nội") + ", ngày" + " " + DateTime.Now.Day.ToString() + " " + "tháng" + " " + DateTime.Now.Month.ToString() + " " + "năm" + " " + DateTime.Now.Year.ToString());

                    double x = 0, y = 0, z = 0, k = 0;
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (!string.IsNullOrEmpty(dt.Rows[i][3].ToString()))
                        {
                            x = x + double.Parse(dt.Rows[i][3].ToString());
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[i][5].ToString()))
                        {
                            y = y + double.Parse(dt.Rows[i][5].ToString());
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[i][4].ToString()))
                        {
                            z = z + double.Parse(dt.Rows[i][4].ToString());
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[i][7].ToString()))
                        {
                            k = k + double.Parse(dt.Rows[i][7].ToString());
                        }
                    }
                    p[7]  = new ReportParameter("tongdltt", x.ToString());
                    p[8]  = new ReportParameter("tongtruloi", y.ToString());
                    p[9]  = new ReportParameter("tongtruthuakho", z.ToString());
                    p[10] = new ReportParameter("tongthucnhap", k.ToString());
                    p[11] = new ReportParameter("tien", Util.ReadMoney(k.ToString()));
                    p[6]  = new ReportParameter("ngaynhapkho", currentPhieuNhap.NgayNhap.ToString());
                    rpViewer.LocalReport.SetParameters(p);
                    if (currentPhieuNhap.TinhTrang != 2)
                    {
                        ltAccept.Text = "<li class=\"menu-item icon-only\"><a id=\"btnAccept\" class=\"menu-bar-item-button icon accept-icon\" href=\"javascript:duyetPhieuNhap('" + currentPhieuNhap.ID + "');\"></a></li>";
                    }
                }
            }
        }
示例#3
0
        private void LoadData(int id)
        {
            try
            {
                xRPDataContext dts = new xRPDataContext();
                this.currentPhieuNhap = (from t in dts.Qlvt_PhieuNhaps where t.ID == id select t).FirstOrDefault();
                if (this.currentPhieuNhap != null)
                {
                    if (this.currentPhieuNhap.Xoa.HasValue && this.currentPhieuNhap.Xoa.Value)
                    {
                        Response.Redirect(Util.SERVER_NAME + "/Business/QuanLyVatTu/Default.aspx?page=pn", false);
                    }
                    //btnCancel.Visible = this.currentPhieuNhap.Xoa.HasValue && this.currentPhieuNhap.Xoa.Value;
                    pnChiTietVatTu.Visible = true;

                    this.txtMaPhieu.Value  = this.currentPhieuNhap.MaHieuPhieuNhap;
                    this.txtNgayNhap.Value = string.Format("{0:dd/MM/yyyy}", this.currentPhieuNhap.NgayNhap);

                    if (this.currentPhieuNhap.MaNhaCungCap.HasValue)
                    {
                        var ncc = dts.Qlvt_NhaCungCaps.Where(t => t.ID == this.currentPhieuNhap.MaNhaCungCap.Value).FirstOrDefault();
                        if (ncc != null)
                        {
                            this.txtTenNhaCungCap.Value = ncc.MaHieuNhaCungCap.Trim() + " - " + ncc.TenNhaCungCap;
                        }
                    }
                    if (this.currentPhieuNhap.MaKhoVatTu.HasValue)
                    {
                        var kc = dts.Qlvt_KhoVatTus.Where(t => t.ID == this.currentPhieuNhap.MaKhoVatTu.Value).FirstOrDefault();
                        if (kc != null)
                        {
                            this.txtKhoChua.Value = kc.TenKhoVatTu;
                        }
                    }
                    if (this.currentPhieuNhap.MaTinhChatNhapXuat.HasValue)
                    {
                        var kc = dts.Qlvt_TinhChatNhapXuats.Where(t => t.ID == this.currentPhieuNhap.MaTinhChatNhapXuat.Value).FirstOrDefault();
                        if (kc != null)
                        {
                            this.txtTinhChat.Value = kc.TenTinhChatNhapXuat;
                        }
                    }

                    this.txtGhiChu.Text = this.currentPhieuNhap.GhiChu;
                    var x           = (from t in dts.Qlvt_VatTuNhaps where t.MaPhieuNhap == this.currentPhieuNhap.ID select t).ToList();
                    var listChiTiet = new System.Collections.ArrayList();

                    for (int i = 0; i < x.Count; i++)
                    {
                        var vt     = x[i];
                        var vttype = dts.Qlvt_VatTus.Where(t => t.ID == vt.MaVatTu).FirstOrDefault();
                        if (vttype != null)
                        {
                            listChiTiet.Add(new
                            {
                                ID                        = vt.ID,
                                maVatTu                   = vttype.MaHieuVatTu,
                                tenVatTu                  = vttype.TenVatTu,
                                donViTinh                 = vt.IDDonViTinh,
                                tenDonViTinh              = dts.Qlvt_DonViTinhs.Where(t => t.ID == vt.IDDonViTinh).FirstOrDefault().DonViTinh,
                                giaNhap                   = vt.DonGia.HasValue ? vt.DonGia.Value : 0,
                                soLuongThucNhap           = vt.SoLuongThucNhap.HasValue ? vt.SoLuongThucNhap.Value : 0,
                                soLuongDauCuon            = vt.SoLuongDauCuon.HasValue ? vt.SoLuongDauCuon.Value : 0,
                                soLuongLamPhieuNhap       = vt.SoLuongLamPhieuNhap.HasValue ? vt.SoLuongLamPhieuNhap.Value : 0,
                                dinhLuongTieuChuan        = vttype.DinhLuong,
                                dinhLuongThucTe           = vt.DinhLuongThucTe.HasValue ? vt.DinhLuongThucTe.Value : 0,
                                kichThuocTieuChuan        = vttype.KichThuocVatTu,
                                kichThuocThucTe           = vt.KichThuocThucTe.HasValue ? vt.KichThuocThucTe.Value : 0,
                                chenhLechDinhLuong        = vt.ChenhLechDinhLuong.HasValue ? vt.ChenhLechDinhLuong.Value : 0,
                                dinhLuongTinhTru          = vt.DinhLuongTinhTru.HasValue ? vt.DinhLuongTinhTru.Value : 0,
                                truKichThuoc              = vt.TruThuaKichThuoc.HasValue ? vt.TruThuaKichThuoc : 0,
                                khoiLuongTru              = vt.KhoiLuongTru.HasValue ? vt.KhoiLuongTru.Value : 0,
                                truLoi                    = vt.TruLoi.HasValue ? vt.TruLoi.Value : 0,
                                soLuongChenhLechKhongTinh = vt.SoLuongChenhLechKhongTinh.HasValue ? vt.SoLuongChenhLechKhongTinh : 0,
                                thanhTien                 = vt.ThanhTien.HasValue ? vt.ThanhTien : 0,
                                ghiChu                    = vt.GhiChu
                            });
                        }
                    }
                    DataChiTiet   = new JavaScriptSerializer().Serialize(listChiTiet);
                    DataPhieuNhap = new JavaScriptSerializer().Serialize(new
                    {
                        itemID             = this.currentPhieuNhap.ID,
                        ID                 = this.currentPhieuNhap.ID,
                        MaHieuPhieuNhap    = this.currentPhieuNhap.MaHieuPhieuNhap,
                        NgayNhap           = this.currentPhieuNhap.NgayNhap.Value.ToString("dd/MM/yyyy"),
                        MaNhaCungCap       = this.currentPhieuNhap.MaNhaCungCap.Value,
                        MaKhoVatTu         = this.currentPhieuNhap.MaKhoVatTu.Value,
                        MaTinhChatNhapXuat = this.currentPhieuNhap.MaTinhChatNhapXuat.Value,
                        KieuVatTu          = this.currentPhieuNhap.KieuVatTu.Value,
                        TinhTrang          = this.currentPhieuNhap.TinhTrang.Value,
                        GhiChu             = this.currentPhieuNhap.GhiChu
                    });
                }
                else
                {
                    this.txtNgayNhap.Value = string.Format("{0:dd/MM/yyyy}", DateTime.Now);
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.StackTrace);
                Response.Write(ex.Message);
            }
        }
示例#4
0
        private void LoadData(int id)
        {
            try
            {
                xRPDataContext dts = new xRPDataContext();
                this.currentPhieuNhap = (from t in dts.Qlvt_PhieuNhaps where t.ID == id select t).FirstOrDefault();
                if (this.currentPhieuNhap != null)
                {
                    ltTitle.Text = "Chỉnh sửa phiếu nhập thành phẩm: " + this.currentPhieuNhap.MaHieuPhieuNhap;
                    if (this.currentPhieuNhap.Xoa.HasValue && this.currentPhieuNhap.Xoa.Value)
                    {
                        Response.Redirect(Util.SERVER_NAME + "/Business/QuanLyVatTu/Default.aspx?page=pn", false);
                    }
                    //btnCancel.Visible = this.currentPhieuNhap.Xoa.HasValue && this.currentPhieuNhap.Xoa.Value;
                    pnChiTietVatTu.Visible = true;

                    this.txtMaPhieu.Value  = this.currentPhieuNhap.MaHieuPhieuNhap;
                    this.txtNgayNhap.Value = string.Format("{0:dd/MM/yyyy}", this.currentPhieuNhap.NgayNhap);

                    this.slcTenNhaCungCap.Value = this.currentPhieuNhap.MaNhaCungCap.HasValue ? this.currentPhieuNhap.MaNhaCungCap.Value.ToString() : "";
                    if (this.currentPhieuNhap.MaNhaCungCap.HasValue)
                    {
                        this.slcTenNhaCungCap.Value = this.currentPhieuNhap.MaNhaCungCap.Value.ToString();
                        var ncc = dts.Qlvt_NhaCungCaps.Where(t => t.ID == this.currentPhieuNhap.MaNhaCungCap.Value).FirstOrDefault();
                        if (ncc != null)
                        {
                            this.txtTenNhaCungCap.Value = ncc.MaHieuNhaCungCap.Trim() + " - " + ncc.TenNhaCungCap;
                        }
                    }
                    if (this.currentPhieuNhap.MaKhoVatTu.HasValue)
                    {
                        this.slcKhoChua.Value = this.currentPhieuNhap.MaKhoVatTu.Value.ToString();
                        var kc = dts.Qlvt_KhoVatTus.Where(t => t.ID == this.currentPhieuNhap.MaKhoVatTu.Value).FirstOrDefault();
                        if (kc != null)
                        {
                            this.txtKhoChua.Value = kc.MaHieuKho.Trim() + " - " + kc.TenKhoVatTu;
                        }
                    }
                    if (this.currentPhieuNhap.MaTinhChatNhapXuat.HasValue)
                    {
                        this.ddlTinhChat.SelectedValue = this.currentPhieuNhap.MaTinhChatNhapXuat.Value.ToString();
                        if (this.currentPhieuNhap.MaTinhChatNhapXuat.Value == 29 && this.currentPhieuNhap.MaPhieuXuat.HasValue)
                        {
                            this.slcPhieuXuat.Value = this.currentPhieuNhap.MaPhieuXuat.Value.ToString();
                            var phieuxuat = dts.Qlvt_PhieuXuats.FirstOrDefault(t => t.ID == this.currentPhieuNhap.MaPhieuXuat.Value);
                            if (phieuxuat != null)
                            {
                                this.txtTheoPhieuXuat.Text = phieuxuat.MaHieuPhieuXuat;
                            }
                        }
                    }

                    this.txtGhiChu.Text = this.currentPhieuNhap.GhiChu;
                    var x           = (from t in dts.Qlvt_VatTuNhaps where t.MaPhieuNhap == this.currentPhieuNhap.ID select t).ToList();
                    var listChiTiet = new System.Collections.ArrayList();
                    this.CurrentTinhTrang = this.currentPhieuNhap.TinhTrang.HasValue ? this.currentPhieuNhap.TinhTrang.Value : 0;
                }
                else
                {
                    this.txtNgayNhap.Value = string.Format("{0:dd/MM/yyyy}", DateTime.Now);
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.StackTrace);
                Response.Write(ex.Message);
            }
        }