using System; 
 | 
using System.Collections.Generic; 
 | 
using System.Linq; 
 | 
using System.Web; 
 | 
using System.Web.Http; 
 | 
using WebAPI.Models; 
 | 
using WebAPI.Service; 
 | 
using System.Collections.Generic; 
 | 
using System.Data; 
 | 
using Newtonsoft.Json.Linq; 
 | 
  
 | 
namespace WebAPI.Controllers 
 | 
{ 
 | 
    public class QC_ManagementController : ApiController 
 | 
    { 
 | 
  
 | 
        #region 错误返回方法 
 | 
        // GET: QC_Management 
 | 
        public DBUtility.ClsPub.Enum_BillStatus BillStatus; 
 | 
  
 | 
        private json objJsonResult = new json(); 
 | 
  
 | 
        ///<summary> 
 | 
        ///封装状态码及返回信息的公用方法。 
 | 
        ///参数:DataSet。 
 | 
        ///返回值:json。 
 | 
        ///</summary> 
 | 
        public object GetObjectJson(DataSet ds) 
 | 
        { 
 | 
            try 
 | 
            { 
 | 
                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 = "0"; 
 | 
                    objJsonResult.count = 1; 
 | 
                    objJsonResult.Message = "获取信息成功!"; 
 | 
                    objJsonResult.data = ds.Tables[0]; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 0; 
 | 
                objJsonResult.Message = "没有返回任何记录!" + e.ToString(); 
 | 
                objJsonResult.data = null; 
 | 
                return objJsonResult; 
 | 
            } 
 | 
        } 
 | 
  
 | 
        ///<summary> 
 | 
        ///统一正确信息方法。 
 | 
        ///参数:string。 
 | 
        ///返回值:object。 
 | 
        ///</summary> 
 | 
        public object CustomCorrect(DataSet ds) 
 | 
        { 
 | 
            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 = "0"; 
 | 
                objJsonResult.count = 1; 
 | 
                objJsonResult.Message = "获取信息成功!"; 
 | 
                objJsonResult.data = ds.Tables[0]; 
 | 
                return objJsonResult; 
 | 
            } 
 | 
        } 
 | 
  
 | 
        ///<summary> 
 | 
        ///自定义错误信息方法。 
 | 
        ///参数:string。 
 | 
        ///返回值:object。 
 | 
        ///</summary> 
 | 
        public object CustomError(string msg) 
 | 
        { 
 | 
            objJsonResult.code = "0"; 
 | 
            objJsonResult.count = 0; 
 | 
            objJsonResult.Message = msg; 
 | 
            objJsonResult.data = null; 
 | 
            return objJsonResult; 
 | 
        } 
 | 
        #endregion 
 | 
  
 | 
        #region 查询列表方法 
 | 
        /// <summary> 
 | 
        /// 返回检验方案单列表 
 | 
        /// </summary> 
 | 
        /// <param name="sWhere"></param> 
 | 
        /// <returns></returns> 
 | 
        [Route("QC_Management/MES_QC_CheckProjectList_Json")] 
 | 
        [HttpGet] 
 | 
        public object MES_QC_CheckProjectList_Json(string sqlWhere) 
 | 
        { 
 | 
            DataSet ds; 
 | 
            try 
 | 
            { 
 | 
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); 
 | 
                if (sqlWhere == null || sqlWhere.Equals("")) 
 | 
                { 
 | 
                    ds = oCN.RunProcReturn("select top 500 * from h_v_Gy_QCCheckProjectList where HBillStatus>-1 ", "h_v_Gy_QCCheckProjectList"); 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    string sql1 = "select * from h_v_Gy_QCCheckProjectList where HBillStatus>-1 "; 
 | 
                    string sql = sql1 + sqlWhere; 
 | 
                    ds = oCN.RunProcReturn(sql, "h_v_Gy_QCCheckProjectList"); 
 | 
                } 
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 0; 
 | 
                objJsonResult.Message = "没有返回任何记录!" + e.ToString(); 
 | 
                objJsonResult.data = null; 
 | 
                return objJsonResult; 
 | 
            } 
 | 
            return GetObjectJson(ds); 
 | 
        } 
 | 
  
 | 
        /// <summary> 
 | 
        /// 返回来料检验单列表 
 | 
        /// </summary> 
 | 
        /// <param name="sWhere"></param> 
 | 
        /// <returns></returns> 
 | 
        [Route("QC_Management/MES_QC_POStockInCheckBillList_Json")] 
 | 
        [HttpGet] 
 | 
        public object MES_QC_POStockInCheckBillList_Json(string sqlWhere) 
 | 
        { 
 | 
            DataSet ds; 
 | 
            try 
 | 
            { 
 | 
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); 
 | 
                if (sqlWhere == null || sqlWhere.Equals("")) 
 | 
                { 
 | 
                    ds = oCN.RunProcReturn("select top 500 * from h_v_QC_POStockInCheckBillList where 关闭人='' ", "h_v_QC_POStockInCheckBillList"); 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    string sql1 = "select * from h_v_QC_POStockInCheckBillList where 关闭人='' "; 
 | 
                    string sql = sql1 + sqlWhere; 
 | 
                    ds = oCN.RunProcReturn(sql, "h_v_QC_POStockInCheckBillList"); 
 | 
                } 
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 0; 
 | 
                objJsonResult.Message = "没有返回任何记录!" + e.ToString(); 
 | 
                objJsonResult.data = null; 
 | 
                return objJsonResult; 
 | 
            } 
 | 
            return GetObjectJson(ds); 
 | 
        } 
 | 
  
 | 
        /// <summary> 
 | 
        ///返回首件检验单列表 
 | 
        /// </summary> 
 | 
        /// <param name="sWhere"></param> 
 | 
        /// <returns></returns> 
 | 
        [Route("QC_Management/MES_QC_FirstPieceCheckBillList_Json")] 
 | 
        [HttpGet] 
 | 
        public object MES_QC_FirstPieceCheckBillList_Json(string sqlWhere) 
 | 
        { 
 | 
            DataSet ds; 
 | 
            try 
 | 
            { 
 | 
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); 
 | 
                if (sqlWhere == null || sqlWhere.Equals("")) 
 | 
                { 
 | 
                    ds = oCN.RunProcReturn("select top 500 * from h_v_QC_FirstPieceCheckBillList  where  关闭人='' ", "h_v_QC_FirstPieceCheckBillList"); 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    string sql1 = "select * from h_v_QC_FirstPieceCheckBillList where 关闭人='' "; 
 | 
                    string sql = sql1 + sqlWhere; 
 | 
                    ds = oCN.RunProcReturn(sql, "h_v_QC_FirstPieceCheckBillList"); 
 | 
                } 
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 0; 
 | 
                objJsonResult.Message = "没有返回任何记录!" + e.ToString(); 
 | 
                objJsonResult.data = null; 
 | 
                return objJsonResult; 
 | 
            } 
 | 
            return GetObjectJson(ds); 
 | 
        } 
 | 
  
 | 
        /// <summary> 
 | 
        /// 返回巡检记录单列表 
 | 
        /// </summary> 
 | 
        /// <param name="sWhere"></param> 
 | 
        /// <returns></returns> 
 | 
        [Route("QC_Management/MES_QC_PatrolProcCheckBillList_Json")] 
 | 
        [HttpGet] 
 | 
        public object MES_QC_PatrolProcCheckBillList_Json(string sqlWhere) 
 | 
        { 
 | 
            DataSet ds; 
 | 
            try 
 | 
            { 
 | 
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); 
 | 
                if (sqlWhere == null || sqlWhere.Equals("")) 
 | 
                { 
 | 
                    ds = oCN.RunProcReturn("select top 500 * from h_v_QC_PatrolProcCheckBillList where  关闭人=''", "h_v_QC_PatrolProcCheckBillList"); 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    string sql1 = "select * from h_v_QC_PatrolProcCheckBillList where 关闭人='' "; 
 | 
                    string sql = sql1 + sqlWhere; 
 | 
                    ds = oCN.RunProcReturn(sql, "h_v_QC_PatrolProcCheckBillList"); 
 | 
                } 
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 0; 
 | 
                objJsonResult.Message = "没有返回任何记录!" + e.ToString(); 
 | 
                objJsonResult.data = null; 
 | 
                return objJsonResult; 
 | 
            } 
 | 
            return GetObjectJson(ds); 
 | 
        } 
 | 
  
 | 
  
 | 
        /// <summary> 
 | 
        /// 检验方案获取信息 
 | 
        /// </summary> 
 | 
        /// <returns></returns> 
 | 
        [Route("GetQCCheckProjectDetail")] 
 | 
        [HttpGet] 
 | 
        public ApiResult<DataSet> GetQCCheckProjectDetail(string HID) 
 | 
        { 
 | 
            var model = LuBaoSevice.GetCheckProjectDetail(HID); 
 | 
            return model; 
 | 
        } 
 | 
  
 | 
        /// <summary> 
 | 
        /// 来料检验单获取信息 
 | 
        /// </summary> 
 | 
        /// <returns></returns> 
 | 
        [Route("GetPOStockInCheckDetail")] 
 | 
        [HttpGet] 
 | 
        public ApiResult<DataSet> GetPOStockInCheckDetail(string HID) 
 | 
        { 
 | 
            var model = LuBaoSevice.GetPOStockInCheckBillDetail(HID); 
 | 
            return model; 
 | 
        } 
 | 
  
 | 
        /// <summary> 
 | 
        /// 首件检验单获取信息 
 | 
        /// </summary> 
 | 
        /// <returns></returns> 
 | 
        [Route("GetQC_FirstPieceCheckDetail")] 
 | 
        [HttpGet] 
 | 
        public ApiResult<DataSet> GetQC_FirstPieceCheckDetail(string HID) 
 | 
        { 
 | 
            var model = LuBaoSevice.GetQC_FirstPieceCheckBillDetail(HID); 
 | 
            return model; 
 | 
        } 
 | 
  
 | 
  
 | 
        /// <summary> 
 | 
        /// 巡检单获取信息 
 | 
        /// </summary> 
 | 
        /// <returns></returns> 
 | 
        [Route("GetQC_PatrolProcCheckDetail")] 
 | 
        [HttpGet] 
 | 
        public ApiResult<DataSet> GetQC_PatrolProcCheckDetail(string HID) 
 | 
        { 
 | 
            var model = LuBaoSevice.GetQC_PatrolProcCheckBillDetail(HID); 
 | 
            return model; 
 | 
        } 
 | 
  
 | 
  
 | 
        /// <summary> 
 | 
        /// 返回检验方案单子表详情 
 | 
        /// </summary> 
 | 
        /// <param name="sWhere"></param> 
 | 
        /// <returns></returns> 
 | 
        [Route("MES_QC_CheckProjectDetail_Json")] 
 | 
        [HttpGet] 
 | 
        public object MES_QC_CheckProjectDetail_Json(string sqlWhere) 
 | 
        { 
 | 
            DataSet ds; 
 | 
            try 
 | 
            { 
 | 
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); 
 | 
                if (sqlWhere == null || sqlWhere.Equals("")) 
 | 
                { 
 | 
                    ds = oCN.RunProcReturn("select HPrjNo,HQCCheckItemID,HQCStd,HQCStdMax,HQCUnit,HRemark from Gy_QCCheckProjectSub", "Gy_QCCheckProjectSub"); 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    string sql1 = "select HPrjNo,HQCCheckItemID,HQCStd,HQCStdMax,HQCUnit,HRemark from Gy_QCCheckProjectSub where 1 = 1 "; 
 | 
                    string sql = sql1 + sqlWhere; 
 | 
                    ds = oCN.RunProcReturn(sql, "Gy_QCCheckProjectSub"); 
 | 
                } 
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 0; 
 | 
                objJsonResult.Message = "没有返回任何记录!" + e.ToString(); 
 | 
                objJsonResult.data = null; 
 | 
                return objJsonResult; 
 | 
            } 
 | 
            return GetObjectJson(ds); 
 | 
        } 
 | 
  
 | 
  
 | 
        /// <summary> 
 | 
        /// 返回来料检验单子表详情 
 | 
        /// </summary> 
 | 
        /// <param name="sWhere"></param> 
 | 
        /// <returns></returns> 
 | 
        [Route("MES_QC_POStockInCheckDetail_Json")] 
 | 
        [HttpGet] 
 | 
        public object MES_QC_POStockInCheckDetail_Json(string sqlWhere) 
 | 
        { 
 | 
            DataSet ds; 
 | 
            try 
 | 
            { 
 | 
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); 
 | 
                if (sqlWhere == null || sqlWhere.Equals("")) 
 | 
                { 
 | 
                    ds = oCN.RunProcReturn("select * from h_v_QC_Edit_POStockInCheckBillList", "h_v_QC_Edit_POStockInCheckBillList"); 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    string sql1 = "select * from h_v_QC_Edit_POStockInCheckBillList where 1 = 1 "; 
 | 
                    string sql = sql1 + sqlWhere; 
 | 
                    ds = oCN.RunProcReturn(sql, "h_v_QC_Edit_POStockInCheckBillList"); 
 | 
                } 
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 0; 
 | 
                objJsonResult.Message = "没有返回任何记录!" + e.ToString(); 
 | 
                objJsonResult.data = null; 
 | 
                return objJsonResult; 
 | 
            } 
 | 
            return GetObjectJson(ds); 
 | 
        } 
 | 
  
 | 
        /// <summary> 
 | 
        /// 返回首件检验单子表详情 
 | 
        /// </summary> 
 | 
        /// <param name="sWhere"></param> 
 | 
        /// <returns></returns> 
 | 
        [Route("MES_QC_FirstPieceCheckDetail_Json")] 
 | 
        [HttpGet] 
 | 
        public object MES_QC_FirstPieceCheckDetail_Json(string sqlWhere) 
 | 
        { 
 | 
            DataSet ds; 
 | 
            try 
 | 
            { 
 | 
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); 
 | 
                if (sqlWhere == null || sqlWhere.Equals("")) 
 | 
                { 
 | 
                    ds = oCN.RunProcReturn("select * from h_v_QC_Edit_FirstPieceCheckBillList", "h_v_QC_Edit_FirstPieceCheckBillList"); 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    string sql1 = "select * from h_v_QC_Edit_FirstPieceCheckBillList where 1 = 1 "; 
 | 
                    string sql = sql1 + sqlWhere; 
 | 
                    ds = oCN.RunProcReturn(sql, "h_v_QC_Edit_FirstPieceCheckBillList"); 
 | 
                } 
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 0; 
 | 
                objJsonResult.Message = "没有返回任何记录!" + e.ToString(); 
 | 
                objJsonResult.data = null; 
 | 
                return objJsonResult; 
 | 
            } 
 | 
            return GetObjectJson(ds); 
 | 
        } 
 | 
  
 | 
  
 | 
        /// <summary> 
 | 
        /// 返回巡检单子表详情 
 | 
        /// </summary> 
 | 
        /// <param name="sWhere"></param> 
 | 
        /// <returns></returns> 
 | 
        [Route("MES_QC_PatrolProcCheckDetail_Json")] 
 | 
        [HttpGet] 
 | 
        public object MES_QC_PatrolProcCheckDetail_Json(string sqlWhere) 
 | 
        { 
 | 
            DataSet ds; 
 | 
            try 
 | 
            { 
 | 
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); 
 | 
                if (sqlWhere == null || sqlWhere.Equals("")) 
 | 
                { 
 | 
                    ds = oCN.RunProcReturn("select * from h_v_QC_Edit_PatrolProcCheckBillList", "h_v_QC_Edit_PatrolProcCheckBillList"); 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    string sql1 = "select * from h_v_QC_Edit_PatrolProcCheckBillList where 1 = 1 "; 
 | 
                    string sql = sql1 + sqlWhere; 
 | 
                    ds = oCN.RunProcReturn(sql, "h_v_QC_Edit_PatrolProcCheckBillList"); 
 | 
                } 
 | 
            } 
 | 
            catch (Exception e) 
 | 
            { 
 | 
                objJsonResult.code = "0"; 
 | 
                objJsonResult.count = 0; 
 | 
                objJsonResult.Message = "没有返回任何记录!" + e.ToString(); 
 | 
                objJsonResult.data = null; 
 | 
                return objJsonResult; 
 | 
            } 
 | 
            return GetObjectJson(ds); 
 | 
        } 
 | 
  
 | 
  
 | 
        #endregion 
 | 
  
 | 
        #region 保存/编辑/删除方法 
 | 
  
 | 
        #region 检验方案 
 | 
        /// <summary> 
 | 
        /// 保存检验方案 
 | 
        /// </summary> 
 | 
        /// <param name="msg"></param> 
 | 
        /// <returns></returns> 
 | 
        [Route("SaveQCCheckProjectList")] 
 | 
        [HttpPost] 
 | 
        public object SaveQCCheckProjectList([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 UserName = ""; 
 | 
            ListModels oListModels = new ListModels(); 
 | 
            try 
 | 
            { 
 | 
                DAL.ClsGy_QCCheckProjectMain oBill = new DAL.ClsGy_QCCheckProjectMain(); 
 | 
                List<Model.ClsGy_QCCheckProjectMain> lsmain = new List<Model.ClsGy_QCCheckProjectMain>(); 
 | 
                msg2 = msg2.Replace("\\", ""); 
 | 
                msg2 = msg2.Replace("\n", "");  //\n 
 | 
                lsmain = oListModels.getObjectByJson_Gy_QCCheckProjectMain(msg2); 
 | 
                foreach (Model.ClsGy_QCCheckProjectMain oItem in lsmain) 
 | 
                { 
 | 
                    //oItem.HMaker = ""; 
 | 
                    UserName = oItem.HMaker; 
 | 
                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); 
 | 
                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); 
 | 
                    oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd")); 
 | 
                    oItem.HBillType = "3302"; 
 | 
                    oItem.HBillSubType = "3302"; 
 | 
                    oItem.HBillStatus = 0; 
 | 
                    oItem.HPeriod = 0; 
 | 
                    oItem.HMaker = ""; 
 | 
                    oItem.HStandard = false; 
 | 
                    oItem.HMainSourceInterID = oItem.HInterID; 
 | 
                    oItem.HMaterTypeID = 0; 
 | 
                    //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); 
 | 
                    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.ClsGy_QCCheckProjectSub> ls = new List<Model.ClsGy_QCCheckProjectSub>(); 
 | 
                ls = oListModels.getObjectByJson_ClsGy_QCCheckProjectSub(msg3); 
 | 
                int i = 0; 
 | 
                foreach (Model.ClsGy_QCCheckProjectSub oItemSub in ls) 
 | 
                { 
 | 
                    oItemSub.HBillNo_bak = oBill.omodel.HBillNo;//单据号(备份,以免内码丢失,找不到对应主表) 
 | 
                    i++; 
 | 
                    if (string.IsNullOrWhiteSpace(oItemSub.HBillNo_bak)) 
 | 
                    { 
 | 
                        objJsonResult.code = "0"; 
 | 
                        objJsonResult.count = 0; 
 | 
                        objJsonResult.Message = "保存失败!没备份单据号,无法保存!"; 
 | 
                        objJsonResult.data = 1; 
 | 
                        return objJsonResult; 
 | 
                    } 
 | 
                    oItemSub.HSourceEntryID =0; 
 | 
                    oItemSub.HSourceInterID =0; 
 | 
                    oItemSub.HEntryID = i; 
 | 
                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); 
 | 
                    oItemSub.HCloseType = false; 
 | 
                    oItemSub.HSourceBillNo = ""; 
 | 
                    oItemSub.HSourceBillType = ""; 
 | 
                    oItemSub.HRelationQty = 0; 
 | 
                    oItemSub.HRelationMoney = 0; 
 | 
                    oItemSub.HCloseMan = ""; 
 | 
                    oItemSub.HRemark = ""; 
 | 
                    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 = "保存成功!"; 
 | 
                    //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); 
 | 
                    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; 
 | 
            } 
 | 
        } 
 | 
  
 | 
        /// <summary> 
 | 
        /// 检验方案逻辑删除功能 
 | 
        /// </summary> 
 | 
        /// <returns></returns> 
 | 
        [Route("DeltetQCCheckProject")] 
 | 
        [HttpGet] 
 | 
        public object DeltetQCCheckProject(string HInterID) 
 | 
        { 
 | 
            DataSet ds; 
 | 
            //string ModRightNameCheck = "Sc_ProcessReport_check"; 
 | 
            try 
 | 
            { 
 | 
                //删除权限 
 | 
                //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName)) 
 | 
                //{ 
 | 
                //    objJsonResult.code = "0"; 
 | 
                //    objJsonResult.count = 0; 
 | 
                //    objJsonResult.Message = "审核失败!无权限!"; 
 | 
                //    objJsonResult.data = null; 
 | 
                //    return objJsonResult; 
 | 
                //} 
 | 
                 
 | 
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); 
 | 
                if (string.IsNullOrWhiteSpace(HInterID)) 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "HInterID为空!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
                oCN.BeginTran();//开始事务 
 | 
                ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where HInterID=" + HInterID, "Gy_QCCheckProjectMain"); 
 | 
                DataSet ds2 = oCN.RunProcReturn("select * from Gy_QCCheckProjectSub where HInterID=" + HInterID, "Gy_QCCheckProjectSub"); 
 | 
                if (ds == null || ds.Tables[0].Rows.Count == 0 || ds2==null || ds2.Tables[0].Rows.Count == 0) 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "没有这个单据,无法删除!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; ; 
 | 
                } 
 | 
                int HBillStatus = Convert.ToInt32(ds.Tables[0].Rows[0]["HBillStatus"]); 
 | 
                int HPrjNo= Convert.ToInt32(ds2.Tables[0].Rows[0]["HPrjNo"]); 
 | 
                if (HBillStatus < 0 || HPrjNo<0) 
 | 
                { 
 | 
                    oCN.RollBack();//回滚事务 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "单据已删除无法再次删除!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
              
 | 
                oCN.RunProc("update Gy_QCCheckProjectMain set HBillStatus=-1 where HInterID="+HInterID); 
 | 
                oCN.RunProc("update Gy_QCCheckProjectSub set HPrjNo=-1 where HInterID=" + HInterID); 
 | 
                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 来料检验 
 | 
        /// <summary> 
 | 
        /// 保存来料检验单 
 | 
        /// </summary> 
 | 
        /// <param name="msg"></param> 
 | 
        /// <returns></returns> 
 | 
        [Route("SaveQC_POStockInCheckList")] 
 | 
        [HttpPost] 
 | 
        public object SaveQC_POStockInCheckList([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 UserName = ""; 
 | 
            ListModels oListModels = new ListModels(); 
 | 
            try 
 | 
            { 
 | 
                DAL.ClsQC_POStockInCheckBill oBill = new DAL.ClsQC_POStockInCheckBill(); 
 | 
                List<Model.ClsQC_POStockInCheckBillMain> lsmain = new List<Model.ClsQC_POStockInCheckBillMain>(); 
 | 
                msg2 = msg2.Replace("\\", ""); 
 | 
                msg2 = msg2.Replace("\n", "");  //\n 
 | 
                lsmain = oListModels.getObjectByJson_QC_POStockInCheckBillMain(msg2); 
 | 
                foreach (Model.ClsQC_POStockInCheckBillMain oItem in lsmain) 
 | 
                { 
 | 
                    //oItem.HMaker = ""; 
 | 
                    UserName = oItem.HMaker; 
 | 
                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); 
 | 
                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); 
 | 
                    oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd")); 
 | 
                    oItem.HBillType = "7503"; 
 | 
                    oItem.HBillSubType = "7503"; 
 | 
                    oItem.HBillStatus = 0; 
 | 
                    oItem.HPeriod = 0; 
 | 
                    oItem.HMaker = ""; 
 | 
                    oItem.HMainSourceInterID = oItem.HInterID; 
 | 
  
 | 
                    //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); 
 | 
                    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.ClsQC_POStockInCheckBillSub> ls = new List<Model.ClsQC_POStockInCheckBillSub>(); 
 | 
                ls = oListModels.getObjectByJson_QC_POStockInCheckBillSub(msg3); 
 | 
                int i = 0; 
 | 
                foreach (Model.ClsQC_POStockInCheckBillSub oItemSub in ls) 
 | 
                { 
 | 
                    oItemSub.HBillNo_bak = oBill.omodel.HBillNo;//单据号(备份,以免内码丢失,找不到对应主表) 
 | 
                    i++; 
 | 
                    if (string.IsNullOrWhiteSpace(oItemSub.HBillNo_bak)) 
 | 
                    { 
 | 
                        objJsonResult.code = "0"; 
 | 
                        objJsonResult.count = 0; 
 | 
                        objJsonResult.Message = "保存失败!没备份单据号,无法保存!"; 
 | 
                        objJsonResult.data = 1; 
 | 
                        return objJsonResult; 
 | 
                    } 
 | 
                    oItemSub.HSourceEntryID = 0; 
 | 
                    oItemSub.HSourceInterID = 0; 
 | 
                    oItemSub.HEntryID = i; 
 | 
                    // DBUtility.ClsPub.isDate(DateTime.Now); 
 | 
                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); 
 | 
                    oItemSub.HCloseType = false; 
 | 
                    oItemSub.HSourceBillNo = ""; 
 | 
                    oItemSub.HSourceBillType = ""; 
 | 
                    oItemSub.HRelationQty = 0; 
 | 
                    oItemSub.HRelationMoney = 0; 
 | 
                    oItemSub.HCloseMan = ""; 
 | 
                    oItemSub.HRemark = ""; 
 | 
                    oItemSub.HProcCheckEmp = oBill.omodel.HFirstCheckEmp;//检测员 
 | 
                    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 = "保存成功!"; 
 | 
                    //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); 
 | 
                    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; 
 | 
            } 
 | 
        } 
 | 
  
 | 
        /// <summary> 
 | 
        /// 来料检验逻辑删除功能 
 | 
        /// </summary> 
 | 
        /// <returns></returns> 
 | 
        [Route("DeltetQC_POStockInCheck")] 
 | 
        [HttpGet] 
 | 
        public object DeltetQC_POStockInCheck(string HInterID) 
 | 
        { 
 | 
            DataSet ds; 
 | 
            //string ModRightNameCheck = "Sc_ProcessReport_check"; 
 | 
            try 
 | 
            { 
 | 
                //删除权限 
 | 
                //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName)) 
 | 
                //{ 
 | 
                //    objJsonResult.code = "0"; 
 | 
                //    objJsonResult.count = 0; 
 | 
                //    objJsonResult.Message = "审核失败!无权限!"; 
 | 
                //    objJsonResult.data = null; 
 | 
                //    return objJsonResult; 
 | 
                //} 
 | 
  
 | 
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); 
 | 
                if (string.IsNullOrWhiteSpace(HInterID)) 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "HInterID为空!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
                oCN.BeginTran();//开始事务 
 | 
                ds = oCN.RunProcReturn("select * from QC_POStockInCheckBillMain where HInterID=" + HInterID, "QC_POStockInCheckBillMain"); 
 | 
                DataSet ds2 = oCN.RunProcReturn("select * from QC_POStockInCheckBillSub where HInterID=" + HInterID, "QC_POStockInCheckBillSub"); 
 | 
                if (ds == null || ds.Tables[0].Rows.Count == 0 || ds2 == null || ds2.Tables[0].Rows.Count == 0) 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "没有这个单据,无法删除!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; ; 
 | 
                } 
 | 
                var HCloseMan = Convert.ToString(ds.Tables[0].Rows[0]["HCloseMan"]); 
 | 
                var HCloseMan2 = Convert.ToString(ds2.Tables[0].Rows[0]["HCloseMan"]); 
 | 
                if (!string.IsNullOrWhiteSpace(HCloseMan) || !string.IsNullOrWhiteSpace(HCloseMan2) ) 
 | 
                { 
 | 
                    oCN.RollBack();//回滚事务 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "单据已删除无法再次删除!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
  
 | 
                oCN.RunProc("update QC_POStockInCheckBillMain set HCloseMan='-1',HCloseDate=GETDATE()  where HInterID=" + HInterID); 
 | 
                oCN.RunProc("update QC_POStockInCheckBillSub set HCloseMan='-1',HEntryCloseDate=GETDATE()  where HInterID=" + HInterID); 
 | 
                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 首件检验 
 | 
        /// <summary> 
 | 
        /// 保存首件检验单 
 | 
        /// </summary> 
 | 
        /// <param name="msg"></param> 
 | 
        /// <returns></returns> 
 | 
        [Route("SaveQC_FirstPieceCheckList")] 
 | 
        [HttpPost] 
 | 
        public object SaveQC_FirstPieceCheckList([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 UserName = ""; 
 | 
            ListModels oListModels = new ListModels(); 
 | 
            try 
 | 
            { 
 | 
  
 | 
                DAL.ClsQC_FirstPieceCheckBill oBill = new DAL.ClsQC_FirstPieceCheckBill(); 
 | 
                List<Model.ClsQC_FirstPieceCheckBillMain> lsmain = new List<Model.ClsQC_FirstPieceCheckBillMain>(); 
 | 
                msg2 = msg2.Replace("\\", ""); 
 | 
                msg2 = msg2.Replace("\n", "");  //\n 
 | 
                lsmain = oListModels.getObjectByJson_QC_FirstPieceCheckBillMain(msg2); 
 | 
                foreach (Model.ClsQC_FirstPieceCheckBillMain oItem in lsmain) 
 | 
                { 
 | 
                    //oItem.HMaker = ""; 
 | 
                    UserName = oItem.HMaker; 
 | 
                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); 
 | 
                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); 
 | 
                    oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd")); 
 | 
                    oItem.HBillType = "7505"; 
 | 
                    oItem.HBillSubType = "7505"; 
 | 
                    oItem.HBillStatus = 0; 
 | 
                    oItem.HPeriod = 0; 
 | 
                    oItem.HMaker = ""; 
 | 
                    oItem.HMainSourceInterID = oItem.HInterID; 
 | 
  
 | 
                    //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); 
 | 
                    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.ClsQC_FirstPieceCheckBillSub> ls = new List<Model.ClsQC_FirstPieceCheckBillSub>(); 
 | 
                ls = oListModels.getObjectByJson_QC_FirstPieceCheckBillSub(msg3); 
 | 
                int i = 0; 
 | 
                foreach (Model.ClsQC_FirstPieceCheckBillSub oItemSub in ls) 
 | 
                { 
 | 
                    oItemSub.HBillNo_bak = oBill.omodel.HBillNo;//单据号(备份,以免内码丢失,找不到对应主表) 
 | 
                    i++; 
 | 
                    if (string.IsNullOrWhiteSpace(oItemSub.HBillNo_bak)) 
 | 
                    { 
 | 
                        objJsonResult.code = "0"; 
 | 
                        objJsonResult.count = 0; 
 | 
                        objJsonResult.Message = "保存失败!没备份单据号,无法保存!"; 
 | 
                        objJsonResult.data = 1; 
 | 
                        return objJsonResult; 
 | 
                    } 
 | 
                    oItemSub.HSourceEntryID = 0; 
 | 
                    oItemSub.HSourceInterID = 0; 
 | 
                    oItemSub.HEntryID = i; 
 | 
                    // DBUtility.ClsPub.isDate(DateTime.Now); 
 | 
                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); 
 | 
                    oItemSub.HCloseType = false; 
 | 
                    oItemSub.HSourceBillNo = ""; 
 | 
                    oItemSub.HSourceBillType = ""; 
 | 
                    oItemSub.HRelationQty = 0; 
 | 
                    oItemSub.HRelationMoney = 0; 
 | 
                    oItemSub.HCloseMan = ""; 
 | 
                    oItemSub.HRemark = ""; 
 | 
                    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 = "保存成功!"; 
 | 
                    //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); 
 | 
                    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; 
 | 
            } 
 | 
        } 
 | 
  
 | 
        /// <summary> 
 | 
        /// 首件检验逻辑删除功能 
 | 
        /// </summary> 
 | 
        /// <returns></returns> 
 | 
        [Route("DeltetQC_FirstPieceCheck")] 
 | 
        [HttpGet] 
 | 
        public object DeltetQC_FirstPieceCheck(string HInterID) 
 | 
        { 
 | 
            DataSet ds; 
 | 
            //string ModRightNameCheck = "Sc_ProcessReport_check"; 
 | 
            try 
 | 
            { 
 | 
                //删除权限 
 | 
                //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName)) 
 | 
                //{ 
 | 
                //    objJsonResult.code = "0"; 
 | 
                //    objJsonResult.count = 0; 
 | 
                //    objJsonResult.Message = "审核失败!无权限!"; 
 | 
                //    objJsonResult.data = null; 
 | 
                //    return objJsonResult; 
 | 
                //} 
 | 
  
 | 
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); 
 | 
                if (string.IsNullOrWhiteSpace(HInterID)) 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "HInterID为空!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
                oCN.BeginTran();//开始事务 
 | 
                ds = oCN.RunProcReturn("select * from QC_FirstPieceCheckBillMain where HInterID=" + HInterID, "QC_FirstPieceCheckBillMain"); 
 | 
                DataSet ds2 = oCN.RunProcReturn("select * from QC_FirstPieceCheckBillSub where HInterID=" + HInterID, "QC_FirstPieceCheckBillSub"); 
 | 
                if (ds == null || ds.Tables[0].Rows.Count == 0 || ds2 == null || ds2.Tables[0].Rows.Count == 0) 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "没有这个单据,无法删除!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; ; 
 | 
                } 
 | 
                var HCloseMan = Convert.ToString(ds.Tables[0].Rows[0]["HCloseMan"]); 
 | 
                var HCloseMan2 = Convert.ToString(ds2.Tables[0].Rows[0]["HCloseMan"]); 
 | 
                if (!string.IsNullOrWhiteSpace(HCloseMan) || !string.IsNullOrWhiteSpace(HCloseMan2)) 
 | 
                { 
 | 
                    oCN.RollBack();//回滚事务 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "单据已删除无法再次删除!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
  
 | 
                oCN.RunProc("update QC_FirstPieceCheckBillMain set HCloseMan='-1',HCloseDate=GETDATE()  where HInterID=" + HInterID); 
 | 
                oCN.RunProc("update QC_FirstPieceCheckBillSub set HCloseMan='-1',HEntryCloseDate=GETDATE()  where HInterID=" + HInterID); 
 | 
                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 巡检 
 | 
        /// <summary> 
 | 
        /// 保存巡检单 
 | 
        /// </summary> 
 | 
        /// <param name="msg"></param> 
 | 
        /// <returns></returns> 
 | 
        [Route("SaveQC_PatrolProcCheckList")] 
 | 
        [HttpPost] 
 | 
        public object SaveQC_PatrolProcCheckList([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 UserName = ""; 
 | 
            ListModels oListModels = new ListModels(); 
 | 
            try 
 | 
            { 
 | 
                WebAPI.DLL.ClsQC_PatrolProcCheckBill oBill = new WebAPI.DLL.ClsQC_PatrolProcCheckBill(); 
 | 
                List<Model.ClsQC_PatrolProcCheckBillMain> lsmain = new List<Model.ClsQC_PatrolProcCheckBillMain>(); 
 | 
                msg2 = msg2.Replace("\\", ""); 
 | 
                msg2 = msg2.Replace("\n", "");  //\n 
 | 
                lsmain = oListModels.getObjectByJson_QC_PatrolProcCheckBillMain(msg2); 
 | 
                foreach (Model.ClsQC_PatrolProcCheckBillMain oItem in lsmain) 
 | 
                { 
 | 
                    //oItem.HMaker = ""; 
 | 
                    UserName = oItem.HMaker; 
 | 
                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); 
 | 
                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); 
 | 
                    oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd")); 
 | 
                    oItem.HBillType = "7506"; 
 | 
                    oItem.HBillSubType = "7506"; 
 | 
                    oItem.HBillStatus = 0; 
 | 
                    oItem.HPeriod = 0; 
 | 
                    oItem.HMaker = ""; 
 | 
                    oItem.HMainSourceInterID = oItem.HInterID; 
 | 
  
 | 
                    //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); 
 | 
                    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.ClsQC_PatrolProcCheckBillSub> ls = new List<Model.ClsQC_PatrolProcCheckBillSub>(); 
 | 
                ls = oListModels.getObjectByJson_QC_PatrolProcCheckBillSub(msg3); 
 | 
                int i = 0; 
 | 
                foreach (Model.ClsQC_PatrolProcCheckBillSub oItemSub in ls) 
 | 
                { 
 | 
                    oItemSub.HBillNo_bak = oBill.omodel.HBillNo;//单据号(备份,以免内码丢失,找不到对应主表) 
 | 
                    i++; 
 | 
                    if (string.IsNullOrWhiteSpace(oItemSub.HBillNo_bak)) 
 | 
                    { 
 | 
                        objJsonResult.code = "0"; 
 | 
                        objJsonResult.count = 0; 
 | 
                        objJsonResult.Message = "保存失败!没备份单据号,无法保存!"; 
 | 
                        objJsonResult.data = 1; 
 | 
                        return objJsonResult; 
 | 
                    } 
 | 
                    oItemSub.HSourceEntryID = 0; 
 | 
                    oItemSub.HSourceInterID = 0; 
 | 
                    oItemSub.HEntryID = i; 
 | 
                    // DBUtility.ClsPub.isDate(DateTime.Now); 
 | 
                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); 
 | 
                    oItemSub.HCloseType = false; 
 | 
                    oItemSub.HSourceBillNo = ""; 
 | 
                    oItemSub.HSourceBillType = ""; 
 | 
                    oItemSub.HRelationQty = 0; 
 | 
                    oItemSub.HRelationMoney = 0; 
 | 
                    oItemSub.HCloseMan = ""; 
 | 
                    oItemSub.HRemark = ""; 
 | 
                    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 = "保存成功!"; 
 | 
                    //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); 
 | 
                    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; 
 | 
            } 
 | 
        } 
 | 
  
 | 
        /// <summary> 
 | 
        /// 巡检逻辑删除功能 
 | 
        /// </summary> 
 | 
        /// <returns></returns> 
 | 
        [Route("DeltetQC_PatrolProcCheck")] 
 | 
        [HttpGet] 
 | 
        public object DeltetQC_PatrolProcCheck(string HInterID) 
 | 
        { 
 | 
            DataSet ds; 
 | 
            //string ModRightNameCheck = "Sc_ProcessReport_check"; 
 | 
            try 
 | 
            { 
 | 
                //删除权限 
 | 
                //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName)) 
 | 
                //{ 
 | 
                //    objJsonResult.code = "0"; 
 | 
                //    objJsonResult.count = 0; 
 | 
                //    objJsonResult.Message = "审核失败!无权限!"; 
 | 
                //    objJsonResult.data = null; 
 | 
                //    return objJsonResult; 
 | 
                //} 
 | 
  
 | 
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); 
 | 
                if (string.IsNullOrWhiteSpace(HInterID)) 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "HInterID为空!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
                oCN.BeginTran();//开始事务 
 | 
                ds = oCN.RunProcReturn("select * from QC_PatrolProcCheckBillMain where HInterID=" + HInterID, "QC_PatrolProcCheckBillMain"); 
 | 
                DataSet ds2 = oCN.RunProcReturn("select * from QC_PatrolProcCheckBillSub where HInterID=" + HInterID, "QC_PatrolProcCheckBillSub"); 
 | 
                if (ds == null || ds.Tables[0].Rows.Count == 0 || ds2 == null || ds2.Tables[0].Rows.Count == 0) 
 | 
                { 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "没有这个单据,无法删除!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; ; 
 | 
                } 
 | 
                var HCloseMan = Convert.ToString(ds.Tables[0].Rows[0]["HCloseMan"]); 
 | 
                var HCloseMan2 = Convert.ToString(ds2.Tables[0].Rows[0]["HCloseMan"]); 
 | 
                if (!string.IsNullOrWhiteSpace(HCloseMan) || !string.IsNullOrWhiteSpace(HCloseMan2)) 
 | 
                { 
 | 
                    oCN.RollBack();//回滚事务 
 | 
                    objJsonResult.code = "0"; 
 | 
                    objJsonResult.count = 0; 
 | 
                    objJsonResult.Message = "单据已删除无法再次删除!"; 
 | 
                    objJsonResult.data = null; 
 | 
                    return objJsonResult; 
 | 
                } 
 | 
  
 | 
                oCN.RunProc("update QC_PatrolProcCheckBillMain set HCloseMan='-1',HCloseDate=GETDATE()  where HInterID=" + HInterID); 
 | 
                oCN.RunProc("update QC_PatrolProcCheckBillSub set HCloseMan='-1',HEntryCloseDate=GETDATE()  where HInterID=" + HInterID); 
 | 
                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 
 | 
  
 | 
        #endregion 
 | 
  
 | 
  
 | 
  
 | 
  
 | 
    } 
 | 
} 
 |