﻿using LJH.Inventory.BLL;
using LJH.Inventory.BusinessModel;
using LJH.Inventory.UI.Forms;
using LJH.Inventory.UI.Forms.Inventory;
using LJH.Inventory.UI.Forms.Financial;
using LJH.Inventory.UI.Forms.Sale;
using LJH.Inventory.UI.Forms.Purchase;

namespace WeiTongApp
{
    public class FrmSheetDetailFactory : LJH.Inventory.UI.Forms.FrmSheetDetailFactoryBase
    {
        public override FrmSheetDetailBase CreateFrmOrderDetail(SheetType ot)
        {
            switch (ot)
            {
                case SheetType.订单:
                    if (!AppSettings.Current.OperatorPara.Permit(Permission.Order, PermissionActions.Read) && !AppSettings.Current.OperatorPara.Permit(Permission.Order, PermissionActions.Edit)) return null;
                    FrmOrderDetail frm = new FrmOrderDetail();
                    return frm;
                default:
                    return null;
            }
        }

        public override FrmSheetDetailBase CreateFrmPurchaseOrderDetail(SheetType st)
        {
            switch (st)
            {
                case SheetType.加工单:
                    if (!AppSettings.Current.OperatorPara.Permit(Permission.生产加工单, PermissionActions.Read) && !AppSettings.Current.OperatorPara.Permit(Permission.生产加工单, PermissionActions.Edit)) return null;
                    return new FrmPurchaseOrderDetail_加工();
                default:
                    return base.CreateFrmPurchaseOrderDetail(st);
            }
        }

        public override FrmSheetDetailBase CreateFrmStackoutSheetDetail(SheetType st)
        {
            switch (st)
            {
                case SheetType.送货单:
                    if (!AppSettings.Current.OperatorPara.Permit(Permission.DeliverySheet, PermissionActions.Read) && !AppSettings.Current.OperatorPara.Permit(Permission.DeliverySheet, PermissionActions.Edit)) return null;
                    return new FrmStackOutSheetDetail();
                case SheetType.管子送货单:
                     if (!AppSettings.Current.OperatorPara.Permit(Permission.DeliverySheet, PermissionActions.Read) && !AppSettings.Current.OperatorPara.Permit(Permission.DeliverySheet, PermissionActions.Edit)) return null;
                    return new Frm管子送货单();
                default:
                    return base.CreateFrmStackoutSheetDetail(st);
            }
        }

        public override FrmSheetDetailBase CreateFrmStackInSheetDetail(SheetType st)
        {
            switch (st)
            {
                case SheetType.加工入库单:
                    if (!AppSettings.Current.OperatorPara.Permit(Permission.StackInSheet, PermissionActions.Read) && !AppSettings.Current.OperatorPara.Permit(Permission.StackInSheet, PermissionActions.Edit)) return null;
                    return new Frm加工入库单();
                case SheetType.采购入库单:
                    if (!AppSettings.Current.OperatorPara.Permit(Permission.StackInSheet, PermissionActions.Read) && !AppSettings.Current.OperatorPara.Permit(Permission.StackInSheet, PermissionActions.Edit)) return null;
                    return new Frm采购入库单();
                case SheetType.订单备货单:
                    if (!AppSettings.Current.OperatorPara.Permit(Permission.StackInSheet, PermissionActions.Read) && !AppSettings.Current.OperatorPara.Permit(Permission.StackInSheet, PermissionActions.Edit)) return null;
                    return new Frm订单备货单();
                default:
                    return base.CreateFrmStackInSheetDetail(st);
            }
        }
    }
}
