| using System; | 
| using System.Collections.Generic; | 
| using Newtonsoft.Json; | 
| using Newtonsoft.Json.Linq; | 
| using System.Linq; | 
| using System.Net; | 
| using System.Net.Http; | 
| using System.Web.Http; | 
| using WebAPI.Models; | 
| using System.Data; | 
| using SyntacticSugar.constant; | 
| using DBUtility; | 
| using System.Text; | 
|   | 
| namespace WebAPI.Controllers.基础资料.基础资料 | 
| { | 
|     public class QC_CheckNote_PNL_TempController : ApiController | 
|     { | 
|   | 
|         private json objJsonResult = new json(); | 
|         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|         DataSet ds; | 
|   | 
|         #region 获取QC_CheckNote_PNL_Temp列表 | 
|         [Route("QC_CheckNote_PNL_TempController/GetQC_CheckNote_PNL_TempList")] | 
|         [HttpGet] | 
|         public object GetQC_CheckNote_PNL_TempList(string sWhere, string user) | 
|         { | 
|             try | 
|             { | 
|                 List<object> columnNameList = new List<object>(); | 
|                 if (!DBUtility.ClsPub.Security_Log("QC_CheckNote_PNL_Temp_Query", 1, false, user)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "没有查看权限"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 DataSet ds = oCN.RunProcReturn("select * from h_v_QC_CheckNote_PNL_Temp_List where 1=1 " + sWhere + " order by HItemID", "h_v_QC_CheckNote_PNL_Temp_List"); | 
|   | 
|                 //添加列名 | 
|                 foreach (DataColumn col in ds.Tables[0].Columns) | 
|                 { | 
|                     Type dataType = col.DataType; | 
|                     string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; | 
|                     columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 | 
|                 } | 
|   | 
|                 objJsonResult.code = "1"; | 
|                 objJsonResult.count = 1; | 
|                 objJsonResult.Message = "Sucess!"; | 
|                 objJsonResult.data = ds.Tables[0]; | 
|                 objJsonResult.list = columnNameList; | 
|                 return objJsonResult; | 
|   | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = "Exception!" + e.ToString(); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|         } | 
|         #endregion | 
|   | 
|         #region 获取QC_CheckNote_PNL_Temp列表 分页 | 
|         [Route("QC_CheckNote_PNL_TempController/GetQC_CheckNote_PNL_TempListPage")] | 
|         [HttpGet] | 
|         public object GetQC_CheckNote_PNL_TempListPage(string sWhere, string user, string page, string size) | 
|         { | 
|             try | 
|             { | 
|                 List<object> columnNameList = new List<object>(); | 
|                 if (!DBUtility.ClsPub.Security_Log("QC_CheckNote_PNL_Temp_Query", 1, false, user)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "没有查看权限"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|                 if (string.IsNullOrWhiteSpace(sWhere) == false) | 
|                 { | 
|                     sWhere = sWhere.Replace("'", "''"); | 
|                 } | 
|   | 
|                 string sql = "exec h_p_QC_CheckNote_PNL_Temp_ListPage " + page + "," + size + ",'" + sWhere + "'"; | 
|   | 
|                 DataSet ds = oCN.RunProcReturn(sql, "h_p_QC_CheckNote_PNL_Temp_ListPage"); | 
|   | 
|                 //添加列名 | 
|                 foreach (DataColumn col in ds.Tables[0].Columns) | 
|                 { | 
|                     Type dataType = col.DataType; | 
|                     string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; | 
|                     columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 | 
|                 } | 
|   | 
|                 objJsonResult.code = CodeConstant.SUCCEED; | 
|                 objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); | 
|                 objJsonResult.Message = "Sucess!"; | 
|                 objJsonResult.data = ds.Tables[0]; | 
|                 objJsonResult.list = columnNameList; | 
|                 return objJsonResult; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 objJsonResult.code = CodeConstant.FAIL; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = "没有返回任何记录!" + e.ToString(); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|         } | 
|         #endregion | 
|   | 
|         #region 添加QC_CheckNote_PNL_Temp | 
|         [Route("QC_CheckNote_PNL_TempController/AddBill")] | 
|         [HttpPost] | 
|         public object AddBill([FromBody] JObject oMain) | 
|         { | 
|             try | 
|             { | 
|                 var _value = oMain["oMain"].ToString(); | 
|                 string msg1 = _value.ToString(); | 
|                 string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
|                 string msg2 = sArray[0].ToString(); | 
|                 string msg3 = sArray[1].ToString();//当前人 | 
|   | 
|                 //反序列化 | 
|                 msg2 = "[" + msg2.ToString() + "]"; | 
|                 List<Models.ClsQC_CheckNote_PNL_Temp> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.ClsQC_CheckNote_PNL_Temp>>(msg2); | 
|   | 
|                 int HItemID = list[0].HItemID; | 
|                 string HBarCode = list[0].HBarCode; | 
|                 string HSetNo = list[0].HSetNo; | 
|                 string HPCSNo = list[0].HPCSNo; | 
|                 int HPosition_x = list[0].HPosition_x; | 
|                 int HPosition_y = list[0].HPosition_y; | 
|                 string HCheckProc = list[0].HCheckProc; | 
|                 string HPageIndex = list[0].HPageIndex; | 
|                 string HBadReason = list[0].HBadReason; | 
|                 string HMaker = list[0].HMaker; | 
|                 DateTime HMakeDate = list[0].HMakeDate; | 
|   | 
|                 //判断权限 | 
|                 if (!ClsPub.Security_Log("QC_CheckNote_PNL_Temp_Edit", 1, false, msg3)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "没有修改权限!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 oCN.BeginTran(); | 
|                 DataSet ds_editCheck; | 
|                 //保存前控制========================================= | 
|                 ds_editCheck = oCN.RunProcReturn("Exec h_p_QC_CheckNote_PNL_Temp_BeforeSaveCtrl " + msg3 + ",'1'", "h_p_QC_CheckNote_PNL_Temp_BeforeSaveCtrl"); | 
|                 if (ds_editCheck == null) | 
|                 { | 
|                     oCN.RollBack(); | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "保存前判断失败!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|                 if (DBUtility.ClsPub.isStrNull(ds_editCheck.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; | 
|                 } | 
|                 //========================================================= | 
|   | 
|                 //DataSet ds_exits = oCN.RunProcReturn("select HBarCode from QC_CheckNote_PNL_Temp where HSetNo = N'" + HSetNo + "'" + | 
|                 //    "AND HPCSNo = N'" + HPCSNo + "'", "QC_CheckNote_PNL_Temp"); | 
|                 //if (ds_exits.Tables[0].Rows.Count > 0) | 
|                 //{ | 
|                 //    objJsonResult.code = "0"; | 
|                 //    objJsonResult.count = 0; | 
|                 //    objJsonResult.Message = "SET编号或PCS编号已存在!"; | 
|                 //    objJsonResult.data = null; | 
|                 //    return objJsonResult; | 
|                 //} | 
|   | 
|                 StringBuilder sb = new StringBuilder(); | 
|                 sb.Append("Insert Into QC_CheckNote_PNL_Temp(HBarCode, HSetNo, HPCSNo, HPosition_x,HPosition_y,HCheckProc,HPageIndex ,HBadReason, HMaker, HMakeDate) Values("); | 
|                 sb.Append("N'" + HBarCode + "',"); | 
|                 sb.Append("N'" + HSetNo + "',"); | 
|                 sb.Append("N'" + HPCSNo + "',"); | 
|                 sb.Append("N'" + HPosition_x + "',"); | 
|                 sb.Append("N'" + HPosition_y + "',"); | 
|                 sb.Append("N'" + HCheckProc + "',"); | 
|                 sb.Append("N'" + HPageIndex + "',"); | 
|                 sb.Append("N'" + HBadReason + "',"); | 
|                 sb.Append("N'" + HMaker + "',"); | 
|                 sb.Append("N'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')"); | 
|   | 
|                 string sql = sb.ToString(); | 
|                 sb.Clear(); | 
|   | 
|                 ds = oCN.RunProcReturn(sql, "QC_CheckNote_PNL_Temp"); | 
|   | 
|                 //保存后控制========================================= | 
|                 ds_editCheck = oCN.RunProcReturn("Exec h_p_QC_CheckNote_PNL_Temp_AfterSaveCtrl " + msg3 + ",'1'", "h_p_QC_CheckNote_PNL_Temp_AfterSaveCtrl"); | 
|                 if (ds_editCheck == null) | 
|                 { | 
|                     oCN.RollBack(); | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "保存后判断失败!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|   | 
|                 } | 
|                 if (DBUtility.ClsPub.isStrNull(ds_editCheck.Tables[0].Rows[0]["HBack"]) != "0") | 
|                 { | 
|                     oCN.RollBack(); | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "" + DBUtility.ClsPub.isStrNull(ds_editCheck.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 批量添加QC_CheckNote_PNL_Temp | 
|         [Route("QC_CheckNote_PNL_TempController/BatchAddBill")] | 
|         [HttpPost] | 
|         public object BatchAddBill([FromBody] JObject oMain) | 
|         { | 
|             try | 
|             { | 
|                 var _value = oMain["oMain"].ToString(); | 
|                 string msg1 = _value.ToString(); | 
|                 string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
|                 string msg2 = sArray[0].ToString(); | 
|                 string msg3 = sArray[1].ToString();//当前人 | 
|   | 
|                 //判断权限 | 
|                 if (!ClsPub.Security_Log("QC_CheckNote_PNL_Temp_Edit", 1, false, msg3)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "没有修改权限!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 //反序列化 | 
|                 //msg2 = "[" + msg2.ToString() + "]"; | 
|                 List<Models.ClsQC_CheckNote_PNL_Temp> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.ClsQC_CheckNote_PNL_Temp>>(msg2); | 
|   | 
|                 oCN.BeginTran(); | 
|                 for (int i = 0; i < list.Count; i++) | 
|                 { | 
|                     int HItemID = list[i].HItemID; | 
|                     string HBarCode = list[i].HBarCode; | 
|                     string HSetNo = list[i].HSetNo; | 
|                     string HPCSNo = list[i].HPCSNo; | 
|                     int HPosition_x = list[i].HPosition_x; | 
|                     int HPosition_y = list[i].HPosition_y; | 
|                     string HCheckProc = list[i].HCheckProc; | 
|                     string HPageIndex = list[i].HPageIndex; | 
|                     string HBadReason = list[i].HBadReason; | 
|                     string HMaker = list[i].HMaker; | 
|                     DateTime HMakeDate = list[i].HMakeDate; | 
|   | 
|                     DataSet ds_editCheck; | 
|                     //保存前控制========================================= | 
|                     ds_editCheck = oCN.RunProcReturn("Exec h_p_QC_CheckNote_PNL_Temp_BeforeSaveCtrl " + msg3 + ",'1'", "h_p_QC_CheckNote_PNL_Temp_BeforeSaveCtrl"); | 
|                     if (ds_editCheck == null) | 
|                     { | 
|                         oCN.RollBack(); | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "保存前判断失败!"; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     if (DBUtility.ClsPub.isStrNull(ds_editCheck.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; | 
|                     } | 
|                     //========================================================= | 
|   | 
|                     StringBuilder sb = new StringBuilder(); | 
|                     sb.Append("Insert Into QC_CheckNote_PNL_Temp(HBarCode, HSetNo, HPCSNo, HPosition_x,HPosition_y,HCheckProc,HPageIndex ,HBadReason, HMaker, HMakeDate) Values("); | 
|                     sb.Append("N'" + HBarCode + "',"); | 
|                     sb.Append("N'" + HSetNo + "',"); | 
|                     sb.Append("N'" + HPCSNo + "',"); | 
|                     sb.Append("N'" + HPosition_x + "',"); | 
|                     sb.Append("N'" + HPosition_y + "',"); | 
|                     sb.Append("N'" + HCheckProc + "',"); | 
|                     sb.Append("N'" + HPageIndex + "',"); | 
|                     sb.Append("N'" + HBadReason + "',"); | 
|                     sb.Append("N'" + HMaker + "',"); | 
|                     sb.Append("N'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "')"); | 
|                     string sql = sb.ToString(); | 
|                     sb.Clear(); | 
|                     ds = oCN.RunProcReturn(sql, "QC_CheckNote_PNL_Temp"); | 
|   | 
|                     //保存后控制========================================= | 
|                     ds_editCheck = oCN.RunProcReturn("Exec h_p_QC_CheckNote_PNL_Temp_AfterSaveCtrl " + msg3 + ",'1'", "h_p_QC_CheckNote_PNL_Temp_AfterSaveCtrl"); | 
|                     if (ds_editCheck == null) | 
|                     { | 
|                         oCN.RollBack(); | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "保存后判断失败!"; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|   | 
|                     } | 
|                     if (DBUtility.ClsPub.isStrNull(ds_editCheck.Tables[0].Rows[0]["HBack"]) != "0") | 
|                     { | 
|                         oCN.RollBack(); | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "" + DBUtility.ClsPub.isStrNull(ds_editCheck.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 删除QC_CheckNote_PNL_Temp | 
|         [Route("QC_CheckNote_PNL_TempController/DeleteBill")] | 
|         [HttpGet] | 
|         public object DeleteBill(string HItemID, string user) | 
|         { | 
|             try | 
|             { | 
|                 if (!DBUtility.ClsPub.Security_Log("QC_CheckNote_PNL_Temp_Drop", 1, false, user)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "没有删除权限"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|   | 
|                     DataSet ds_delcheck; | 
|                     oCN.BeginTran(); | 
|                     //删除前控制========================================= | 
|                     ds_delcheck = oCN.RunProcReturn("Exec h_p_QC_CheckNote_PNL_Temp_BeforeDelCtrl " + HItemID + ",'" + User + "'", "h_p_QC_CheckNote_PNL_Temp_BeforeDelCtrl"); | 
|                     if (ds_delcheck == null) | 
|                     { | 
|                         oCN.RollBack(); | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "删除前判断失败!"; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     if (DBUtility.ClsPub.isStrNull(ds_delcheck.Tables[0].Rows[0]["HBack"]) != "0") | 
|                     { | 
|                         oCN.RollBack(); | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "删除失败!" + DBUtility.ClsPub.isStrNull(ds_delcheck.Tables[0].Rows[0]["HBackRemark"]); | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                 //========================================================= | 
|   | 
|   | 
|                 string sql = "delete from QC_CheckNote_PNL_Temp where HItemID =" + HItemID; | 
|                 ds = oCN.RunProcReturn(sql, "QC_CheckNote_PNL_Temp"); | 
|   | 
|                     //删除后控制========================================= | 
|                 ds_delcheck = oCN.RunProcReturn("Exec h_p_QC_CheckNote_PNL_Temp_AfterDelCtrl " + HItemID + ",'" + User + "'", "h_p_QC_CheckNote_PNL_Temp_AfterDelCtrl"); | 
|                     if (ds_delcheck == null) | 
|                     { | 
|                         oCN.RollBack(); | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "删除后判断失败!"; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     if (DBUtility.ClsPub.isStrNull(ds_delcheck.Tables[0].Rows[0]["HBack"]) != "0") | 
|                     { | 
|                         oCN.RollBack(); | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "删除失败!" + DBUtility.ClsPub.isStrNull(ds_delcheck.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) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = "Exception!" + e.ToString(); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|         } | 
|         #endregion | 
|   | 
|         #region 更新QC_CheckNote_PNL_Temp  | 
|         [Route("QC_CheckNote_PNL_TempController/EditBill")] | 
|         [HttpPost] | 
|         public object EditBill([FromBody] JObject oMain) | 
|         { | 
|             try | 
|             { | 
|                 var _value = oMain["oMain"].ToString(); | 
|                 string msg1 = _value.ToString(); | 
|                 string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
|                 string msg2 = sArray[0].ToString(); | 
|                 string msg3 = sArray[1].ToString();//当前人 | 
|   | 
|                 //反序列化 | 
|                 msg2 = "[" + msg2.ToString() + "]"; | 
|                 List<Models.ClsQC_CheckNote_PNL_Temp> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.ClsQC_CheckNote_PNL_Temp>>(msg2); | 
|   | 
|                 int HItemID = list[0].HItemID; | 
|                 string HBarCode = list[0].HBarCode; | 
|                 string HSetNo = list[0].HSetNo; | 
|                 string HPCSNo = list[0].HPCSNo; | 
|                 int HPosition_x = list[0].HPosition_x; | 
|                 int HPosition_y = list[0].HPosition_y; | 
|                 string HCheckProc = list[0].HCheckProc; | 
|                 string HPageIndex = list[0].HPageIndex; | 
|                 string HBadReason = list[0].HBadReason; | 
|                 string HMaker = list[0].HMaker; | 
|                 DateTime HMakeDate = list[0].HMakeDate; | 
|   | 
|                 //判断权限 | 
|                 if (!ClsPub.Security_Log("QC_CheckNote_PNL_Temp_Edit", 1, false, msg3)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "没有修改权限!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|                oCN.BeginTran(); | 
|                 DataSet ds_editCheck; | 
|                 //保存前控制========================================= | 
|                 ds_editCheck = oCN.RunProcReturn("Exec h_p_QC_CheckNote_PNL_Temp_BeforeSaveCtrl " + msg3 + ",'2'", "h_p_QC_CheckNote_PNL_Temp_BeforeSaveCtrl"); | 
|                 if (ds_editCheck == null) | 
|                 { | 
|                     oCN.RollBack(); | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "保存前判断失败!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|                 if (DBUtility.ClsPub.isStrNull(ds_editCheck.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; | 
|                 } | 
|                 //========================================================= | 
|   | 
|                 //DataSet ds_exits = oCN.RunProcReturn("select HBarCode from QC_CheckNote_PNL_Temp where HSetNo = N'" + HSetNo + "'" + | 
|                 //    "AND HPCSNo = N'" + HPCSNo + "' AND HItemID != " + HItemID, "QC_CheckNote_PNL_Temp"); | 
|                 //if (ds_exits.Tables[0].Rows.Count > 0) | 
|                 //{ | 
|                 //    objJsonResult.code = "0"; | 
|                 //    objJsonResult.count = 0; | 
|                 //    objJsonResult.Message = "SET编号或PCS编号已存在!"; | 
|                 //    objJsonResult.data = null; | 
|                 //    return objJsonResult; | 
|                 //} | 
|   | 
|                 StringBuilder sb = new StringBuilder(); | 
|                 sb.Append("Update QC_CheckNote_PNL_Temp set "); | 
|                 sb.Append("HBarCode=N'" + HBarCode + "',"); | 
|                 sb.Append("HSetNo=N'" + HSetNo + "',"); | 
|                 sb.Append("HPCSNo=N'" + HPCSNo + "',"); | 
|                 sb.Append("HPosition_x=N'" + HPosition_x + "',"); | 
|                 sb.Append("HPosition_y=N'" + HPosition_y + "',"); | 
|                 sb.Append("HPageIndex=N'" + HPageIndex + "',"); | 
|                 sb.Append("HCheckProc=N'" + HCheckProc + "',"); | 
|                 sb.Append("HBadReason=N'" + HBadReason + "',"); | 
|                 sb.Append("HMaker=N'" + HMaker + "',"); | 
|                 sb.Append("HMakeDate=N'" + HMakeDate + "',"); | 
|                 sb.Append("HModifyMan=N'" + msg3 + "',"); | 
|                 sb.Append("HModifyDate=getdate()"); | 
|                 sb.Append(" Where HItemID = " + HItemID); | 
|   | 
|                 string sql = sb.ToString(); | 
|                 sb.Clear(); | 
|   | 
|                 //LogService.Write("执行SQL: " + sql); | 
|                 ds = oCN.RunProcReturn(sql, "QC_CheckNote_PNL_Temp"); | 
|   | 
|                 //保存后控制========================================= | 
|                 ds_editCheck = oCN.RunProcReturn("Exec h_p_QC_CheckNote_PNL_Temp_AfterSaveCtrl " + msg3 + ",'2'", "h_p_QC_CheckNote_PNL_Temp_AfterSaveCtrl"); | 
|                 if (ds_editCheck == null) | 
|                 { | 
|                     oCN.RollBack(); | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "保存后判断失败!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|   | 
|                 } | 
|                 if (DBUtility.ClsPub.isStrNull(ds_editCheck.Tables[0].Rows[0]["HBack"]) != "0") | 
|                 { | 
|                     oCN.RollBack(); | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "" + DBUtility.ClsPub.isStrNull(ds_editCheck.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 审核PNL检验信息 | 
|         [Route("QC_CheckNote_PNL_TempController/CheckBill")] | 
|         [HttpGet] | 
|         public object CheckBill(int HInterID, string user, int IsAudit) | 
|         { | 
|             try | 
|             { | 
|                 //审核权限 | 
|                 if (!DBUtility.ClsPub.Security_Log_second("QC_CheckNote_PNL_Temp_Check", 1, false, user)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "审核失败!无权限!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 var ds = oCN.RunProcReturn("select top 1 HCheckMan from QC_CheckNote_PNL_Temp  where HItemID=" + HInterID, "QC_CheckNote_PNL_Temp"); | 
|                 if (ds.Tables[0].Rows.Count > 0) | 
|                 { | 
|                     if (IsAudit == 0)  //审核判断 | 
|                     { | 
|                         if (string.IsNullOrEmpty(ds.Tables[0].Rows[0]["HCheckMan"].ToString()) != true) | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已审核!不能再次审核!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                     } | 
|                     if (IsAudit == 1) //反审核判断 | 
|                     { | 
|                         if (string.IsNullOrEmpty(ds.Tables[0].Rows[0]["HCheckMan"].ToString()) == true) | 
|                         { | 
|                             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_QC_CheckNote_PNL_BeforeCheckCtrl " + HInterID + ",'" + user + "'", "h_p_QC_CheckNote_PNL_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 QC_CheckNote_PNL_Temp set HCheckMan='" + user + "',HCheckDate=getdate() where HItemID=" + HInterID); | 
|   | 
|                     //审核后控制========================================= | 
|                     DataSet ds2 = oCN.RunProcReturn("Exec h_p_QC_CheckNote_PNL_AfterCheckCtrl " + HInterID + ",'" + user + "'", "h_p_QC_CheckNote_PNL_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_QC_CheckNote_PNL_BeforeUnCheckCtrl " + HInterID + ",'" + user + "'", "h_p_QC_CheckNote_PNL_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 QC_CheckNote_PNL_Temp set HCheckMan='',HCheckDate=null where HItemID=" + HInterID); | 
|   | 
|   | 
|                     //反审核后控制========================================= | 
|                     DataSet ds2 = oCN.RunProcReturn("Exec h_p_QC_CheckNote_PNL_AfterUnCheckCtrl " + HInterID + ",'" + user + "'", "h_p_QC_CheckNote_PNL_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 | 
|     } | 
| } |