public async Task <IHttpActionResult> GetForNvByCode(string code)
        {
            MdMerchandiseVm.Dto result = null;
            var unitCode = _service.GetCurrentUnitCode();
            //var instance = _service.Repository.DbSet.FirstOrDefault(x => x.MaVatTu.ToUpper() == code.ToUpper());//&& x.UnitCode == unitCode);
            var service = new ProcedureService <MdMerchandiseTypeVm.Dto>();
            var data    = ProcedureCollection.GetMerchandiseType(new BTS.API.ENTITY.ERPContext(), code, unitCode);

            if (data != null && data.Count() >= 1)
            {
                var items = data.ToList();


                return(Ok(items[0]));
            }
            else
            {
                return(NotFound());
            }
        }
Beispiel #2
0
        public HttpResponseMessage ExportExcelSyntheticByCondition(ParameterExcelByCondition para)
        {
            var _ParentUnitCode = _service.GetParentUnitCode();

            NvGiaoDichQuayVm.ReportExcel result = null;
            var unitCode = _service.GetCurrentUnitCode();

            para.UnitCode = unitCode;
            var service = new ProcedureService <NvGiaoDichQuayVm.ReportExcel>();
            var data    = ProcedureCollection.DuLieuTongHopGiaoDichQuayTheoDieuKien(para.TuNgay, para.DenNgay, para.UnitCode, new BTS.API.ENTITY.ERPContext());

            using (ExcelPackage package = new ExcelPackage())
            {
                var ms = new MemoryStream();
                package.Workbook.Worksheets.Add("Data");
                var worksheet = package.Workbook.Worksheets[1];
                int index     = 0;
                worksheet.Cells[1, 1, 1, 5].Merge = true;
                worksheet.Cells[1, 1].Value       = "SIÊU THỊ TỪ SƠN ";
                worksheet.Cells[2, 1, 2, 5].Merge = true;
                worksheet.Cells[2, 1].Value       = "Đường Lý Thái Tổ, P. Đình Bảng, TX Từ Sơn, Bắc Ninh ";
                worksheet.Cells[4, 4, 4, 7].Merge = true;
                worksheet.Cells[4, 4].Value       = "BÁO CÁO GIAO DỊCH QUẦY TỔNG HỢP ";
                worksheet.Cells[5, 4, 5, 8].Merge = true;
                worksheet.Cells[5, 4].Value       = "Từ ngày: " + para.TuNgay.Day + "/" + para.TuNgay.Month + "/" + para.TuNgay.Year + "   Đến ngày:" + para.DenNgay.Day + "/" + para.DenNgay.Month + "/" + para.DenNgay.Year;
                worksheet.Cells[7, 1].Value       = "STT";
                worksheet.Cells[7, 2].Value       = "Mã giao dịch";
                worksheet.Cells[7, 3].Value       = "Mã giao dịch PK";
                worksheet.Cells[7, 4].Value       = "Loại giao dịch";
                worksheet.Cells[7, 5].Value       = "Tổng tiền";
                int stt = 1;
                index = 8;
                if (data != null && data.Count() >= 1)
                {
                    var item = data.ToList();
                    for (int i = 0; i < item.Count; i++)
                    {
                        var hanghoa    = new MdMerchandiseVm.Dto();
                        var innerindex = item[i].MaVatTu;
                        var hanghoatg  = _merchandiseservice.UnitOfWork.Repository <MdMerchandise>().DbSet.FirstOrDefault(x => x.MaVatTu == innerindex && x.UnitCode.StartsWith(_ParentUnitCode));
                        hanghoa = Mapper.Map <MdMerchandise, MdMerchandiseVm.Dto>(hanghoatg);
                        worksheet.Cells[index, 1].Value = stt;
                        worksheet.Cells[index, 2].Value = item[i].MaGiaoDich;
                        worksheet.Cells[index, 3].Value = item[i].MaGiaoDichQuayPK;
                        if (item[i].LoaiGiaoDich == 1)
                        {
                            worksheet.Cells[index, 4].Value = "Bán lẻ";
                        }
                        else if (item[i].LoaiGiaoDich == 2)
                        {
                            worksheet.Cells[index, 4].Value = "Trả lại";
                        }
                        worksheet.Cells[index, 5].Value = CurrentSetting.FormatTienViet(item[i].TTienCoVat.ToString());
                        index++;
                        stt++;
                    }
                }
                else
                {
                    //return null;
                }

                package.SaveAs(ms);
                HttpResponseMessage response = Request.CreateResponse();
                response.StatusCode = HttpStatusCode.OK;
                ms.Seek(0, SeekOrigin.Begin);
                response.Content = new StreamContent(ms);

                response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline")
                {
                    FileName = "BaoCaoGiaoDichQuayTongHop.xlsx"
                };
                response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

                return(response);
            }
        }
Beispiel #3
0
        public HttpResponseMessage ExportExcel(ParameterCashier para)
        {
            var _ParentUnitCode = _service.GetParentUnitCode();

            NvGiaoDichQuayVm.ReportExcel result = null;
            var unitCode = _service.GetCurrentUnitCode();
            //var instance = _service.Repository.DbSet.FirstOrDefault(x => x.MaVatTu.ToUpper() == code.ToUpper());//&& x.UnitCode == unitCode);
            var service = new ProcedureService <NvGiaoDichQuayVm.ReportExcel>();
            var data    = ProcedureCollection.GetReportGDQExcel(para.FromDate, para.ToDate, new BTS.API.ENTITY.ERPContext(), unitCode);

            using (ExcelPackage package = new ExcelPackage())
            {
                var ms = new MemoryStream();
                package.Workbook.Worksheets.Add("Data");
                var worksheet = package.Workbook.Worksheets[1];
                int index     = 0;
                worksheet.Cells[1, 1, 1, 5].Merge = true;
                worksheet.Cells[1, 1].Value       = "SIÊU THỊ TỪ SƠN ";
                worksheet.Cells[2, 1, 2, 5].Merge = true;
                worksheet.Cells[2, 1].Value       = "Đường Lý Thái Tổ, P. Đình Bảng, TX Từ Sơn, Bắc Ninh ";
                worksheet.Cells[4, 4, 4, 7].Merge = true;
                worksheet.Cells[4, 4].Value       = "BÁO CÁO GIAO DỊCH QUẦY ";
                worksheet.Cells[5, 4, 5, 8].Merge = true;
                worksheet.Cells[5, 4].Value       = "Từ ngày: " + para.FromDate.Day + "/" + para.FromDate.Month + "/" + para.FromDate.Year + "   Đến ngày:" + para.ToDate.Day + "/" + para.ToDate.Month + "/" + para.ToDate.Year;
                worksheet.Cells[7, 1].Value       = "STT";
                worksheet.Cells[7, 2].Value       = "Nhân viên";
                worksheet.Cells[7, 3].Value       = "Máy bán";
                worksheet.Cells[7, 4].Value       = "Ngày phát sinh";
                worksheet.Cells[7, 5].Value       = "Loại giao dịch";
                worksheet.Cells[7, 6].Value       = "Mã hàng";
                worksheet.Cells[7, 7].Value       = "Tên hàng";
                worksheet.Cells[7, 8].Value       = "Số lượng";
                worksheet.Cells[7, 9].Value       = "Tổng tiền";
                index = 8;
                if (data != null && data.Count() >= 1)
                {
                    var item = data.ToList();
                    for (int i = 0; i < item.Count; i++)
                    {
                        var hanghoa    = new MdMerchandiseVm.Dto();
                        var innerindex = item[i].MaVatTu;
                        var hanghoatg  = _merchandiseservice.UnitOfWork.Repository <MdMerchandise>().DbSet.FirstOrDefault(x => x.MaVatTu == innerindex && x.UnitCode.StartsWith(_ParentUnitCode));
                        hanghoa = Mapper.Map <MdMerchandise, MdMerchandiseVm.Dto>(hanghoatg);
                        worksheet.Cells[index, 1].Value = index;
                        worksheet.Cells[index, 2].Value = item[i].MaNguoiTao + "-" + item[i].NguoiTao;
                        worksheet.Cells[index, 3].Value = item[i].MaQuayBan;
                        worksheet.Cells[index, 4].Value = item[i].NgayPhatSinh.Date + "/" + item[i].NgayPhatSinh.Month + "/" + item[i].NgayPhatSinh.Year;
                        worksheet.Cells[index, 6].Value = item[i].MaVatTu;
                        if (hanghoa == null)
                        {
                            worksheet.Cells[index, 7].Value = " ";
                        }
                        worksheet.Cells[index, 7].Value = hanghoa.TenHang;
                        worksheet.Cells[index, 8].Value = item[i].SoLuong;
                        worksheet.Cells[index, 9].Value = CurrentSetting.FormatTienViet(item[i].TTienCoVat.ToString());
                        if (item[i].LoaiGiaoDich == 1)
                        {
                            worksheet.Cells[index, 5].Value = "xuất bán";
                        }
                        else if (item[i].LoaiGiaoDich == 2)
                        {
                            worksheet.Cells[index, 5].Value = "bán trả lại";
                        }
                        index++;
                    }
                }
                else
                {
                    //return null;
                }

                package.SaveAs(ms);
                HttpResponseMessage response = Request.CreateResponse();
                response.StatusCode = HttpStatusCode.OK;
                ms.Seek(0, SeekOrigin.Begin);
                response.Content = new StreamContent(ms);

                response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline")
                {
                    FileName = "BaoCaoGiaoDichQuay.xlsx"
                };
                response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

                return(response);
            }
        }