using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using Pub_Class;
using System.Web.Http;
using WebAPI.Models;
using Model;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
namespace WebAPI.Controllers.SCGL
{
    public class Sc_ProductionReturnBillController : ApiController
    {
        private json objJsonResult = new json();
        public DataSet ds = new DataSet();
        public WebServer webserver = new WebServer();
        //public DAL.ClsCg_POInStockBill BillOld = new DAL.ClsCg_POInStockBill();
        public DAL.ClsSc_ProductionReturnBill BillOld = new DAL.ClsSc_ProductionReturnBill();
        public SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        #region 生产退库单 查找记录功能
        /// 
        /// 根据基础资料ID 查找记录
        ///参数:string sql。
        ///返回值:object。
        /// 
        [Route("Sc_ProductionReturnBill/cx")]
        [HttpGet]
        public object cx(long HInterID)
        {
            try
            {
                ds = oCN.RunProcReturn("select * from h_v_IF_ProductionReturnList where hmainid=" + HInterID, "h_v_IF_ProductionReturnList");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "false!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "Sucess!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        /// 
        /// 生产退库单列表
        /// 
        /// 
        [Route("Sc_ProductionReturnBill/list")]
        [HttpGet]
        public object list(string sWhere,string user)
        {
            try
            {
                List