using Newtonsoft.Json.Linq;
using Pub_Class;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Data.SqlClient;
using System.Web.Http;
using WebAPI.Models;
namespace WebAPI.Controllers
{
//生产上料单Controller
public class Sc_MaterToSourceBillController : ApiController
{
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
private json objJsonResult = new json();
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
DataSet ds;
//获取系统参数
Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
public DAL.ClsSc_MESMaterToSourceBill BillNew = new DAL.ClsSc_MESMaterToSourceBill(); //对应单据类
public DAL.ClsSc_MESMaterToSourceBill BillOld = new DAL.ClsSc_MESMaterToSourceBill(); //对应单据类
#region 上料放错单Web列表查询
///
/// 返回生产上料单列表
///参数:string sql。
///返回值:object。
///
[Route("Sc_MaterToSourceBill/list")]
[HttpGet]
public object list(string sWhere)
{
try
{
if (sWhere == null || sWhere.Equals(""))
{
ds = oCN.RunProcReturn("select * from h_v_Sc_MaterToSourceBillMain " + sWhere, "h_v_Sc_MaterToSourceBillMain");
}
else
{
string sql1 = "select * from h_v_Sc_MaterToSourceBillMain where 1 = 1 ";
string sql = sql1 + sWhere;
ds = oCN.RunProcReturn(sql, "h_v_Sc_MaterToSourceBillMain");
}
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "没有返回任何记录!";
objJsonResult.data = ds.Tables[0];
return objJsonResult;
}
else
{
objJsonResult.code = "1";
objJsonResult.count = 1;
objJsonResult.Message = "查询数据成功!";
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
#region 上料防错单编辑时获取表头数据
[Route("Sc_MaterToSourceBill/Sc_MaterToSourceBillListCheckDetai")]
[HttpGet]
public ApiResult Sc_MaterToSourceBillListCheckDetai(string HID)
{
if (string.IsNullOrEmpty(HID))
return new ApiResult { code = -1, msg = "ID不能为空" };
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_MaterToSourceBillMain where hmainid= " + HID + " ", "h_v_Sc_MaterToSourceBillMain");
if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
return new ApiResult { code = -1, msg = "不存在上料防错单数据" };
return new ApiResult { code = 1, msg = "查询成功", data = dataSet };
}
#endregion
#region 上料防错单编辑时获取表体数据(配料记录、治具记录)
[Route("Sc_MaterToSourceBill/Sc_MaterToSourceBillListProjectDetai")]
[HttpGet]
public object Sc_MaterToSourceBillListProjectDetai(string HInterID)
{
DataSet ds, ds1;
List