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

namespace NFine.Web.Areas.OMAY.Controllers
{
    public class OMAYSalesDeliveryController : ControllerBase
    {
        OMAYSalesDeliveryApp App = new OMAYSalesDeliveryApp();
        // GET: OMAY/OMAYSalesDelivery
        public ActionResult OMAYSalesDeliveryIndex()
        {
            return View();
        }
        
        public ActionResult OMAYSalesDeliveryFrom()
        {
            return View();
        }

        [HttpGet]
        public ActionResult GetSalesDeliveryInfo(string Code, Pagination pagination)
        {
            DataTable ListData = App.GetSalesDeliveryInfo(Code, ref pagination);
            var JsonData = new
            {
                total = pagination.total,
                page = pagination.page,
                records = pagination.records,
                rows = ListData,
            };
            return Content(JsonData.ToJson());
        }


        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetSalesByCode(Pagination pagination, string queryJson)
        {
            DataTable ListData = App.GetSalesByCode(queryJson, ref pagination);
            var JsonData = new
            {
                total = pagination.total,
                page = pagination.page,
                records = pagination.records,
                rows = ListData,
            };
            return Content(JsonData.ToJson());
        }

        [HttpGet]
        [HandlerAjaxOnly]
        public ActionResult GetMoPicksByCode(Pagination pagination, string queryJson)
        {
            DataTable ListData = App.GetMoPicksByCode(queryJson, ref pagination);
            var JsonData = new
            {
                total = pagination.total,
                page = pagination.page,
                records = pagination.records,
                rows = ListData,
            };
            return Content(JsonData.ToJson());
        }


        public ActionResult GetLotNotInfo(string keyValue)

        {
            var ListData = App.GetLotNotInfo(keyValue);

            return Content(ListData.ToJson());
        }

        [HttpPost]
        [HandlerAjaxOnly]
        public ActionResult SaveSalesDelivery(string ICSASN)
        {

            string msg = App.SaveSalesDelivery(ICSASN);
            if (!string.IsNullOrEmpty(msg))
            {
                return Error(msg);
            }
            else
            {
                return Success("添加成功!");
            }
        }



    }
}