using DBUtility; using Newtonsoft.Json.Linq; using SQLHelper; using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Net; using System.Net.Http; using System.Web; using System.Web.Http; using WebAPI.Code; using WebAPI.Models; namespace WebAPI.Controllers { public class PODemandPlanController : ApiController { private JsonResult objJsonResult = new JsonResult(); private json objjson = new json(); /// /// 采购单列表 /// /// /// /// /// [Route("GetPODemandPlanBill")] [HttpPost] //采购订单列表 public object GetPODemandPlanBill([FromBody] JObject msg) { string HSupIDs = msg["HSupIDs"].ToString(); string sqlWhere = msg["sqlWhere"].ToString(); try { string VsWhere = ""; string PcWhere = ""; SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); DataSet ds; //其他过滤 string sql = " Where hsupid in (" + HSupIDs.Trim() + ")" + sqlWhere; //转换特殊字符 if (Common.SQLtoChange(sql, ref VsWhere, ref PcWhere) == false) { objjson.code = "0"; objjson.count = 0; objjson.Message = "获取失败"; objjson.data = null; return objjson; } //获取总行数 Int64 RowTotal = Common.GetRowTotal("h_v_SRM_JIT_PODemandPlanBillList", VsWhere, ref DBUtility.ClsPub.sExeReturnInfo); //获取返回数据 ds = oCn.RunProcReturn("exec H_p_SRM_PODemandPlanBillList '" + PcWhere + "'", "H_p_SRM_PODemandPlanBillList"); if (ds == null || ds.Tables[0].Rows.Count == 0) { objjson.code = "0"; objjson.count = 0; objjson.Message = "获取失败"; objjson.data = null; return objjson; } else { objjson.code = "0"; objjson.count = 10000; objjson.Message = "获取成功"; objjson.data = ds.Tables[0]; return objjson; } } catch (Exception e) { objjson.code = "0"; objjson.count = 0; objjson.Message = "获取失败" + e.ToString(); objjson.data = null; return objjson; } } /// /// 要货通知单表头信息 /// /// /// [Route("GetPODemandPlanShowBillMain")] [HttpGet] public object GetPODemandPlanShowBillMain(string sMsg) { try { DataSet ds; string ShowItem = " * ";//显示的字段 if (DBUtility.ClsPub.isLong(sMsg) == 0) { objjson.code = "0"; objjson.count = 0; objjson.Message = "获取失败"; objjson.data = null; return objjson; } DAL.ClsSRM_PODemandPlanBill oClsSRM_PODemandPlanBill = new DAL.ClsSRM_PODemandPlanBill(); ds = oClsSRM_PODemandPlanBill.ShowBillMainTo(DBUtility.ClsPub.isLong(sMsg), ShowItem, ref DBUtility.ClsPub.sExeReturnInfo); if (ds == null || ds.Tables[0].Rows.Count == 0) { objjson.code = "0"; objjson.count = 0; objjson.Message = "获取失败"; objjson.data = null; return objjson; } else { objjson.code = "0"; objjson.count = 10000; objjson.Message = "获取成功"; objjson.data = ds.Tables[0]; return objjson; } } catch (Exception e) { objjson.code = "0"; objjson.count = 0; objjson.Message = "获取失败" + e.ToString(); objjson.data = null; return objjson; } } /// /// 要货通知单明细表体信息 /// /// /// /// [Route("GetPODemandPlanShowBillSub")] [HttpGet] public object GetPODemandPlanShowBillSub(string sMsg) { try { DataSet ds = null; string ShowItem = " * ";//显示的字段 if (DBUtility.ClsPub.isLong(sMsg) == 0) { objjson.code = "0"; objjson.count = 0; objjson.Message = "获取失败"; objjson.data = null; return objjson; } DAL.ClsSRM_PODemandPlanBill oClsSRM_PODemandPlanBill = new DAL.ClsSRM_PODemandPlanBill(); ds = oClsSRM_PODemandPlanBill.ShowBillSubTo(DBUtility.ClsPub.isLong(sMsg), ShowItem, ref DBUtility.ClsPub.sExeReturnInfo); if (ds == null || ds.Tables[0].Rows.Count == 0) { //return DBUtility.ClsPub.sExeReturnInfo; objjson.code = "0"; objjson.count = 0; objjson.Message = "获取失败"; objjson.data = null; return objjson; } else { objjson.code = "0"; objjson.count = 10000; objjson.Message = "获取成功"; objjson.data = ds.Tables[0]; return objjson; } //return s; } catch (Exception e) { objjson.code = "0"; objjson.count = 0; objjson.Message = "获取失败" + e.ToString(); objjson.data = null; return objjson; } } [Route("PODemandPlanAccept")] [HttpGet] /// /// 订单接受 /// /// /// public object PODemandPlanAccept(string HInterID, string HEntryID, string HBillNo, string HUser) { try { if (DBUtility.ClsPub.isLong(HInterID) == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "接受失败!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsSRM_PODemandPlanBill oBill = new DAL.ClsSRM_PODemandPlanBill(); oBill.WebAccept(DBUtility.ClsPub.isLong(HInterID), DBUtility.ClsPub.isLong(HEntryID), DBUtility.ClsPub.isStrNull(HBillNo), DBUtility.ClsPub.isStrNull(HUser), ref DBUtility.ClsPub.sExeReturnInfo); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "接受成功!"; objJsonResult.data = 1; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "接受失败!"+e.ToString(); objJsonResult.data = null; return objJsonResult; } } [Route("PODemandPlanRefuse")] [HttpGet] /// /// 订单拒绝 /// /// /// public object PODemandPlanRefuse(string HInterID, string HEntryID, string HBillNo, string HUser, string HBackRemark) { try { if (DBUtility.ClsPub.isLong(HInterID) == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "失败!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsSRM_PODemandPlanBill oBill = new DAL.ClsSRM_PODemandPlanBill(); oBill.WebRefuse(DBUtility.ClsPub.isLong(HInterID), DBUtility.ClsPub.isLong(HEntryID), DBUtility.ClsPub.isStrNull(HBillNo), DBUtility.ClsPub.isStrNull(HUser), DBUtility.ClsPub.isStrNull(HBackRemark), ref DBUtility.ClsPub.sExeReturnInfo); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "拒绝成功!"; objJsonResult.data = 1; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "失败!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } } }