﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using NPOI;
using NPOI.HPSF;
using NPOI.HSSF;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using NPOI.HSSF.UserModel;
using LJH.Inventory.BusinessModel;
using LJH.Inventory.BusinessModel.Resource;
using LJH.Inventory.WebAPIClient;
using LJH.GeneralLibrary;
using LJH.Inventory.UI.Forms.Inventory.Print;

namespace LJH.Inventory.UI.Forms.Purchase.Print
{
    /// <summary>
    /// 表示一个订单导出电子表格类
    /// </summary>
    public class PurchaseOrderExporter : SheetExporter<PurchaseOrder, PurchaseItem>
    {
        #region 构造函数
        public PurchaseOrderExporter(string modalPath)
            : base(modalPath)
        {
        }

        public PurchaseOrderExporter(string modalPath, bool showPrice)
            : base(modalPath, showPrice)
        {
        }
        #endregion

        #region 重写基类方法
        protected override bool FillSheetInfo(ICell cell, string express, PurchaseOrder info, PurchaseItem[] allItems, PurchaseItem[] curPageItems)
        {
            bool ret = true;
            if (express == "[生产单号]") cell.SetCellValue(info.ID);
            else if (express == "[交货日期]") cell.SetCellValue(info.DemandDate.ToString("yyyy年MM月dd日"));
            else if (express == "[客户]")
            {
                Company customer = new CompanyBLL(AppSettings.Current.ConnStr).GetByID(info.CustomerID).QueryObject;
                if (customer != null) cell.SetCellValue(customer.Name);
            }
            else ret = false;
            return ret;
        }

        protected override bool FillSheetItemInfo(ICell cell, string express, PurchaseItem item)
        {
            var ret = true;
            if (express == "[产品备注]") cell.SetCellValue(item.GetMemo());
            else ret = false;
            return ret;
        }
        #endregion
    }
}
