yusijie
8 天以前 01685f3ab68f64b51b83eee40af90f4030866691
WebAPI/Controllers/BaseSet/Gy_ProcessController.cs
@@ -20,6 +20,7 @@
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        DataSet ds;
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
        #region 工序 文件上传
        [Route("Gy_Process/Gy_Process_Excel")]
@@ -28,6 +29,9 @@
        {
            try
            {
                string Ret = "";
                oSystemParameter.ShowBill(ref Ret);
                //获取文件名称
                var file = HttpContext.Current.Request.Files[0];
                //获取文件物理路径
@@ -114,6 +118,8 @@
                if (!tb2.Columns.Contains("巡检质检方案名称"))
                    error += "没有找到【巡检质检方案名称】的标题,";
                if (!tb2.Columns.Contains("工序分类"))
                    error += "没有找到【工序分类】的标题,";
                if (error.Length > 0)
@@ -129,6 +135,7 @@
                {
                    string HProcessName = "";
                    string HProcessNum = "";
                    string HProcType = "";
                    string HORGNumber = "";
                    string HORGName = "";
                    string HDeptNum = "";
@@ -144,6 +151,7 @@
                    HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["工序名称"].ToString());
                    HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["工序代码"].ToString());
                    HProcType = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["工序分类"].ToString());
                    HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString());
                    HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString());
                    HDeptNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["部门代码"].ToString());
@@ -182,83 +190,166 @@
                        }
                        string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        //查询部门
                        ds = oCN.RunProcReturn("select * from Gy_Department where  HNumber='" + HDeptNum + "'  and HUSEORGID=" + HORGid + "", "Gy_Department");
                        if (ds.Tables[0].Rows.Count == 0)
                        if (oSystemParameter.omodel.WMS_CampanyName == "宝工")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,部门:" + HDeptName + ",不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                            if (HProcType == "")
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "第" + index + "行,工序分类不能为空!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            //查询部门
                            ds = oCN.RunProcReturn("select * from Gy_Department where  HNumber='" + HDeptNum + "'  and HUSEORGID=" + HORGid + "", "Gy_Department");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                tb2.Rows[i]["HDeptID"] = 0;
                            }
                            else
                            {
                                tb2.Rows[i]["HDeptID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                            }
                            //查询首件质检方案
                            ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Fst + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                tb2.Rows[i]["HQCSchemeID_Fst"] = 0;
                            }
                            else
                            {
                                tb2.Rows[i]["HQCSchemeID_Fst"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                            }
                            //查询工序质检方案
                            ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Proc + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                tb2.Rows[i]["HQCSchemeID_Proc"] = 0;
                            }
                            else
                            {
                                tb2.Rows[i]["HQCSchemeID_Proc"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                            }
                            //查询巡检质检方案
                            ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Patrol + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                tb2.Rows[i]["HQCSchemeID_Patrol"] = 0;
                            }
                            else
                            {
                                tb2.Rows[i]["HQCSchemeID_Patrol"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                            }
                            //查询工作中心
                            ds = oCN.RunProcReturn("select * from Gy_WorkCenter where  HNumber='" + HCentNum + "' and HUSEORGID=" + HORGid + "", "Gy_WorkCenter"); //
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                tb2.Rows[i]["HWorkCenterID"] = 0;
                            }
                            else
                            {
                                tb2.Rows[i]["HWorkCenterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                            }
                        }
                        else
                        {
                            tb2.Rows[i]["HDeptID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                        }
                            //查询部门
                            ds = oCN.RunProcReturn("select * from Gy_Department where  HNumber='" + HDeptNum + "'  and HUSEORGID=" + HORGid + "", "Gy_Department");
                        //查询首件质检方案
                        ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Fst + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,部门:" + HDeptName + ",不存在!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            else
                            {
                                tb2.Rows[i]["HDeptID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                            }
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,首件质检方案:" + HQCSchemeName_Fst + ",不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            tb2.Rows[i]["HQCSchemeID_Fst"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                        }
                        //查询工序质检方案
                        ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Proc + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                            //查询首件质检方案
                            ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Fst + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,工序质检方案:" + HQCSchemeName_Proc + ",不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            tb2.Rows[i]["HQCSchemeID_Proc"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                        }
                        //查询巡检质检方案
                        ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Patrol + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,首件质检方案:" + HQCSchemeName_Fst + ",不存在!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            else
                            {
                                tb2.Rows[i]["HQCSchemeID_Fst"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                            }
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,巡检质检方案:" + HQCSchemeName_Patrol + ",不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            tb2.Rows[i]["HQCSchemeID_Patrol"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                        }
                            //查询工序质检方案
                            ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Proc + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                        //查询工作中心
                        ds = oCN.RunProcReturn("select * from Gy_WorkCenter where  HNumber='" + HCentNum + "' and HUSEORGID=" + HORGid + "", "Gy_WorkCenter"); //
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,工序质检方案:" + HQCSchemeName_Proc + ",不存在!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            else
                            {
                                tb2.Rows[i]["HQCSchemeID_Proc"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                            }
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,工作中心:" + HCentName + ",不存在!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        else
                        {
                            tb2.Rows[i]["HWorkCenterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                            //查询巡检质检方案
                            ds = oCN.RunProcReturn("select * from Gy_QCCheckProjectMain where  HBillNo='" + HQCSchemeNum_Patrol + "' and HUSEORGID=" + HORGid + "", "Gy_QCCheckProjectMain");
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,巡检质检方案:" + HQCSchemeName_Patrol + ",不存在!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            else
                            {
                                tb2.Rows[i]["HQCSchemeID_Patrol"] = ds.Tables[0].Rows[0]["HInterID"].ToString();
                            }
                            //查询工作中心
                            ds = oCN.RunProcReturn("select * from Gy_WorkCenter where  HNumber='" + HCentNum + "' and HUSEORGID=" + HORGid + "", "Gy_WorkCenter"); //
                            if (ds.Tables[0].Rows.Count == 0)
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,工作中心:" + HCentName + ",不存在!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                            else
                            {
                                tb2.Rows[i]["HWorkCenterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
                            }
                            //工序代码
                            if (HProcessNum == "")
                            {
                                objJsonResult.code = "0";
                                objJsonResult.count = 0;
                                objJsonResult.Message = "第" + index + "行,工序资源代码不能为空!";
                                objJsonResult.data = null;
                                return objJsonResult;
                            }
                        }
                        //工序名称
@@ -271,15 +362,7 @@
                            return objJsonResult;
                        }
                        //工序代码
                        if (HProcessNum == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "第" + index + "行,工序资源代码不能为空!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    else
                    {
@@ -320,6 +403,9 @@
            string user = sArray[1].ToString();
            try
            {
                string Ret = "";
                oSystemParameter.ShowBill(ref Ret);
                if (!DBUtility.ClsPub.Security_Log("Gy_Porcess_Edit", 1, false, user))
                {
                    objJsonResult.code = "0";
@@ -354,6 +440,7 @@
                    string HQCSchemeID_Patrol = item["HQCSchemeID_Patrol"].ToString();//巡检质检方案ID
                    string HProcessName = item["工序名称"].ToString();
                    string HProcessNum = item["工序代码"].ToString();
                    string HProcType = item["工序分类"].ToString();
                    string sShortNumber;
                    sShortNumber = DBUtility.ClsPub.GetShortNumber(HProcessNum);//短代码
                    if (sShortNumber.Trim() == "")
@@ -377,18 +464,25 @@
                        return objJsonResult;
                    }
                    ds = oCN.RunProcReturn("select * from Gy_Process where HNumber='" + HProcessNum + "'", "Gy_Source");
                    if (oSystemParameter.omodel.WMS_CampanyName == "宝工")
                    {
                        ds = oCN.RunProcReturn("select * from Gy_Process where HName='" + HProcessName + "'", "Gy_Process");
                    }
                    else
                    {
                        ds = oCN.RunProcReturn("select * from Gy_Process where HNumber='" + HProcessNum + "'", "Gy_Source");
                    }
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        string sql = "insert into Gy_Process(HName,HNumber,HDeptID,HUSEORGID,HCREATEORGID,HWorkCenterID,HShortNumber,HQCSchemeID_Fst,HQCSchemeID_Proc,HQCSchemeID_Patrol,HEndFlag,HLevel,HHelpCode,HParentID,HStopflag,HRemark,HTypeFlow,HTypeCount)" +
                            $"values('{HProcessName}', '{HProcessNum}',{HDeptID}, {HOrgID}, {HOrgID}, {HWorkCenterID}, '{sShortNumber}',{HQCSchemeID_Fst},{HQCSchemeID_Proc},{HQCSchemeID_Patrol},{HEndFlag},{HLevel},'',0,0,'',0,0)";
                        string sql = "insert into Gy_Process(HName,HNumber,HDeptID,HUSEORGID,HCREATEORGID,HWorkCenterID,HShortNumber,HQCSchemeID_Fst,HQCSchemeID_Proc,HQCSchemeID_Patrol,HEndFlag,HLevel,HHelpCode,HParentID,HStopflag,HRemark,HTypeFlow,HTypeCount,HProcType)" +
                            $"values('{HProcessName}', '{HProcessNum}',{HDeptID}, {HOrgID}, {HOrgID}, {HWorkCenterID}, '{sShortNumber}',{HQCSchemeID_Fst},{HQCSchemeID_Proc},{HQCSchemeID_Patrol},{HEndFlag},{HLevel},'',0,0,'',0,0,'{HProcType}')";
                        oCN.RunProc(sql);
                    }
                    else
                    {
                        oCN.RunProc("   update  Gy_Process set HWorkCenterID=" + HWorkCenterID + ",HDeptID=" + HDeptID + ",HQCSchemeID_Fst=" + HQCSchemeID_Fst + ",HQCSchemeID_Proc=" + HQCSchemeID_Proc + ",HQCSchemeID_Patrol=" + HQCSchemeID_Patrol + "  where HNumber='" + HProcessNum + "'");
                        oCN.RunProc("   update  Gy_Process set HWorkCenterID=" + HWorkCenterID + ",HDeptID=" + HDeptID + ",HQCSchemeID_Fst=" + HQCSchemeID_Fst + ",HQCSchemeID_Proc=" + HQCSchemeID_Proc + ",HQCSchemeID_Patrol=" + HQCSchemeID_Patrol + ",HProcType = '" + HProcType + "'  where HNumber='" + HProcessNum + "'");
                    }
                    i++;
@@ -695,6 +789,7 @@
                long HItemID = list[0].HItemID;
                string HNumber = list[0].HNumber;
                string HName = list[0].HName;
                string HProcType = list[0].HProcType;
                string HShortNumber = list[0].HNumber;
                long HParentID = list[0].HParentID;
                string HHelpCode = list[0].HHelpCode;
@@ -720,6 +815,7 @@
                long HDeptID = list[0].HDeptID;
                long HProcID = list[0].HProcID;
                int HUSEORGID = list[0].HUSEORGID;
                int HCREATEORGID = list[0].HCREATEORGID;
                bool HTProcessFlag = list[0].HTProcessFlag;
                int HQCSchemeID_Fst = list[0].HQCSchemeID_Fst;
                int HQCSchemeID_Proc = list[0].HQCSchemeID_Proc;
@@ -733,8 +829,9 @@
                long HWWBadWHID = list[0].HWWBadWHID; //委外不良仓库
                long HWWWasterWHID = list[0].HWWWasterWHID; //委外报废仓库
                long HWHID = list[0].HWHID; //良品仓库
                string HMakeEmp = user;
                string HPayMentType = list[0].HPayMentType; //计件工资类型
                decimal HStandardWages = list[0].HStandardWages; //标准工价
                //判断权限
@@ -769,28 +866,128 @@
                if (HItemID == 0)
                {
                    oCN.BeginTran();
                    //判断代码是否重复
                    DataSet dss;
                    dss = oCN.RunProcReturn("select * from Gy_Process where HNumber='" + HNumber + "'", "Gy_Process");
                    //判断是否可编辑
                    if (dss.Tables[0].Rows.Count!=0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据代码重复不允许新增";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //保存前控制=========================================
                    string sql1 = "exec h_p_Gy_Process_BeforeSaveCtrl " + HMakeEmp + ",'" + 1 + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_Process_BeforeSaveCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "保存失败!原因:保存前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        oCN.RollBack();
                        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;
                        oCN.RollBack();
                        return objJsonResult;
                    }
                    //==================================================================================
                    oCN.RunProc("Insert into  Gy_Process  " +
                        " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
                        ",HTypeFlow,HTypeCount,HDeptNumber,HSNo" +
                        ",HLevel,HEndFlag,HStopflag,HRemark,HDeptID,HBarCodeForBase,HProcessID_K3,HBillSubType,HAutoTrunFlag" +
                        ",HFixPrice,HOverFixPrice,HProcMulID,HProcCheckNote" +
                        ",HUSEORGID,HWorkCenterID,HBadWHID,HWasterWHID,HBadCountDevelopWHID,HWWBadWHID,HWWWasterWHID,HWHID,HTProcessFlag" +
                        ",HQCSchemeID_Fst,HQCSchemeID_Proc,HQCSchemeID_Patrol,HPayMentType) " +
                        " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + HParentID.ToString() +
                        "," + Convert.ToString(HTypeFlow ? 1 : 0) + "," + Convert.ToString(HTypeCount ? 1 : 0) + ",'" + HDeptNumber + "','" + HSNo.ToString() +
                        "'," + HLevel.ToString() + "," + Convert.ToString(HEndFlag ? 1 : 0) + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "'," + HDeptID +
                        ",'" + HBarCodeForBase + "'," + HProcessID_K3 + ",'" + HBillSubType + "'," + Convert.ToString(HAutoTrunFlag ? 1 : 0) +
                        ",'" + HFixPrice.ToString() + "'," + HOverFixPrice.ToString() + "," + HProcMulID.ToString() + ",'" + HProcCheckNote.ToString() + "'" +
                        "," + HUSEORGID + "," + HWorkCenterID + "," + HBadWHID + "," + HWasterWHID + "," + HBadCountDevelopWHID + "," + HWWBadWHID + "," + HWWWasterWHID + "," + HWHID + "," + Convert.ToString(HTProcessFlag ? 1 : 0) + "," + HQCSchemeID_Fst + "," + HQCSchemeID_Proc + "," + HQCSchemeID_Patrol
                        + ",'" + HPayMentType + "'" + ")", ref DBUtility.ClsPub.sExeReturnInfo);
                         " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
                         ",HTypeFlow,HTypeCount,HDeptNumber,HSNo,HUseFlag" +
                         ",HLevel,HEndFlag,HStopflag,HRemark,HDeptID,HBarCodeForBase,HProcessID_K3,HBillSubType,HAutoTrunFlag" +
                         ",HFixPrice,HOverFixPrice,HProcMulID,HProcCheckNote" +
                         ",HUSEORGID,HCREATEORGID,HWorkCenterID,HBadWHID,HWasterWHID,HBadCountDevelopWHID,HWWBadWHID,HWWWasterWHID,HWHID,HTProcessFlag" +
                         ",HQCSchemeID_Fst,HQCSchemeID_Proc,HQCSchemeID_Patrol,HPayMentType,HMakeTime,HMakeEmp,HStandardWages,HProcType) " +
                         " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + HParentID.ToString() +
                         "," + Convert.ToString(HTypeFlow ? 1 : 0) + "," + Convert.ToString(HTypeCount ? 1 : 0) + ",'" + HDeptNumber + "','" + HSNo.ToString() + "','" + HUseFlag.ToString() +
                         "'," + HLevel.ToString() + "," + Convert.ToString(HEndFlag ? 1 : 0) + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "'," + HDeptID +
                         ",'" + HBarCodeForBase + "'," + HProcessID_K3 + ",'" + HBillSubType + "'," + Convert.ToString(HAutoTrunFlag ? 1 : 0) +
                         ",'" + HFixPrice.ToString() + "'," + HOverFixPrice.ToString() + "," + HProcMulID.ToString() + ",'" + HProcCheckNote.ToString() + "'" +
                         "," + HUSEORGID + "," + HCREATEORGID + "," + HWorkCenterID + "," + HBadWHID + "," + HWasterWHID + "," + HBadCountDevelopWHID + "," + HWWBadWHID + "," + HWWWasterWHID + "," + HWHID + "," + Convert.ToString(HTProcessFlag ? 1 : 0) + "," + HQCSchemeID_Fst + "," + HQCSchemeID_Proc + "," + HQCSchemeID_Patrol
                         + ",'" + HPayMentType + "',getdate(),'" + HMakeEmp + "'," + HStandardWages + ",'" + HProcType + "' )", ref DBUtility.ClsPub.sExeReturnInfo);
                    //修改上级为非末级代码
                    oCN.RunProc("Update Gy_Process set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                    //保存后控制=========================================
                    string sql2 = "exec h_p_Gy_Process_AfterSaveCtrl " + HMakeEmp + ",'" + 1 + "'";
                    ds = oCN.RunProcReturn(sql2, "h_p_Gy_Process_AfterSaveCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "保存失败!原因:保存后判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        oCN.RollBack();
                        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;
                        oCN.RollBack();
                        return objJsonResult;
                    }
                    //==================================================================================
                    oCN.Commit();
                }
                else
                {
                    //若MAINDI重复则重新获取
                    oCN.BeginTran();
                    //已审核不允许修改
                    DataSet dss;
                    dss = oCN.RunProcReturn("select * from Gy_Process where HItemID=" + HItemID, "Gy_Process");
                    //判断是否可编辑
                    if (dss.Tables[0].Rows[0]["HCheckEmp"].ToString() != "" )
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "此单据状态已经审核,不允许修改!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    //保存前控制=========================================
                    string sql1 = "exec h_p_Gy_Process_BeforeSaveCtrl " + HMakeEmp + ",'" + 2 + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_Process_BeforeSaveCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "保存失败!原因:保存前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        oCN.RollBack();
                        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;
                        oCN.RollBack();
                        return objJsonResult;
                    }
                    //==================================================================================
                    oCN.RunProc("Update Gy_Process set " +
                        " HNumber='" + HNumber + "'" +
                        ",HName='" + HName + "'" +
@@ -801,12 +998,15 @@
                        ",HTypeCount= '" + HTypeCount + "'" +
                        ",HDeptNumber='" + HDeptNumber + "'" +
                        ",HSNo= " + HSNo +
                        ",HUseFlag= '" + HUseFlag + "'" +
                        ",HLevel= " + HLevel +
                        ",HEndFlag= '" + HEndFlag + "'" +
                        ",HTProcessFlag= '" + HTProcessFlag + "'" +
                        ",HStopflag= '" + HStopflag + "'" +
                        ",HRemark='" + HRemark + "'" +
                        ",HDeptID= " + HDeptID +
                        ",HUSEORGID='" + HUSEORGID + "'" +
                        ",HCREATEORGID='" + HCREATEORGID + "'" +
                        ",HBarCodeForBase='" + HBarCodeForBase + "'" +
                        ",HProcessID_K3= " + HProcessID_K3 +
                        ",HBillSubType='" + HBillSubType + "'" +
@@ -825,10 +1025,41 @@
                        ",HQCSchemeID_Proc= " + HQCSchemeID_Proc +
                        ",HQCSchemeID_Patrol= " + HQCSchemeID_Patrol +
                        ",HPayMentType= '" + HPayMentType + "'" +
                        ",HProcCheckNote='" + HProcCheckNote + "' Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                        ",HStandardWages= " + HStandardWages +
                        ",HModifyTime= getdate()" +
                        ",HModifyEmp='" + HMakeEmp + "'" +
                        ",HProcCheckNote='" + HProcCheckNote + "' " +
                        ",HProcType = '" + HProcType + "' " +
                        " Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                    //修改上级为非末级代码
                    oCN.RunProc("Update Gy_Process set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                    //
                    //保存后控制=========================================
                    string sql2 = "exec h_p_Gy_Process_AfterSaveCtrl " + HMakeEmp + ",'" + 2 + "'";
                    ds = oCN.RunProcReturn(sql2, "h_p_Gy_Process_AfterSaveCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "保存失败!原因:保存后判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        oCN.RollBack();
                        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;
                        oCN.RollBack();
                        return objJsonResult;
                    }
                    //==================================================================================
                    oCN.Commit();
                }
                objJsonResult.code = "0";
@@ -1005,17 +1236,7 @@
                    objJsonResult.Message = "已经审核不能删除!";
                    objJsonResult.data = null;
                    return objJsonResult; ;
                }
                //var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]);
                //if (HStopflag)
                //{
                //    oCN.RollBack();//回滚事务
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "数据已删除无法再次删除!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                }
                ds1 = oCN.RunProcReturn("Select HItemID from  Gy_Process  Where HParentID='" + HItemID + "'", " Gy_Process");
                if (ds1.Tables[0].Rows.Count != 0)
                {
@@ -1036,7 +1257,58 @@
                    return objJsonResult;
                }
                //删除前控制=========================================
                string sql1 = "exec h_p_Gy_Process_BeforeDelCtrl " + HItemID + ",'" + user + "'";
                ds = oCN.RunProcReturn(sql1, "h_p_Gy_Process_BeforeDelCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:删除前判断失败,请与网络管理人员联系";
                    objJsonResult.data = null;
                    oCN.RollBack();
                    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;
                    oCN.RollBack();
                    return objJsonResult;
                }
                //==================================================================================
                oCN.RunProc("delete from  Gy_Process  where HItemID=" + HItemID);
                //删除后控制=========================================
                string sql2 = "exec h_p_Gy_Process_AfterDelCtrl " + HItemID + ",'" + user + "'";
                ds = oCN.RunProcReturn(sql2, "h_p_Gy_Process_AfterDelCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:删除后判断失败,请与网络管理人员联系";
                    objJsonResult.data = null;
                    oCN.RollBack();
                    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;
                    oCN.RollBack();
                    return objJsonResult;
                }
                //==================================================================================
                oCN.Commit();//提交事务
                objJsonResult.code = "0";
                objJsonResult.count = 1;
@@ -1120,7 +1392,59 @@
                if (IsAudit == 0)  //审核判断
                {
                    //审核前控制=========================================
                    string sql1 = "exec h_p_Gy_Process_BeforeCheckCtrl " + HInterID + ",'" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_Process_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;
                        oCN.RollBack();
                        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;
                        oCN.RollBack();
                        return objJsonResult;
                    }
                    //==================================================================================
                    oCN.RunProc("update Gy_Process set HCheckEmp='" + CurUserName + "',HCheckTime=getdate() where HItemID=" + HInterID);
                    //审核后控制=========================================
                    string sql2 = "exec h_p_Gy_Process_AfterCheckCtrl " + HInterID + ",'" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql2, "h_p_Gy_Process_AfterCheckCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "审核失败!原因:审核后判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        oCN.RollBack();
                        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;
                        oCN.RollBack();
                        return objJsonResult;
                    }
                    //==================================================================================
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
@@ -1129,7 +1453,59 @@
                }
                if (IsAudit == 1) //反审核判断
                {
                    //反审核前控制=========================================
                    string sql1 = "exec h_p_Gy_Process_BeforeUnCheckCtrl " + HInterID + ",'" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_Process_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;
                        oCN.RollBack();
                        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;
                        oCN.RollBack();
                        return objJsonResult;
                    }
                    //==================================================================================
                    oCN.RunProc("update Gy_Process set HCheckEmp='',HCheckTime=null where HItemID=" + HInterID);
                    //反审核后控制=========================================
                    string sql2 = "exec h_p_Gy_Process_AfterUnCheckCtrl " + HInterID + ",'" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql2, "h_p_Gy_Process_AfterCheckCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反审核失败!原因:反审核后判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        oCN.RollBack();
                        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;
                        oCN.RollBack();
                        return objJsonResult;
                    }
                    //==================================================================================
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
@@ -1215,7 +1591,58 @@
                if (IsStop == 0)  //禁用判断
                {
                    //禁用前控制=========================================
                    string sql1 = "exec h_p_Gy_Process_BeforeStopCtrl " + HInterID + ",'" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_Process_BeforeStopCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "禁用失败!原因:禁用前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        oCN.RollBack();
                        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;
                        oCN.RollBack();
                        return objJsonResult;
                    }
                    //==================================================================================
                    oCN.RunProc("update Gy_Process set HStopEmp='" + CurUserName + "',HStopTime=getdate(),HStopflag=1 where HItemID=" + HInterID);
                    //禁用后控制=========================================
                    string sql2 = "exec h_p_Gy_Process_AfterStopCtrl " + HInterID + ",'" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql2, "h_p_Gy_Process_AfterStopCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "禁用失败!原因:禁用后判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        oCN.RollBack();
                        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;
                        oCN.RollBack();
                        return objJsonResult;
                    }
                    //==================================================================================
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
@@ -1224,8 +1651,60 @@
                }
                if (IsStop == 1) //反禁用判断
                {
                    //反禁用前控制=========================================
                    string sql1 = "exec h_p_Gy_Process_BeforeUnStopCtrl " + HInterID + ",'" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_Process_BeforeUnStopCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反禁用失败!原因:反禁用前判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        oCN.RollBack();
                        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;
                        oCN.RollBack();
                        return objJsonResult;
                    }
                    //==================================================================================
                    oCN.RunProc("update Gy_Process set HStopEmp='',HStopTime=null,HStopflag=0 where HItemID=" + HInterID);
                    //反禁用后控制=========================================
                    string sql2 = "exec h_p_Gy_Process_AfterUnStopCtrl " + HInterID + ",'" + CurUserName + "'";
                    ds = oCN.RunProcReturn(sql2, "h_p_Gy_Process_AfterUnStopCtrl");
                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反禁用失败!原因:反禁用后判断失败,请与网络管理人员联系";
                        objJsonResult.data = null;
                        oCN.RollBack();
                        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;
                        oCN.RollBack();
                        return objJsonResult;
                    }
                    //==================================================================================
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "反禁用成功";