using NFine.Application.WMS;
using NFine.Code;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace NFine.Web.Areas.WMS.Controllers
{
   
    public class RevokeBusinessController : ControllerBase
    {
        // GET: WMS/RevokeBusiness
        RevokeBusinessApp App = new RevokeBusinessApp();
        public ActionResult Revocation()
        {
            return View();
        }

        //[HttpPost]
        //[HandlerAjaxOnly]
        //[ValidateAntiForgeryToken]
        //public ActionResult Revocations(string keyValue)
        //{
        //    string msg = "";
        //    var Parameter = keyValue.ToJObject();
        //    if (Parameter["BusinessCode"].ToString() =="1"|| Parameter["BusinessCode"].ToString() == "2")
        //    {
        //           msg = App.RevocationPurchase(keyValue);
        //    }
        //    else if (Parameter["BusinessCode"].ToString() == "13"|| Parameter["BusinessCode"].ToString() == "14"|| Parameter["BusinessCode"].ToString() == "15")
        //    {
        //        msg = App.RevocationPicking(keyValue);
        //    }
        //    else if (Parameter["BusinessCode"].ToString() == "17"|| Parameter["BusinessCode"].ToString() == "18")
        //    {
        //        msg = App.RevocationFinished(keyValue);
        //    }
        //    else
        //    {
        //        msg = App.RevocationMarket(keyValue);
        //    }


        //    if (string.IsNullOrEmpty(msg))
        //    {
        //        return Success("撤销成功!");
        //    }
        //    else
        //    {
        //        return Error("" + msg + "");
        //    }
        //}

        [HttpPost]
        [HandlerAjaxOnly]
        [ValidateAntiForgeryToken]
        public ActionResult Revocations(string keyValue)
        {
            string msg = "";
            var Parameter = keyValue.ToJObject();
            //采购入库-采购订单
            if (Parameter["BusinessCode"].ToString() == "1" )
            {
                msg = App.RevocationPurchase(keyValue);
            }
            //采购入库-采购到货单
            else if (Parameter["BusinessCode"].ToString() == "2")
            {
                msg = App.RevocationDeliveryNotice(keyValue);
            }
            //生产发料-生产订单备料表
            else if (Parameter["BusinessCode"].ToString() == "13")
            {
                msg = App.RevocationPicking(keyValue);
            }
            //生产发料-领料申请单
            else if (Parameter["BusinessCode"].ToString() == "14")
            {
                msg = App.RevocationMOApply(keyValue);
            }
            //生产发料-材料出库单
            else if (Parameter["BusinessCode"].ToString() == "15")
            {
                msg = App.RevocationMOIssue(keyValue);
            }


            //产成品入库-生产订单
            else if (Parameter["BusinessCode"].ToString() == "17")
            {
                msg = App.RevocationFinished(keyValue);
            }
            //产成品入库-产成品入库单
            else if (Parameter["BusinessCode"].ToString() == "18")
            {
                msg = App.RevocationManufactureReceive(keyValue);
            }
            //销售发货-销售发货单
            else
            {
                msg = App.RevocationMarket(keyValue);
            }


            if (string.IsNullOrEmpty(msg))
            {
                return Success("撤销成功!");
            }
            else
            {
                return Error("" + msg + "");
            }
        }





    }
}