WebAPI/Controllers/QC_ManagementController.cs
@@ -13,6 +13,8 @@
{
    public class QC_ManagementController : ApiController
    {
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        DataSet ds;
        #region 错误返回方法
        // GET: QC_Management
@@ -29,22 +31,22 @@
        {
            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;
                }
                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
                //{
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
                //}
                //else
                //{
                //objJsonResult.code = "0";
                //objJsonResult.count = 0;
                //objJsonResult.Message = "无数据";
                //objJsonResult.data = null;
                //return objJsonResult;
                //}
            }
            catch (Exception e)
            {
@@ -104,11 +106,21 @@
        /// <returns></returns>
        [Route("QC_Management/MES_QC_CheckProjectList_Json")]
        [HttpGet]
        public object MES_QC_CheckProjectList_Json(string sWhere)
        public object MES_QC_CheckProjectList_Json(string sWhere,string user)
        {
            DataSet ds;
            try
            {
                //判断权限
                if (!DBUtility.ClsPub.Security_Log("Gy_QCCheckProject_Query", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查询权限";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (sWhere == null || sWhere.Equals(""))
                {
@@ -174,11 +186,21 @@
        /// <returns></returns>
        [Route("QC_Management/MES_QC_FirstPieceCheckBillList_Json")]
        [HttpGet]
        public object MES_QC_FirstPieceCheckBillList_Json(string sqlWhere)
        public object MES_QC_FirstPieceCheckBillList_Json(string sqlWhere,string user)
        {
            DataSet ds;
            try
            {
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("QC_FirstPieceCheckBill_Query", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (sqlWhere == null || sqlWhere.Equals(""))
                {
@@ -209,11 +231,21 @@
        /// <returns></returns>
        [Route("QC_Management/MES_QC_PatrolProcCheckBillList_Json")]
        [HttpGet]
        public object MES_QC_PatrolProcCheckBillList_Json(string sqlWhere)
        public object MES_QC_PatrolProcCheckBillList_Json(string sqlWhere,string user)
        {
            DataSet ds;
            try
            {
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("QC_PatrolProcCheckBill_Query", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (sqlWhere == null || sqlWhere.Equals(""))
                {
@@ -496,7 +528,17 @@
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string msg3 = sArray[1].ToString();
            string user = sArray[2].ToString();//用户名
            //判断权限
            if (!DBUtility.ClsPub.Security_Log("Gy_QCCheckProject_Edit", 1, false, user))
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "无编辑权限";
                objJsonResult.data = null;
                return objJsonResult;
            }
            string UserName = "";
            ListModels oListModels = new ListModels();
@@ -756,10 +798,6 @@
            }
        }
        #endregion
        #region 来料检验
        /// <summary>
@@ -1091,80 +1129,82 @@
                return objJsonResult;
            }
        }
        #region [伪删除模式]
        ///// <summary>
        ///// 首件检验逻辑删除功能
        ///// </summary>
        ///// <returns></returns>
        //[Route("DeltetQC_FirstPieceCheck")]
        //[HttpGet]
        //public object DeltetQC_FirstPieceCheck(string HInterID,string user)
        //{
        //    DataSet ds;
        //    string ModRightNameCheck = "QC_FirstPieceCheckBill_Delete";
        //    try
        //    {
        //        //删除权限
        //        if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, user))
        //        {
        //            objJsonResult.code = "0";
        //            objJsonResult.count = 0;
        //            objJsonResult.Message = "审核失败!无权限!";
        //            objJsonResult.data = null;
        //            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, false, 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;
        //        }
                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; ;
                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;
            }
        }
        //    }
        //    catch (Exception e)
        //    {
        //        objJsonResult.code = "0";
        //        objJsonResult.count = 0;
        //        objJsonResult.Message = "删除失败!" + e.ToString();
        //        objJsonResult.data = null;
        //        return objJsonResult;
        //    }
        //}
        #endregion
        #endregion
        #region 巡检
@@ -1182,12 +1222,24 @@
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string msg3 = sArray[1].ToString();
            string user = sArray[2].ToString();
            string badmsg = sArray[3].ToString();
            string UserName = "";
            ListModels oListModels = new ListModels();
            try
            {
                //判断权限
                if (!DBUtility.ClsPub.Security_Log("QC_PatrolProcCheckBill_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无保存权限";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                WebAPI.DLL.ClsQC_PatrolProcCheckBill oBill = new WebAPI.DLL.ClsQC_PatrolProcCheckBill();
                List<Model.ClsQC_PatrolProcCheckBillMain> lsmain = new List<Model.ClsQC_PatrolProcCheckBillMain>();
                msg2 = msg2.Replace("\\", "");
@@ -1204,7 +1256,7 @@
                    oItem.HBillSubType = "7506";
                    oItem.HBillStatus = 0;
                    oItem.HPeriod = 0;
                    oItem.HMaker = "";
                    oItem.HMaker = user;
                    oItem.HMainSourceInterID = oItem.HInterID;
                    //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo);
@@ -1250,10 +1302,34 @@
                    oItemSub.HRelationQty = 0;
                    oItemSub.HRelationMoney = 0;
                    oItemSub.HCloseMan = "";
                    oItemSub.HRemark = "";
                    //oItemSub.HRemark = "";
                    oBill.DetailColl.Add(oItemSub);
                }
                badmsg = badmsg.Substring(1, badmsg.Length - 2);
                badmsg = badmsg.Replace("\\", "");
                badmsg = badmsg.Replace("\n", "");  //\n
                List<Model.ClsQC_PatrolProcCheckBillSub_BadReason> bs = new List<Model.ClsQC_PatrolProcCheckBillSub_BadReason>();
                bs = oListModels.getObjectByJson_ClsQC_PatrolProcCheckBillSub_BadReason(badmsg);
                int j = 0;
                foreach (Model.ClsQC_PatrolProcCheckBillSub_BadReason badSub in bs)
                {
                    badSub.HBillNo_bak = oBill.omodel.HBillNo;//单据号(备份,以免内码丢失,找不到对应主表)
                    j++;
                    if (string.IsNullOrWhiteSpace(badSub.HBillNo_bak))
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "保存失败!没备份单据号,无法保存!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    badSub.HInterID = oBill.omodel.HInterID;
                    badSub.HEntryID = j;
                    badSub.HSEQ = j;
                    oBill.DetailColl_Bad.Add(badSub);
                }
                //保存
                //保存完毕后处理
                bool bResult;
@@ -1300,21 +1376,21 @@
        /// <returns></returns>
        [Route("DeltetQC_PatrolProcCheck")]
        [HttpGet]
        public object DeltetQC_PatrolProcCheck(string HInterID)
        public object DeltetQC_PatrolProcCheck(string HInterID,string user)
        {
            DataSet ds;
            //string ModRightNameCheck = "Sc_ProcessReport_check";
            string ModRightNameCheck = "QC_PatrolProcCheckBill_Delete";
            try
            {
                //删除权限
                //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName))
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "审核失败!无权限!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "删除失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (string.IsNullOrWhiteSpace(HInterID))