using Newtonsoft.Json; 
 | 
using Newtonsoft.Json.Linq; 
 | 
using Pub_Class; 
 | 
using System; 
 | 
using System.Collections; 
 | 
using System.Collections.Generic; 
 | 
using System.Data; 
 | 
using System.Data.SqlClient; 
 | 
using System.Web.Http; 
 | 
using WebAPI.Models; 
 | 
  
 | 
namespace WebAPI.Controllers 
 | 
{ 
 | 
    //收款单Controller 
 | 
    public class KB_CGSLController : ApiController 
 | 
    { 
 | 
        //获取系统参数 
 | 
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); 
 | 
        public DBUtility.ClsPub.Enum_BillStatus BillStatus; 
 | 
        private json objJsonResult = new json(); 
 | 
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); 
 | 
        DataSet ds; 
 | 
  
 | 
        #region 采购收料看板 查询 
 | 
        /// <summary> 
 | 
        /// 返回应收单列表 
 | 
        ///参数:string sql。 
 | 
        ///返回值:object。 
 | 
        /// </summary> 
 | 
        [Route("KB_CGSL/getData_CGSL")] 
 | 
        [HttpGet] 
 | 
        public object getData_CGSL(string sWhere, string user) 
 | 
        { 
 | 
            try 
 | 
            { 
 | 
                ////查看权限 
 | 
                //if (!DBUtility.ClsPub.Security_Log("Xs_ReceivableBill_Query", 1, false, user)) 
 | 
                //{ 
 | 
                //    objJsonResult.code = "0"; 
 | 
                //    objJsonResult.count = 0; 
 | 
                //    objJsonResult.Message = "无查看权限!"; 
 | 
                //    objJsonResult.data = null; 
 | 
                //    return objJsonResult; 
 | 
                //} 
 | 
  
 | 
                List<DataTable> tableList = new List<DataTable>(); 
 | 
  
 | 
                List<object> columnNameListSum = new List<object>(); 
 | 
                List<object> columnNameList0 = new List<object>(); 
 | 
                List<object> columnNameList1 = new List<object>(); 
 | 
                List<object> columnNameList2 = new List<object>(); 
 | 
                List<object> columnNameList3 = new List<object>(); 
 | 
                List<object> columnNameList4 = new List<object>(); 
 | 
  
 | 
                //获取 待收料列表 数据 
 | 
                string sql0 = "select * from h_v_KB_CGSL_Query order by 来料日期 desc"; 
 | 
                DataSet ds0 = oCN.RunProcReturn(sql0, "h_v_KB_CGSL_Query"); 
 | 
                if(ds0!=null && ds0.Tables.Count > 0) 
 | 
                { 
 | 
                    tableList.Add(ds0.Tables[0]); 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "Exception!原因:获取待收料列表数据失败!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
  
 | 
                //获取 待收料列表 列数据 
 | 
                foreach (DataColumn col in ds0.Tables[0].Columns) 
 | 
                { 
 | 
                    Type dataType = col.DataType; 
 | 
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; 
 | 
                    columnNameList0.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 
 | 
                } 
 | 
                columnNameListSum.Add(columnNameList0); 
 | 
  
 | 
  
 | 
                //获取图表数据 
 | 
                string sql1 = "exec h_p_KB_CGSL_getChartsData"; 
 | 
                DataSet ds1 = oCN.RunProcReturn(sql1, "h_p_KB_CGSL_getChartsData"); 
 | 
                if(ds1 == null){ 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "Exception!原因:获取图表数据失败!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
  
 | 
                //获取 图表数据 
 | 
                for(int i = 0; i < ds1.Tables.Count; i++) 
 | 
                { 
 | 
                    tableList.Add(ds1.Tables[i]); 
 | 
                } 
 | 
  
 | 
                objJsonResult.code = "1"; 
 | 
                objJsonResult.count = 1; 
 | 
                objJsonResult.Message = "Sucess!"; 
 | 
                objJsonResult.data = tableList; 
 | 
                objJsonResult.list = columnNameListSum; 
 | 
                return objJsonResult; 
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 0; 
 | 
                objJsonResult.Message = "Exception!" + e.ToString(); 
 | 
                objJsonResult.data = null; 
 | 
                return objJsonResult; 
 | 
            } 
 | 
        } 
 | 
        #endregion 
 | 
    } 
 | 
} 
 |