using System.Collections.Generic;
|
using System.Linq;
|
using Json;
|
using Lib;
|
using System.Web.Mvc;
|
using Model;
|
using BLL;
|
using Common;
|
using System.Data;
|
using FastReport.Web;
|
|
namespace WMS.Areas.Business.Controllers
|
{
|
public class PurchaseController : MasterPage
|
{
|
// GET: Business/Purchase
|
public ActionResult GetList()
|
{
|
ViewBag.AuditList = LocalHelper.GetAuditList("");
|
return View();
|
}
|
public ActionResult Add()
|
{
|
string PurchaseNo = Request.QueryString.Get("PurchaseNo");
|
Session["TEMPDATA_CACHE_PURCHASE"] = null;
|
if (string.IsNullOrEmpty(PurchaseNo))
|
{
|
ViewBag.Admin = new Purchase();
|
|
}
|
else
|
{
|
IDALPurchase provider = new DALPurchase();
|
IList<PurchaseMat> erpMats = new List<PurchaseMat>();
|
Purchase entity = provider.GetModel(PurchaseNo, ref erpMats);
|
Session["TEMPDATA_CACHE_PURCHASE"] = erpMats;
|
entity = entity == null ? new Purchase() : entity;
|
//ViewBag.OrdTypeList = LocalHelper.GetOrdTypeList(entity.OrdType);
|
ViewBag.Admin = entity;
|
|
}
|
|
return View();
|
}
|
public ActionResult AddProduct()
|
{
|
string MatNo = Request.QueryString.Get("MatNo");
|
if (MatNo.IsEmpty())
|
{
|
ViewBag.Admin = new PurchaseMat();
|
}
|
else
|
{
|
List<PurchaseMat> list = Session["TEMPDATA_CACHE_PURCHASE"] as List<PurchaseMat>;
|
List<PurchaseMat> list1 = list.Where(a => a.MatNo == MatNo).ToList<PurchaseMat>();
|
ViewBag.UnitList = LocalHelper.GetUnitList("");
|
ViewBag.Admin = list1[0];
|
}
|
return View();
|
}
|
public ActionResult Detail(string PurchaseNo)
|
{
|
if (!string.IsNullOrEmpty(PurchaseNo))
|
{
|
IDALPurchase provider = new DALPurchase();
|
Purchase entity = provider.GetModel(PurchaseNo);
|
entity = entity == null ? new Purchase() : entity;
|
ViewBag.Admin = entity;
|
}
|
return View();
|
}
|
public ActionResult Dialog(string PurchaseNo)
|
{
|
return View();
|
}
|
public ActionResult ReportShow()
|
{
|
string ReportNo = Request["ReportNo"];
|
string OrdNo = Request["OrdNo"];
|
|
|
|
WebReport webReport = new WebReport();
|
webReport.Width = System.Web.UI.WebControls.Unit.Percentage(100);
|
webReport.Height = 600;
|
webReport.ToolbarIconsStyle = ToolbarIconsStyle.Black;
|
webReport.ToolbarIconsStyle = ToolbarIconsStyle.Black;
|
webReport.PrintInBrowser = true;
|
webReport.PrintInPdf = true;
|
webReport.ShowExports = true;
|
webReport.ShowPrint = true;
|
webReport.SinglePage = true;
|
|
DataSet ds = null;
|
|
if (ReportNo.IndexOf("采购单") >= 0)
|
{
|
ReportNo = "采购单2";
|
IDALPurchase purchase = new DALPurchase();
|
ds = purchase.GetPrintData(OrdNo);
|
}
|
else if (ReportNo.IndexOf("入库单") >= 0)
|
{
|
ReportNo = "入库单";
|
//ReportNo = "采购单2";
|
IDALErpIn purchase = new DALErpIn();
|
ds = purchase.GetPrintData(OrdNo);
|
}
|
else if (ReportNo.IndexOf("出库单") >= 0)
|
{
|
ReportNo = "出库单";
|
//ReportNo = "采购单2";
|
IDALErpIn purchase = new DALErpIn();
|
ds = purchase.GetPrintData(OrdNo);
|
}
|
|
//ds = new ReportProvider().GetDataSource(entity, list, orderType, orderNum);
|
string path = "~/Report/" + ReportNo + ".frx";
|
path = Server.MapPath(path);
|
//if (!Directory.Exists(path))
|
//{
|
// string template = Server.MapPath("~Report/Report.frx");
|
// System.IO.File.Copy(template, path, true);
|
//}
|
webReport.Report.Load(path);
|
if (ds != null && ds.Tables != null && ds.Tables.Count > 0)
|
{
|
webReport.Report.RegisterData(ds);
|
for (int i = 0; i < ds.Tables.Count; i++)
|
{
|
webReport.Report.GetDataSource(ds.Tables[i].TableName).Enabled = true;
|
}
|
}
|
webReport.ID = ReportNo;
|
ViewBag.WebReport = webReport;
|
|
return View();
|
|
}
|
public ActionResult SelMatDialog()
|
{
|
return View();
|
}
|
|
}
|
}
|