using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Pub_Class;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Web;
using System.Web.Http;
using ViewAPI;
using WebAPI.Models;
namespace WebAPI.Controllers
{
    /**
     * 找货单单
     */
    public class Sc_MouldRepairInBillListController : ApiController
    {
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更)
        private json objJsonResult = new json();
        public DataSet ds = new DataSet();
        public WebServer webserver = new WebServer();
        public SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
        public DAL.ClsSc_MouldScrapInBill BillNew0 = new DAL.ClsSc_MouldScrapInBill();   //模具报废入库对应单据类
        public DAL.ClsSc_MouldScrapInBill BillOld0 = new DAL.ClsSc_MouldScrapInBill();   //模具报废入库对应单据类
        string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"];
        /// 
        /// 根据包装单 返回此包装单内的相关信息
        /// 
        /// 
        /// 
        /// 检具维修工单列表
        /// 
        /// 
        [Route("Sc_CheckToolsRepair/GetCheckToolsRepairWorkBillList")]
        [HttpGet]
        public object GetCheckToolsRepairWorkBillList(string sWhere)
        {
            try
            {
                ds = Sc_CheckToolsRepairWorkBillList_s(sWhere);
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #region sql语句
        public static DataSet Sc_CheckToolsRepairWorkBillList_s(string sWhere)
        {
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_CheckToolsRepairWorkBillList order by 日期 desc", "h_v_Sc_CheckToolsRepairWorkBillList");
        }
        /// 
        /// 检具点检计划表列表
        /// 
        /// 
        [Route("Sc_CheckToolsDotCheckPlan/GetCheckToolsDotCheckPlanBillList")]
        [HttpGet]
        public object GetCheckToolsDotCheckPlanBillList(string sWhere)
        {
            try
            {
                ds = Sc_CheckToolsDotCheckPlanBillList_s(sWhere);
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #region sql语句
        public static DataSet Sc_CheckToolsDotCheckPlanBillList_s(string sWhere)
        {
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_CheckToolsDotCheckPlanBillList order by 日期 desc", "h_v_Sc_CheckToolsDotCheckPlanBillList");
        }
        #endregion
        /// 
        /// 检具保养记录表列表
        /// 
        /// 
        [Route("Sc_CheckToolsMaintainBill/GetCheckToolsMaintainBillList")]
        [HttpGet]
        public object GetCheckToolsMaintainBillList(string sWhere)
        {
            try
            {
                ds = Sc_CheckToolsMaintainBillList_s(sWhere);
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
            }
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #region sql语句
        public static DataSet Sc_CheckToolsMaintainBillList_s(string sWhere)
        {
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_CheckToolsMaintainBillList order by 日期 desc", "h_v_Sc_CheckToolsMaintainBillList");
        }
        #endregion
        /// 
        /// 模具保养记录表列表
        /// 
        /// 
        [Route("Sc_MouldMaintainBill/GetMouldMaintainBillList")]
        [HttpGet]
        public object GetMouldMaintainBillList(string sWhere,string user)
        {
            try
            {
                List