using DBUtility; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; using WebAPI.Models; using System.Web; //using WebAPI.Controllers.SCGL.日计划管理; using System.IO; namespace WebAPI.Controllers.基础资料.基础资料 { public class Gy_PNLInfoTypeLevelController : ApiController { public DBUtility.ClsPub.Enum_BillStatus BillStatus; private json objJsonResult = new json(); SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); DataSet ds; Models.ClsGy_DotCheck oDept = new Models.ClsGy_DotCheck(); Models.ClsGy_DotCheck oDeptHlp = new Models.ClsGy_DotCheck(); #region 层级列表数据 [Route("Gy_PNLInfoTypeLevelController/GetPNLInfoTypeLevel")] [HttpGet] public object GetPNLInfoTypeLevel(string sWhere, string user) { try { List columnNameList = new List(); if (!DBUtility.ClsPub.Security_Log("Gy_PNLInfoTypeLevel", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有查看权限"; objJsonResult.data = null; return objJsonResult; } ds = oCN.RunProcReturn("select * from h_v_Gy_PNLInfoTypeSub where 1=1 " + sWhere + " order by 层级代码", "h_v_Gy_PNLInfoTypeSub"); //添加列名 foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 } //if (ds.Tables[0].Rows.Count != 0 || ds != null) //{ objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = columnNameList; return objJsonResult; //} //else //{ //objJsonResult.code = "0"; //objJsonResult.count = 0; //objJsonResult.Message = "无数据"; //objJsonResult.data = null; //return objJsonResult; //} } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 层级项目删除 [Route("Gy_PNLInfoTypeLevelController/DeleteType")] [HttpGet] public object DeleteType(long HInterID, string User) { try { if (!DBUtility.ClsPub.Security_Log("Gy_PNLInfoTypeLevel_Delete", 1, false, User)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有删除权限"; objJsonResult.data = null; return objJsonResult; } ds = oCN.RunProcReturn("Select * from Gy_PNLInfoTypeSub Where HInterID='" + HInterID + "'", "Gy_PNLInfoTypeSub", ref DBUtility.ClsPub.sExeReturnInfo); if (ds.Tables[0].Rows.Count != 0) { oCN.BeginTran(); //删除前控制========================================= //ds = oCN.RunProcReturn("Exec h_p_Gy_DotCheck_BeforeDelCtrl " + HInterID + ",'" + User + "'", "h_p_Gy_DotCheck_BeforeDelCtrl"); //if (ds == null) //{ // oCN.RollBack(); // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "删除前判断失败!"; // objJsonResult.data = null; // return objJsonResult; //} //if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") //{ // oCN.RollBack(); // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "删除失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); // objJsonResult.data = null; // return objJsonResult; //} //========================================================= ds = oCN.RunProcReturn("Delete from Gy_PNLInfoTypeSub Where HInterID='" + HInterID + "'", "Gy_PNLInfoTypeSub", ref DBUtility.ClsPub.sExeReturnInfo); //删除后控制========================================= //DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_DotCheck_AfterDelCtrl " + HInterID + ",'" + User + "'", "h_p_Gy_DotCheck_AfterDelCtrl"); //if (ds2 == null) //{ // oCN.RollBack(); // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "删除后判断失败!"; // objJsonResult.data = null; // return objJsonResult; //} //if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0") //{ // oCN.RollBack(); // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "删除失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); // objJsonResult.data = null; // return objJsonResult; //} //========================================================= oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "删除成功"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据不存在"; objJsonResult.data = null; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 修改层级获取绑定数据 [Route("Gy_PNLInfoTypeLevelController/EditType")] [HttpGet] public object EditType(long HInterID) { try { ds = oCN.RunProcReturn("select * from Gy_PNLInfoTypeSub where HInterID=" + HInterID, "Gy_PNLInfoTypeSub"); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = ""; objJsonResult.data = ds.Tables[0]; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 点检项目修改保存 [Route("Gy_PNLInfoTypeLevelController/EditBill")] [HttpPost] public object EditBill([FromBody] JObject msg) { try { var _value = msg["msg"].ToString(); string msg3 = _value.ToString(); //string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); //string msg1 = sArray[0].ToString(); //string msg2 = sArray[1].ToString(); string msg2 = msg3.ToString(); //反序列化 msg2 = "[" + msg2.ToString() + "]"; List list = Newtonsoft.Json.JsonConvert.DeserializeObject>(msg2); int HNumber = list[0].HInterID; int HEntryID = list[0].HEntryID; string HPageIndex = list[0].HPageIndex; string HColorStr = list[0].HColorStr; string HLayerNo = list[0].HLayerNo; //判断权限 //if (!ClsPub.Security_Log("Gy_DotCheck_Edit", 1, false, msg3)) //{ // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "没有找到该功能模块!"; // objJsonResult.data = null; // return objJsonResult; //} //若MAINDI重复则重新获取 oCN.BeginTran(); ////保存前控制========================================= //DataSet ds = oCN.RunProcReturn("Exec h_p_Gy_DotCheck_BeforeSaveCtrl " + msg3 + ",'1'", "h_p_Gy_DotCheck_BeforeSaveCtrl"); //if (ds == null) //{ // oCN.RollBack(); // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存前判断失败!"; // objJsonResult.data = null; // return objJsonResult; //} //if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") //{ // oCN.RollBack(); // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); // objJsonResult.data = null; // return objJsonResult; //} //========================================================= //主表 oCN.RunProc("Update Gy_PNLInfoTypeSub set " + "HPageIndex='" + HPageIndex + "'" + ", HColorStr='" + HColorStr + "'" + ", HLayerNo='" + HLayerNo + "'" + " Where HInterID='" + HNumber + "'", ref DBUtility.ClsPub.sExeReturnInfo); //修改子项目代码 //oCN.RunProc("exec h_p_Gy_UpdateNumber Gy_RepairCheck,'" + HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo); //保存后控制========================================= //DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_DotCheck_AfterSaveCtrl " + msg3 + ",'1'", "h_p_Gy_DotCheck_AfterSaveCtrl"); //if (ds2 == null) //{ // oCN.RollBack(); // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存后判断失败!"; // objJsonResult.data = null; // return objJsonResult; //} //if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0") //{ // oCN.RollBack(); // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]); // objJsonResult.data = null; // return objJsonResult; //} //========================================================= oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "修改成功!"; //objJsonResult.data = null; return objJsonResult; } catch (Exception e) { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.Message; objJsonResult.data = null; return objJsonResult; } } #endregion #region 层级项目新增保存 [Route("Gy_PNLInfoTypeLevelController/AddBill")] [HttpPost] public object AddBill([FromBody] JObject msg) { try { var _value = msg["msg"].ToString(); string msg3 = _value.ToString(); //string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); //string msg1 = sArray[0].ToString(); //string msg2 = sArray[1].ToString(); string msg2 = msg3.ToString(); //反序列化 msg2 = "[" + msg2.ToString() + "]"; List list = Newtonsoft.Json.JsonConvert.DeserializeObject>(msg2); int HNumber = list[0].HInterID; int HEntryID = list[0].HEntryID; string HPageIndex = list[0].HPageIndex; string HColorStr = list[0].HColorStr; string HLayerNo = list[0].HLayerNo; //判断权限 //if (!ClsPub.Security_Log("Gy_DotCheck_Edit", 1, false, msg3)) //{ // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "没有找到该功能模块!"; // objJsonResult.data = null; // return objJsonResult; //} //若MAINDI重复则重新获取 oCN.BeginTran(); //保存前控制========================================= //DataSet ds = oCN.RunProcReturn("Exec h_p_Gy_DotCheck_BeforeSaveCtrl " + msg3 + ",'1'", "h_p_Gy_DotCheck_BeforeSaveCtrl"); //if (ds == null) //{ // oCN.RollBack(); // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存前判断失败!"; // objJsonResult.data = null; // return objJsonResult; //} //if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") //{ // oCN.RollBack(); // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); // objJsonResult.data = null; // return objJsonResult; //} //========================================================= //主表 oCN.RunProc("Insert into Gy_PNLInfoTypeSub " + " (HInterID,HEntryID,HPageIndex,HColorStr,HLayerNo" + " ) " + " Values(" + HNumber + "," + HEntryID + ",'" + HPageIndex + "','" + HColorStr + "','" + HLayerNo + "')", ref DBUtility.ClsPub.sExeReturnInfo); //修改上级为非末级代码 //oCN.RunProc("Update Gy_MouldType set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo); //保存后控制========================================= //DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_DotCheck_AfterSaveCtrl " + msg3 + ",'1'", "h_p_Gy_DotCheck_AfterSaveCtrl"); //if (ds2 == null) //{ // oCN.RollBack(); // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存后判断失败!"; // objJsonResult.data = null; // return objJsonResult; //} //if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0") //{ // oCN.RollBack(); // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]); // objJsonResult.data = null; // return objJsonResult; //} //========================================================= oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "新增成功!"; //objJsonResult.data = null; return objJsonResult; } catch (Exception e) { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.Message; objJsonResult.data = null; return objJsonResult; } } #endregion #region 层级列表 树状图 点击分类查询 public class TreeModel { public string id { get; set; } public string title { get; set; } public List children = new List(); } [Route("Gy_PNLInfoTypeLevelController/TreeGetList")] [HttpGet] public object TreeGetList(string sWhere, string user) { try { ds = oCN.RunProcReturn("select HInterID,HName from Gy_PNLInfoType", "Gy_PNLInfoType"); List treeModels = new List(); TreeModel first = new TreeModel(); first.id = "0"; first.title = "层级项目分类设置"; treeModels.Add(first); foreach (DataRow row in ds.Tables[0].Rows) { var strLen = row["HInterID"].ToString().Split('.'); if (strLen.Length == 1) { TreeModel tree = new TreeModel(); tree.id = row["HInterID"].ToString(); tree.title = row["HName"].ToString(); treeModels[0].children.Add(tree); } } //digui(ds.Tables[0], treeModels[0].children, 2); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = Newtonsoft.Json.JsonConvert.SerializeObject(treeModels); return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion //#region 点检项目文件上传 //[Route("Gy_DotCheck/Gy_DotCheck_Excel")] //[HttpPost] //public object Gy_DotCheck_Excel() //{ // try // { // //获取文件名称 // var file = HttpContext.Current.Request.Files[0]; // //获取文件物理路径 // string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); // //保存文件 // file.SaveAs(ExcelPath); // NpoiHelper np = new NpoiHelper(); // DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); // //删除文件 // File.Delete(ExcelPath); // //创建临时表 // DataTable tb2 = new DataTable("dt2"); // //添加列名 // for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) // { // tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); // } // //模板缺少列 但需要从数据库中查询出来显示在页面的字段 // tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID // tb2.Columns.Add("HDotCheckItemClassID", typeof(Int32));//点检项目分类ID // //添加数据 // for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) // { // DataRow row = tb2.NewRow(); // for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) // { // row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); // } // tb2.Rows.Add(row); // } // var error = ""; // //查询工作中心没有的列 // if (!tb2.Columns.Contains("组织代码")) // error += "没有找到【组织代码】的标题,"; // if (!tb2.Columns.Contains("组织名称")) // error += "没有找到【组织名称】的标题,"; // if (!tb2.Columns.Contains("点检项目代码")) // error += "没有找到【点检项目代码】的标题,"; // if (!tb2.Columns.Contains("点检项目名称")) // error += "没有找到【点检项目名称】的标题,"; // if (!tb2.Columns.Contains("点检项目分类代码")) // error += "没有找到【点检项目分类代码】的标题,"; // if (!tb2.Columns.Contains("点检项目分类名称")) // error += "没有找到【点检项目分类名称】的标题,"; // if (error.Length > 0) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = $"Excel模板存在错误,{error}\r\n"; // objJsonResult.data = null; // return objJsonResult; // } // for (int i = 0; i <= tb2.Rows.Count - 1; i++) // { // string HORGNumber = ""; // string HORGName = ""; // string HDotCheckNum = ""; // string HDotCheckName = ""; // string HDotCheckItemClassNum = ""; // string HDotCheckItemClassName = ""; // HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString()); // HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString()); // HDotCheckNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["点检项目代码"].ToString()); // HDotCheckName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["点检项目名称"].ToString()); // HDotCheckItemClassNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["点检项目分类代码"].ToString()); // HDotCheckItemClassName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["点检项目分类名称"].ToString()); // //检查组织 // int index = i + 1; // if (HORGNumber != "") // { // //查询组织 // ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); // if (ds.Tables[0].Rows.Count == 0) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "第" + index + "行,组织不存在!"; // objJsonResult.data = null; // return objJsonResult; // } // else // { // tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); // } // string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString(); // //查询点检项目分类 // ds = oCN.RunProcReturn("select * from Gy_DotCheckItemClass where HNumber='" + HDotCheckItemClassNum + "' and HUSEORGID=" + HORGid + "", "Gy_Department"); // if (ds.Tables[0].Rows.Count == 0) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "第" + index + "行,该" + HORGName + "组织,点检项目分类:" + HDotCheckItemClassName + ",不存在!"; // objJsonResult.data = null; // return objJsonResult; // } // else // { // tb2.Rows[i]["HDotCheckItemClassID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); // } // //点检项目名称 // if (HDotCheckName == "") // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "第" + index + "行,点检项目名称不能为空!"; // objJsonResult.data = null; // return objJsonResult; // } // //点检项目代码 // if (HDotCheckNum == "") // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "第" + index + "行,点检项目代码不能为空!"; // objJsonResult.data = null; // return objJsonResult; // } // } // else // { // objJsonResult.code = "1"; // objJsonResult.count = 1; // objJsonResult.Message = "第" + index + "行,组织代码为空"; // objJsonResult.data = null; // return objJsonResult; // } // } // objJsonResult.code = "1"; // objJsonResult.count = 1; // objJsonResult.Message = error; // objJsonResult.data = tb2; // return objJsonResult; // } // catch (Exception e) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "Exception!" + e.ToString(); // objJsonResult.data = null; // return objJsonResult; // } //} //#endregion #region 点检项目 导入(保存) [Route("Gy_DotCheck/Gy_DotCheck_btnSave")] [HttpPost] public object Gy_DotCheck_btnSave([FromBody] JObject sMainSub) { var _value = sMainSub["sMainSub"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); string user = sArray[1].ToString(); try { if (!DBUtility.ClsPub.Security_Log("Gy_DotCheck_Edit", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无保存权限!"; objJsonResult.data = null; return objJsonResult; } List Excel = Newtonsoft.Json.JsonConvert.DeserializeObject>(msg2); List> list = new List>(); foreach (JObject item in Excel) { Dictionary dic = new Dictionary(); foreach (var itm in item.Properties()) { dic.Add(itm.Name, itm.Value.ToString()); } list.Add(dic); } oCN.BeginTran(); int i = 1; foreach (Dictionary item in list) { string HOrgID = item["HOrgID"].ToString();//组织ID string HDotCheckItemClassID = item["HDotCheckItemClassID"].ToString();//点检项目分类ID string HDotCheckItemClassName = item["点检项目分类代码"].ToString(); string HDotCheckItemClassNum = item["点检项目分类名称"].ToString(); string HDotCheckName = item["点检项目名称"].ToString(); string HDotCheckNum = item["点检项目代码"].ToString(); string sShortNumber; sShortNumber = DBUtility.ClsPub.GetShortNumber(HDotCheckNum);//短代码 if (sShortNumber.Trim() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!短代码为空!"; objJsonResult.data = 1; return objJsonResult; } int HEndFlag = 1;//末级标志 int HLevel = DBUtility.ClsPub.GetLevel(HDotCheckNum); //等级 if (!DBUtility.ClsPub.AllowNumber(HDotCheckNum.Trim())) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; objJsonResult.data = 1; return objJsonResult; } ds = oCN.RunProcReturn("select * from Gy_DotCheck where HNumber='" + HDotCheckNum + "'", "Gy_DotCheck"); if (ds.Tables[0].Rows.Count == 0) { string sql = "insert into Gy_DotCheck(HName,HNumber,HDotCheckItemClassID,HUSEORGID,HCREATEORGID,HShortNumber,HEndFlag,HLevel,HParentID,HStopflag,HRemark,HHelpCode)" + $"values('{HDotCheckName}', '{HDotCheckNum}',{HDotCheckItemClassID}, {HOrgID},{HOrgID}, '{sShortNumber}', {HEndFlag},{HLevel},0,0,'','')"; oCN.RunProc(sql); } else { oCN.RunProc(" update Gy_DotCheck set HDotCheckItemClassID=" + HDotCheckItemClassID + " where HNumber='" + HDotCheckNum + "'"); } i++; } oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "导入成功!"; objJsonResult.data = null; return objJsonResult; } catch (Exception e) { LogService.Write(e); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 点检项目审核、反审核 /// /// /// /// 单据ID /// 审核(0),反审核(1) /// 审核人 /// [Route("Gy_PNLInfoTypeLevelController/AuditGy_DotCheck")] [HttpGet] public object AuditGy_DotCheck(int HInterID, int IsAudit, string CurUserName) { try { //审核权限 if (!DBUtility.ClsPub.Security_Log_second("Gy_PNLInfoTypeLevel_Check", 1, false, CurUserName)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "审核失败!无权限!"; objJsonResult.data = null; return objJsonResult; } var ds = oCN.RunProcReturn("select * from Gy_PNLInfoType where HItemID=" + HInterID, "Gy_PNLInfoTypeSub "); if (ds.Tables[0].Rows.Count > 0) { if (IsAudit == 0) //审核判断 { if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已审核!不能再次审核!"; objJsonResult.data = null; return objJsonResult; } } if (IsAudit == 1) //反审核判断 { if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未审核!不需要反审核!"; objJsonResult.data = null; return objJsonResult; } } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据不存在!"; objJsonResult.data = null; return objJsonResult; } oCN.BeginTran(); if (IsAudit == 0) //审核判断 { //审核前控制========================================= ds = oCN.RunProcReturn("Exec h_p_Gy_PNLInfoType_BeforeCheckCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Gy_PNLInfoType_BeforeCheckCtrl"); if (ds == null) { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "审核前判断失败!"; objJsonResult.data = null; return objJsonResult; } if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); objJsonResult.data = null; return objJsonResult; } //========================================================= oCN.RunProc("update Gy_PNLInfoType set HCheckEmp='" + CurUserName + "',HCheckTime=getdate() where HInterID=" + HInterID); //审核后控制========================================= DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_PNLInfoType_AfterCheckCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Gy_PNLInfoType_AfterCheckCtrl"); if (ds2 == null) { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "审核后判断失败!"; objJsonResult.data = null; return objJsonResult; } if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0") { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); objJsonResult.data = null; return objJsonResult; } //========================================================= objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "审核成功"; objJsonResult.data = null; } if (IsAudit == 1) //反审核判断 { //反审核前控制========================================= ds = oCN.RunProcReturn("Exec h_p_Gy_PNLInfoType_BeforeUnCheckCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Gy_PNLInfoType_BeforeUnCheckCtrl"); if (ds == null) { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "审核前判断失败!"; objJsonResult.data = null; return objJsonResult; } if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); objJsonResult.data = null; return objJsonResult; } //========================================================= oCN.RunProc("update Gy_PNLInfoType set HCheckEmp='',HCheckTime=null where HInterID=" + HInterID); //反审核后控制========================================= DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_PNLInfoType_AfterUnCheckCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Gy_PNLInfoType_AfterUnCheckCtrl"); if (ds2 == null) { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "审核后判断失败!"; objJsonResult.data = null; return objJsonResult; } if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0") { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); objJsonResult.data = null; return objJsonResult; } //========================================================= objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "反审核成功"; objJsonResult.data = null; } oCN.Commit(); return objJsonResult; } catch (Exception e) { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 点检项目禁用、反禁用 /// /// /// /// 单据ID /// 禁用(0),反禁用(1) /// 审核人 /// [Route("Gy_PNLInfoTypeLevelController/StopGy_DotCheck")] [HttpGet] public object StopGy_DotCheck(int HInterID, int IsStop, string CurUserName) { try { //禁用权限 if (!DBUtility.ClsPub.Security_Log_second("Gy_PNLInfoTypeLevel_Stop", 1, false, CurUserName)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "禁用失败!无权限!"; objJsonResult.data = null; return objJsonResult; } var ds = oCN.RunProcReturn("select * from Gy_PNLInfoType where HInterID=" + HInterID, "Gy_PNLInfoType"); if (ds.Tables[0].Rows.Count > 0) { if (IsStop == 0) //禁用判断 { if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已禁用!不能再次禁用!"; objJsonResult.data = null; return objJsonResult; } } if (IsStop == 1) //反禁用判断 { if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未禁用!不需要反禁用!"; objJsonResult.data = null; return objJsonResult; } } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据不存在!"; objJsonResult.data = null; return objJsonResult; } oCN.BeginTran(); if (IsStop == 0) //禁用判断 { //禁用前控制========================================= ds = oCN.RunProcReturn("Exec h_p_Gy_PNLInfoType_BeforeStopCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Gy_PNLInfoType_BeforeStopCtrl"); if (ds == null) { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "禁用前判断失败!"; objJsonResult.data = null; return objJsonResult; } if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "禁用失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); objJsonResult.data = null; return objJsonResult; } //========================================================= oCN.RunProc("update Gy_PNLInfoType set HStopEmp='" + CurUserName + "',HStopTime=getdate() where HInterID=" + HInterID); //禁用后控制========================================= DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_PNLInfoType_AFTERStopCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Gy_PNLInfoType_AFTERStopCtrl"); if (ds2 == null) { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "禁用后判断失败!"; objJsonResult.data = null; return objJsonResult; } if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0") { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "禁用失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); objJsonResult.data = null; return objJsonResult; } //========================================================= objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "禁用成功"; objJsonResult.data = null; } if (IsStop == 1) //反禁用判断 { //反禁用前控制========================================= ds = oCN.RunProcReturn("Exec h_p_Gy_PNLInfoType_BeforeUnStopCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Gy_PNLInfoType_BeforeUnStopCtrl"); if (ds == null) { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "禁用前判断失败!"; objJsonResult.data = null; return objJsonResult; } if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "禁用失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); objJsonResult.data = null; return objJsonResult; } //========================================================= oCN.RunProc("update Gy_PNLInfoType set HStopEmp='',HStopTime=null where HInterID=" + HInterID); //反禁用后控制========================================= DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_PNLInfoType_AfterUnStop " + HInterID + ",'" + CurUserName + "'", "h_p_Gy_PNLInfoType_AfterUnStop"); if (ds2 == null) { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "禁用后判断失败!"; objJsonResult.data = null; return objJsonResult; } if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0") { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "禁用失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); objJsonResult.data = null; return objJsonResult; } //========================================================= objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "反禁用成功"; objJsonResult.data = null; } oCN.Commit(); return objJsonResult; } catch (Exception e) { oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "禁用失败或者反禁用失败!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion } }