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.CJGL 
 | 
{ 
 | 
    public class Sc_ProcExchSendWorkBillController : ApiController 
 | 
    { 
 | 
        public DBUtility.ClsPub.Enum_BillStatus BillStatus; 
 | 
        private json objJsonResult = new json(); 
 | 
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); 
 | 
        public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill(); 
 | 
        DataSet ds; 
 | 
  
 | 
        #region 工序派工单列表 
 | 
        [Route("Sc_ProcExchSendWorkBill/Sc_ProcExchSendWorkBillList")] 
 | 
        [HttpGet] 
 | 
        public object Sc_ProcExchSendWorkBillList(string sWhere, string user) 
 | 
        { 
 | 
            try 
 | 
            { 
 | 
                List<object> columnNameList = new List<object>();                
 | 
  
 | 
                string sql1 = "select * from h_v_Sc_ProcExchSendWorkBillList where 1 = 1  "; 
 | 
                string sql = sql1 + sWhere + " order by hmainid desc"; 
 | 
                ds = oCN.RunProcReturn(sql, "h_v_Sc_ProcExchSendWorkBillList"); 
 | 
  
 | 
                //添加列名 
 | 
                foreach (DataColumn col in ds.Tables[0].Columns) 
 | 
                { 
 | 
                    Type dataType = col.DataType; 
 | 
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; 
 | 
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 
 | 
                } 
 | 
  
 | 
  
 | 
                objJsonResult.code = "1"; 
 | 
                objJsonResult.count = 1; 
 | 
                objJsonResult.Message = "Sucess!"; 
 | 
                objJsonResult.list = columnNameList; 
 | 
                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_ProcExchSendWorkBill/Sc_ProcExchSendWorkBillListByEmp")] 
 | 
        [HttpGet] 
 | 
        public object Sc_ProcExchSendWorkBillListByEmp(string sWhere, string user,int HEmpID) 
 | 
        { 
 | 
            try 
 | 
            { 
 | 
                List<object> columnNameList = new List<object>(); 
 | 
  
 | 
                string sql = $"exec  h_p_Sc_ProcExchSendWorkBillListByEmp '{sWhere}','{user}',{HEmpID} "; 
 | 
                ds = oCN.RunProcReturn(sql, "h_p_Sc_ProcExchSendWorkBillListByEmp"); 
 | 
  
 | 
                //添加列名 
 | 
                foreach (DataColumn col in ds.Tables[0].Columns) 
 | 
                { 
 | 
                    Type dataType = col.DataType; 
 | 
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; 
 | 
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 
 | 
                } 
 | 
  
 | 
  
 | 
                objJsonResult.code = "1"; 
 | 
                objJsonResult.count = 1; 
 | 
                objJsonResult.Message = "Sucess!"; 
 | 
                objJsonResult.list = columnNameList; 
 | 
                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_ProcExchSendWorkBill/Sc_ProcessExchangeHEmpList")] 
 | 
        [HttpGet] 
 | 
        public object Sc_ProcessExchangeHEmpList(string sWhere, string user) 
 | 
        { 
 | 
            DataSet ds; 
 | 
            try 
 | 
            { 
 | 
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); 
 | 
                List<object> columnNameList = new List<object>(); 
 | 
                //得到信息(委外标记为0时,流转标记为1时) 
 | 
                //ds = oCN.RunProcReturn("select  * from h_v_Sc_ProcessExchangeBillList_Sec  where 下道流转工序<>'转' and 委外标记=0 and 流转标记=1  and 工序号='" + sProcNo + "' and 序列号='" + HSEQNumber + "'", "h_v_Sc_ProcessExchangeBillList_Sec"); 
 | 
                ds = oCN.RunProcReturn("select  * from h_v_Sc_ProcessExchangeArrangementHEmpList  where 1=1 " + sWhere, "h_v_Sc_ProcessExchangeArrangementHEmpList"); 
 | 
  
 | 
                //添加列名 
 | 
                foreach (DataColumn col in ds.Tables[0].Columns) 
 | 
                { 
 | 
                    Type dataType = col.DataType; 
 | 
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; 
 | 
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 
 | 
                } 
 | 
                 
 | 
                objJsonResult.code = "1"; 
 | 
                objJsonResult.count = 1; 
 | 
                objJsonResult.Message = "[0000-1-037]Sucess!"; 
 | 
                objJsonResult.data = ds.Tables[0]; 
 | 
                objJsonResult.list = columnNameList; 
 | 
                return objJsonResult; 
 | 
                 
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 0; 
 | 
                objJsonResult.Message = "没有返回任何记录!" + e.ToString(); 
 | 
                objJsonResult.data = null; 
 | 
            } 
 | 
            return objJsonResult; 
 | 
        } 
 | 
        #endregion 
 | 
  
 | 
        #region 查询工序流转卡数据 
 | 
        [Route("Sc_ProcExchSendWorkBill/GetProcessExchangeBillSub")] 
 | 
        [HttpGet] 
 | 
        public object GetProcessExchangeBillSub_cf(string sWhere) 
 | 
        { 
 | 
            DataSet ds; 
 | 
            try 
 | 
            { 
 | 
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); 
 | 
                string sql = string.Format(@"select * from h_v_Sc_ProcessExchangeBillQuerySub_SendWork"); 
 | 
                ds = oCN.RunProcReturn(sql + sWhere + " order by convert(int,流水号) asc", "h_v_Sc_ProcessExchangeBillQuerySub_SendWork"); 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 1; 
 | 
                objJsonResult.Message = "获取信息成功!"; 
 | 
                objJsonResult.data = ds.Tables[0]; 
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 0; 
 | 
                objJsonResult.Message = "没有返回任何记录!" + e.ToString(); 
 | 
                objJsonResult.data = null; 
 | 
            } 
 | 
            return objJsonResult; 
 | 
        } 
 | 
        #endregion 
 | 
  
 | 
        #region 工序派工单 保存/编辑 
 | 
        /// <summary> 
 | 
        /// 工序派工单 保存 
 | 
        /// </summary> 
 | 
        /// <param name="msg"></param> 
 | 
        /// <returns></returns> 
 | 
        [Route("Sc_ProcExchSendWorkBill/SaveProcessSendWork")] 
 | 
        [HttpPost] 
 | 
        public object SaveProcessSendWork([FromBody] JObject msg) 
 | 
        { 
 | 
            var _value = msg["msg"].ToString(); 
 | 
            string msg1 = _value.ToString(); 
 | 
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); 
 | 
            string msg2 = sArray[0].ToString(); 
 | 
            string msg3 = sArray[1].ToString(); 
 | 
            string msg4 = sArray[2].ToString(); 
 | 
  
 | 
  
 | 
            string UserName = ""; 
 | 
            ListModels oListModels = new ListModels(); 
 | 
            try 
 | 
            { 
 | 
                DAL.ClsSc_ProcExchSendWorkBill oBill = new DAL.ClsSc_ProcExchSendWorkBill(); 
 | 
                List<Model.ClsSc_ProcExchSendWorkBillMain> lsmain = new List<Model.ClsSc_ProcExchSendWorkBillMain>(); 
 | 
                msg2 = msg2.Replace("\\", ""); 
 | 
                msg2 = msg2.Replace("\n", "");  //\n 
 | 
                lsmain = oListModels.getObjectByJson_ClsSc_ProcExchSendWorkBillMain(msg2); 
 | 
                foreach (Model.ClsSc_ProcExchSendWorkBillMain oItem in lsmain) 
 | 
                { 
 | 
                    //oItem.HMaker = ""; 
 | 
                    UserName = oItem.HMaker;  //制单人 
 | 
                    oItem.HBillType = "3798"; 
 | 
                    oItem.HBillSubType = "3798"; 
 | 
                    oItem.HBillStatus = 1; 
 | 
                    DBUtility.ClsPub.CurUserName = UserName; 
 | 
                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); 
 | 
  
 | 
                    if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") 
 | 
                    { 
 | 
                        objJsonResult.code = "0"; 
 | 
                        objJsonResult.count = 0; 
 | 
                        objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; 
 | 
                        objJsonResult.data = 1; 
 | 
                        return objJsonResult; 
 | 
                    } 
 | 
                    oBill.omodel = oItem; 
 | 
                } 
 | 
                //表体数据 
 | 
                //按 },{来拆分数组 //去掉【和】 
 | 
                msg3 = msg3.Substring(1, msg3.Length - 2); 
 | 
                msg3 = msg3.Replace("\\", ""); 
 | 
                msg3 = msg3.Replace("\n", "");  //\n 
 | 
                //msg2 = msg2.Replace("'", "’"); 
 | 
                List<Model.ClsSc_ProcExchSendWorkBillSub> ls = new List<Model.ClsSc_ProcExchSendWorkBillSub>(); 
 | 
                ls = oListModels.getObjectByJson_ClsSc_ProcExchSendWorkBillSub(msg3); 
 | 
                int i = 0; 
 | 
                foreach (Model.ClsSc_ProcExchSendWorkBillSub oItemSub in ls) 
 | 
                { 
 | 
  
 | 
                    i++; 
 | 
                    oItemSub.HEntryID = i; 
 | 
                    //oItemSub.HCloseMan = "";       //行关闭 
 | 
                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); 
 | 
                    oItemSub.HCloseType = false;   //关闭类型 
 | 
                    //oItemSub.HRemark = "";         //备注 
 | 
                    oItemSub.HSourceInterID = oItemSub.HSourceInterID;     // 源单主内码 
 | 
                    oItemSub.HSourceEntryID = oItemSub.HSourceEntryID;   //源单子内码 
 | 
                    oItemSub.HSourceBillNo = oItemSub.HSourceBillNo;  //源单单号 
 | 
                    oItemSub.HSourceBillType = oItemSub.HSourceBillType; //源单类型 
 | 
                    oItemSub.HRelationQty = 0;     //关联数量 
 | 
             
 | 
                    oBill.DetailColl.Add(oItemSub); 
 | 
  
 | 
                } 
 | 
                //保存 
 | 
                //保存完毕后处理 
 | 
                bool bResult; 
 | 
                if (oBill.omodel.HInterID == 0) 
 | 
                { 
 | 
                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); 
 | 
                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); 
 | 
                } 
 | 
                if (bResult) 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 1; 
 | 
                    objJsonResult.Message = "保存成功!"; 
 | 
                    objJsonResult.data = 1; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; 
 | 
                    objJsonResult.data = 1; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 0; 
 | 
                objJsonResult.Message = "保存失败!" + e.ToString(); 
 | 
                objJsonResult.data = 1; 
 | 
                return objJsonResult; 
 | 
            } 
 | 
        } 
 | 
        #endregion 
 | 
  
 | 
        //#region 工序派工单 删除 
 | 
        [Route("Sc_ProcExchSendWorkBill/DelProcessSendWork")] 
 | 
        [HttpGet] 
 | 
        public object DelProcessSendWork(string HInterID, string user) 
 | 
        { 
 | 
            Int64 lngBillKey = 0; 
 | 
            lngBillKey = DBUtility.ClsPub.isLong(HInterID); 
 | 
            if (lngBillKey == 0) 
 | 
            { 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 0; 
 | 
                objJsonResult.Message = "单据ID为空!"; 
 | 
                objJsonResult.data = null; 
 | 
                return objJsonResult; 
 | 
            } 
 | 
            DAL.ClsSc_ProcExchSendWorkBill oBill = new DAL.ClsSc_ProcExchSendWorkBill(); 
 | 
            if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) 
 | 
            { 
 | 
                ds = oCN.RunProcReturn("select * from Sc_ProcExchSendWorkBillMain where HInterID=" + lngBillKey, "Sc_ProcExchSendWorkBillMain"); 
 | 
                if (int.Parse(ds.Tables[0].Rows[0]["HBillStatus"].ToString()) > 1) 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "单据当前处于不能删除状态,不能删除!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
  
 | 
                if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "") 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "单据已经审核,不能删除!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
  
 | 
                //删除前控制=========================================       
 | 
                string HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString(); 
 | 
                string sql1 = "exec h_p_Sc_ProcExchSendWorkBill_BeforeDelCtrl " + HInterID + ",'" + HBillNo + "','" + user + "'"; 
 | 
                ds = oCN.RunProcReturn(sql1, "h_p_Sc_ProcExchSendWorkBill_BeforeDelCtrl"); 
 | 
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "删除失败!原因:删除前判断失败,请与网络管理人员联系"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
  
 | 
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "删除失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
                //==================================================================================       
 | 
  
 | 
                bool IsDete = oBill.DeleteBill(lngBillKey, HBillNo, "h_p_Sc_ProcExchSendWorkBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo); 
 | 
                if (IsDete) 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 1; 
 | 
                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
  
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 0; 
 | 
                objJsonResult.Message = "单据未找到"; 
 | 
                objJsonResult.data = null; 
 | 
                return objJsonResult; 
 | 
            } 
 | 
        } 
 | 
        //#endregion 
 | 
  
 | 
        #region 工序派工单审核/反审核功能 
 | 
        [Route("Sc_ProcExchSendWorkBill/CheckSc_ProcExchSendWorkBill")] 
 | 
        [HttpGet] 
 | 
        public object CheckSc_ProcExchSendWorkBill(string HInterID, int Type, string user) 
 | 
        { 
 | 
            try 
 | 
            { 
 | 
                //判断是否有删除权限 
 | 
                if (!DBUtility.ClsPub.Security_Log("Sc_ProcessSendWork_Check", 1, false, user)) 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "无权限审核!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
  
 | 
                if (string.IsNullOrWhiteSpace(HInterID)) 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "HInterID为空!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
  
 | 
                ClsPub.CurUserName = user; 
 | 
                BillOld.MvarItemKey = "Sc_ProcExchSendWorkBillMain"; 
 | 
                oCN.BeginTran();//开始事务 
 | 
  
 | 
                //Type 1 审核  2  反审核 
 | 
                if (Type == 1) 
 | 
                { 
 | 
                    //判断单据是否已经审核 
 | 
                    DataSet ds; 
 | 
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; 
 | 
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); 
 | 
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) 
 | 
                    { 
 | 
                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") 
 | 
                        { 
 | 
                            objJsonResult.code = "0"; 
 | 
                            objJsonResult.count = 0; 
 | 
                            objJsonResult.Message = "单据已审核!不需要再审核!"; 
 | 
                            objJsonResult.data = null; 
 | 
                            return objJsonResult; 
 | 
                        } 
 | 
                    } 
 | 
  
 | 
                    //审核前控制 
 | 
                    string HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString(); 
 | 
                    sql = "exec h_p_Sc_ProcExchSendWorkBill_BeforeCheckCtrl " + int.Parse(HInterID) + ",'" + HBillNo + "','" + user + "'"; 
 | 
                    ds = oCN.RunProcReturn(sql, "h_p_Sc_ProcExchSendWorkBill_BeforeCheckCtrl"); 
 | 
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) 
 | 
                    { 
 | 
                        objJsonResult.code = "0"; 
 | 
                        objJsonResult.count = 1; 
 | 
                        objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系"; 
 | 
                        objJsonResult.data = null; 
 | 
                        return objJsonResult; 
 | 
  
 | 
                    } 
 | 
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") 
 | 
                    { 
 | 
                        objJsonResult.code = "0"; 
 | 
                        objJsonResult.count = 1; 
 | 
                        objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; 
 | 
                        objJsonResult.data = null; 
 | 
                        return objJsonResult; 
 | 
                    } 
 | 
  
 | 
                    //审核单据 
 | 
                    if (!BillOld.CheckBill(Int64.Parse(HInterID), HBillNo, "h_p_Sc_ProcExchSendWorkBill_AfterCheckCtrl", user, ref ClsPub.sExeReturnInfo)) 
 | 
                    { 
 | 
                        objJsonResult.code = "0"; 
 | 
                        objJsonResult.count = 1; 
 | 
                        objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo; 
 | 
                        objJsonResult.data = null; 
 | 
                        return objJsonResult; 
 | 
                    } 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    //判断单据是否已经反审核 
 | 
                    DataSet ds; 
 | 
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; 
 | 
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); 
 | 
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) 
 | 
                    { 
 | 
                        if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "") 
 | 
                        { 
 | 
                            objJsonResult.code = "0"; 
 | 
                            objJsonResult.count = 0; 
 | 
                            objJsonResult.Message = "单据已反审核!不需要再反审核!"; 
 | 
                            objJsonResult.data = null; 
 | 
                            return objJsonResult; 
 | 
                        } 
 | 
                    } 
 | 
  
 | 
                    //反审核前控制 
 | 
                    string HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString(); 
 | 
                    sql = "exec h_p_Sc_ProcExchSendWorkBill_BeforeUnCheckCtrl " + int.Parse(HInterID) + ",'" + HBillNo + "','" + user + "'"; 
 | 
                    ds = oCN.RunProcReturn(sql, "h_p_Sc_ProcExchSendWorkBill_BeforeUnCheckCtrl"); 
 | 
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) 
 | 
                    { 
 | 
                        objJsonResult.code = "0"; 
 | 
                        objJsonResult.count = 1; 
 | 
                        objJsonResult.Message = "反审核失败!原因:反审核前判断失败,请与网络管理人员联系"; 
 | 
                        objJsonResult.data = null; 
 | 
                        return objJsonResult; 
 | 
  
 | 
                    } 
 | 
                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") 
 | 
                    { 
 | 
                        objJsonResult.code = "0"; 
 | 
                        objJsonResult.count = 1; 
 | 
                        objJsonResult.Message = "反审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; 
 | 
                        objJsonResult.data = null; 
 | 
                        return objJsonResult; 
 | 
                    } 
 | 
  
 | 
                    //反审核单据 
 | 
                    if (BillOld.AbandonCheck(Int64.Parse(HInterID), HBillNo, "h_p_Sc_ProcExchSendWorkBill_AfterUnCheckCtrl", user, ref ClsPub.sExeReturnInfo)) 
 | 
                    { 
 | 
                        //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); 
 | 
                        //DataSet DSet = oCn.RunProcReturn("exec h_p_Sc_ICMOBill_AbandonCheckCtrl " + int.Parse(HInterID), "h_p_Sc_ICMOBill_AbandonCheckCtrl"); 
 | 
                        ////if (DBUtility.ClsPub.isInt(DSet.Tables[0].Rows[0]["Hback"]) != 0) 
 | 
                        ////{ 
 | 
                        ////    objJsonResult.code = "0"; 
 | 
                        ////    objJsonResult.count = 1; 
 | 
                        ////    objJsonResult.Message = "该任务单已下推流转卡,不允许反审核" + DBUtility.ClsPub.isStrNull(DSet.Tables[0].Rows[0]["HBackRemark"]); 
 | 
                        ////    objJsonResult.data = null; 
 | 
                        ////    return objJsonResult; 
 | 
                        ////} 
 | 
                    } 
 | 
                    else 
 | 
                    { 
 | 
                        objJsonResult.code = "0"; 
 | 
                        objJsonResult.count = 1; 
 | 
                        objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo; 
 | 
                        objJsonResult.data = null; 
 | 
                        return objJsonResult; 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                oCN.Commit();//提交事务 
 | 
  
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 1; 
 | 
                objJsonResult.Message = "执行成功!"; 
 | 
                objJsonResult.data = null; 
 | 
                return objJsonResult; ; 
 | 
  
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 0; 
 | 
                objJsonResult.Message = "执行失败!" + e.ToString(); 
 | 
                objJsonResult.data = null; 
 | 
                return objJsonResult; 
 | 
            } 
 | 
        } 
 | 
        #endregion 
 | 
  
 | 
        #region 工序派工单关闭/反关闭功能 
 | 
        [Route("Sc_ProcExchSendWorkBill/CloseSc_ProcExchSendWorkBill")] 
 | 
        [HttpGet] 
 | 
        public object CloseSc_ProcExchSendWorkBill(string HInterID, int Type, string user) 
 | 
        { 
 | 
            try 
 | 
            { 
 | 
                //判断是否有删除权限 
 | 
                if (!DBUtility.ClsPub.Security_Log("Sc_ProcessSendWork_Close", 1, false, user)) 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "无权限关闭!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
  
 | 
                if (string.IsNullOrWhiteSpace(HInterID)) 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "HInterID为空!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
  
 | 
                ClsPub.CurUserName = user; 
 | 
                BillOld.MvarItemKey = "Sc_ProcExchSendWorkBillMain"; 
 | 
                oCN.BeginTran();//开始事务 
 | 
  
 | 
                //Type 1 关闭  2  反关闭 
 | 
                if (Type == 1) 
 | 
                { 
 | 
                    //判断单据是否已经关闭 
 | 
                    DataSet ds; 
 | 
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; 
 | 
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); 
 | 
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) 
 | 
                    { 
 | 
                        if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") 
 | 
                        { 
 | 
                            objJsonResult.code = "0"; 
 | 
                            objJsonResult.count = 0; 
 | 
                            objJsonResult.Message = "单据已关闭!不需要再关闭!"; 
 | 
                            objJsonResult.data = null; 
 | 
                            return objJsonResult; 
 | 
                        } 
 | 
                    } 
 | 
                    //关闭单据 
 | 
                    if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) 
 | 
                    { 
 | 
                        objJsonResult.code = "0"; 
 | 
                        objJsonResult.count = 1; 
 | 
                        objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo; 
 | 
                        objJsonResult.data = null; 
 | 
                        return objJsonResult; 
 | 
                    } 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    //判断单据是否已经反关闭 
 | 
                    DataSet ds; 
 | 
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; 
 | 
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); 
 | 
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) 
 | 
                    { 
 | 
                        if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "") 
 | 
                        { 
 | 
                            objJsonResult.code = "0"; 
 | 
                            objJsonResult.count = 0; 
 | 
                            objJsonResult.Message = "单据已反关闭!不需要再反关闭!"; 
 | 
                            objJsonResult.data = null; 
 | 
                            return objJsonResult; 
 | 
                        } 
 | 
                    } 
 | 
                    //反关闭单据 
 | 
                    if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) 
 | 
                    { 
 | 
                        objJsonResult.code = "0"; 
 | 
                        objJsonResult.count = 1; 
 | 
                        objJsonResult.Message = "反关闭失败!原因:" + ClsPub.sExeReturnInfo; 
 | 
                        objJsonResult.data = null; 
 | 
                        return objJsonResult; 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                oCN.Commit();//提交事务 
 | 
  
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 1; 
 | 
                objJsonResult.Message = "执行成功!"; 
 | 
                objJsonResult.data = null; 
 | 
                return objJsonResult; ; 
 | 
  
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 0; 
 | 
                objJsonResult.Message = "执行失败!" + e.ToString(); 
 | 
                objJsonResult.data = null; 
 | 
                return objJsonResult; 
 | 
            } 
 | 
        } 
 | 
        #endregion 
 | 
  
 | 
  
 | 
  
 | 
    } 
 | 
} 
 |