From 078a38b7fdc48595cac707cbcecbf61e6ffb7d2e Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期五, 14 三月 2025 16:17:41 +0800
Subject: [PATCH] 工艺路线保存后控制位置修改
---
WebAPI/Controllers/JHGL/Gy_MaterialTechParamBillController.cs | 739 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 738 insertions(+), 1 deletions(-)
diff --git a/WebAPI/Controllers/JHGL/Gy_MaterialTechParamBillController.cs b/WebAPI/Controllers/JHGL/Gy_MaterialTechParamBillController.cs
index a19588e..301c267 100644
--- a/WebAPI/Controllers/JHGL/Gy_MaterialTechParamBillController.cs
+++ b/WebAPI/Controllers/JHGL/Gy_MaterialTechParamBillController.cs
@@ -10,7 +10,9 @@
using System.Web.Http;
using System.Windows.Forms;
using WebAPI.Models;
-
+using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
+using System.IO;
+using SyntacticSugar.constant;
namespace WebAPI.Controllers.MJGL
{
public class Gy_MaterialTechParamBillController : ApiController
@@ -312,6 +314,8 @@
{
try
{
+ string s = "";
+ DAL.ClsGy_MaterialTechParamBillMain BillOld = new DAL.ClsGy_MaterialTechParamBillMain();
//鏌ョ湅鏉冮檺
if (!DBUtility.ClsPub.Security_Log("Gy_MaterialTechParamBillMain_Drop", 1, false, user))
{
@@ -331,10 +335,78 @@
return objJsonResult;
}
+ if (BillOld.ShowBill(long.Parse(HInterID), ref s) == false)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "姝ゅ崟鎹湁璇紒";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ //鍒ゆ柇鏄惁鍙垹闄�
+ if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽鍒犻櫎锛�";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+
oCN.BeginTran();
+
+ //鍒犻櫎鍓嶆帶鍒�=========================================
+ string sql1 = "exec h_p_Gy_MaterialTechParamBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
+ ds = oCN.RunProcReturn(sql1, "h_p_Gy_MaterialTechParamBill_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;
+ 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;
+ return objJsonResult;
+ }
+ //==================================================================================
+
oCN.RunProc("delete from Gy_MaterialTechParamBillMain where HInterID = " + HInterID);
oCN.RunProc("delete from Gy_MaterialTechParamBillSub where HInterID = " + HInterID);
+
+ //鍒犻櫎鍚庢帶鍒�==================================================================================
+ string sql2 = "exec h_p_Gy_MaterialTechParamBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
+ ds = oCN.RunProcReturn(sql2, "h_p_Gy_MaterialTechParamBill_AfterDelCtrl");
+ if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+ {
+ s = "鍒犻櫎鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s;
+ objJsonResult.data = null;
+ oCN.RollBack();
+ return objJsonResult;
+ }
+ if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+ {
+ s = ds.Tables[0].Rows[0]["HRemark"].ToString();
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s;
+ objJsonResult.data = null;
+ oCN.RollBack();
+ return objJsonResult;
+ }
+ //==============================================================================================
+
+
oCN.Commit();
@@ -643,5 +715,670 @@
}
}
#endregion
+
+ #region 瀹夌伅閫愮骇鍛煎彨瑙勫垯 浣滃簾/鍙嶄綔搴�
+ /// <summary>
+ /// </summary>
+ /// <param name="HInterID">鍗曟嵁ID</param>
+ /// <param name="IsAudit">浣滃簾(0),鍙嶄綔搴�(1)</param>
+ /// <param name="CurUserName">浣滃簾浜�</param>
+ /// <returns></returns>
+ [Route("Gy_MaterialTechParamBill/DeleteGy_MaterialTechParamBill")]
+ [HttpGet]
+ public object DeleteGy_MaterialTechParamBill(int HInterID, int IsAudit, string CurUserName)
+ {
+ string ModRightNameCheck = "Gy_MaterialTechParamBillMain_Delete";
+ DBUtility.ClsPub.CurUserName = CurUserName;
+ try
+ {
+ //妫�鏌ユ潈闄�
+ if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "浣滃簾澶辫触锛佹棤鏉冮檺锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ //HInterID鏁版嵁鍒ゆ柇
+ if (HInterID <= 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "HInterID灏忎簬0锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+
+ Int64 lngBillKey = 0;
+ lngBillKey = DBUtility.ClsPub.isLong(HInterID); //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹�
+ DAL.ClsGy_MaterialTechParamBillMain oBill = new DAL.ClsGy_MaterialTechParamBillMain(); //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+
+ //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+ if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
+ {
+ if (oBill.omodel.HChecker.Trim() != "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (IsAudit == 0) //浣滃簾鍒ゆ柇
+ {
+ if (oBill.omodel.HDeleteMan.Trim() != "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶄綔搴燂紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ if (IsAudit == 1) //鍙嶄綔搴熷垽鏂�
+ {
+ if (oBill.omodel.HDeleteMan.Trim() == "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍗曟嵁鏈綔搴�!涓嶉渶瑕佸弽浣滃簾锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+
+ //杩涜闇�瑕佽繘琛岀殑浣滃簾/鍙嶄綔搴熸搷浣�
+ if (IsAudit == 0) //浣滃簾鎻愪氦
+ {
+ //浣滃簾鍓嶆帶鍒�=========================================
+ string sql1 = "exec h_p_Gy_MaterialTechParamBill_BeforeDropCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+ ds = oCN.RunProcReturn(sql1, "h_p_Gy_MaterialTechParamBill_BeforeDropCtrl");
+ 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;
+ }
+ //==================================================================================
+
+
+ //浣滃簾鎻愪氦
+ if (oBill.Cancelltion(lngBillKey, oBill.omodel.HBillNo, "h_p_Gy_MaterialTechParamBill_AfterDropCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+ {
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "浣滃簾鎴愬姛";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ if (IsAudit == 1) //鍙嶄綔搴熸彁浜�
+ {
+ //鍙嶄綔搴熷墠鎺у埗=========================================
+ string sql1 = "exec h_p_Gy_MaterialTechParamBill_BeforeUnDropCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'";
+ ds = oCN.RunProcReturn(sql1, "h_p_Gy_MaterialTechParamBill_BeforeUnDropCtrl");
+ 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;
+ }
+ //==================================================================================
+
+
+ //鍙嶄綔搴熸彁浜�
+ if (oBill.AbandonCancelltion(lngBillKey, oBill.omodel.HBillNo, "h_p_Gy_MaterialTechParamBill_AfterUnDropCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+ {
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍙嶄綔搴熸垚鍔�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "浣滃簾澶辫触鎴栬�呭弽浣滃簾澶辫触锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 浜у搧宸ヨ壓鍙傛暟 鏂囦欢瀵煎叆淇濆瓨
+ #region 浜у搧宸ヨ壓鍙傛暟 鏂囦欢涓婁紶
+ [Route("Gy_MaterialTechParamBill/Gy_MaterialTechParamBill_Excel")]
+ [HttpPost]
+ public object Gy_MaterialTechParamBill_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("HDeptID", typeof(Int32));//閮ㄩ棬ID
+ tb2.Columns.Add("HEmpID", typeof(Int32));//璐熻矗浜篒D
+ tb2.Columns.Add("HMaterID", typeof(Int32));//鐗╂枡ID
+ tb2.Columns.Add("HTechParamID", typeof(Int32));//宸ヨ壓鍙傛暟ID
+ tb2.Columns.Add("HTechParamUnitID", 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("缁勭粐浠g爜"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("缁勭粐鍚嶇О"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囧悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("閮ㄩ棬浠g爜"))
+ error += "娌℃湁鎵惧埌銆愰儴闂ㄤ唬鐮併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("閮ㄩ棬鍚嶇О"))
+ error += "娌℃湁鎵惧埌銆愰儴闂ㄥ悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("璐熻矗浜轰唬鐮�"))
+ error += "娌℃湁鎵惧埌銆愯礋璐d汉浠g爜銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("璐熻矗浜哄悕绉�"))
+ error += "娌℃湁鎵惧埌銆愯礋璐d汉鍚嶇О銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鐗╂枡浠g爜"))
+ error += "娌℃湁鎵惧埌銆愮墿鏂欎唬鐮併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鐗╂枡鍚嶇О"))
+ error += "娌℃湁鎵惧埌銆愮墿鏂欏悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("澶囨敞"))
+ error += "娌℃湁鎵惧埌銆愬娉ㄣ�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("宸ヨ壓鍙傛暟浠g爜"))
+ error += "娌℃湁鎵惧埌銆愬伐鑹哄弬鏁颁唬鐮併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("宸ヨ壓鍙傛暟鍚嶇О"))
+ error += "娌℃湁鎵惧埌銆愬伐鑹哄弬鏁板悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("宸ヨ壓鍙傛暟鍗曚綅浠g爜"))
+ 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 (!tb2.Columns.Contains("閲囬泦鍛ㄦ湡鍗曚綅"))
+ error += "娌℃湁鎵惧埌銆愰噰闆嗗懆鏈熷崟浣嶃�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鍗曟嵁鍙�"))
+ error += "娌℃湁鎵惧埌銆愬崟鎹彿銆戠殑鏍囬,";
+
+ if (error.Length > 0)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ 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 HDeptName = "";
+ string HDeptNumber = "";
+ string HEmpName = "";
+ string HEmpNumber = "";
+ string HMaterNumber = "";
+ string HMaterName = "";
+ string HTechParamNumber = "";
+ string HTechParamName = "";
+ string HTechParamUnitNumber = "";
+ string HTechParamUnitName = "";
+ string HBillNo = "";
+
+ HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString());
+ HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].ToString());
+ HDeptNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["閮ㄩ棬浠g爜"].ToString());
+ HDeptName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["閮ㄩ棬鍚嶇О"].ToString());
+ HEmpNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璐熻矗浜轰唬鐮�"].ToString());
+ HEmpName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璐熻矗浜哄悕绉�"].ToString());
+ HMaterNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡浠g爜"].ToString());
+ HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡鍚嶇О"].ToString());
+ HTechParamNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["宸ヨ壓鍙傛暟浠g爜"].ToString());
+ HTechParamName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["宸ヨ壓鍙傛暟鍚嶇О"].ToString());
+ HTechParamUnitNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["宸ヨ壓鍙傛暟鍗曚綅浠g爜"].ToString());
+ HTechParamUnitName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["宸ヨ壓鍙傛暟鍗曚綅鍚嶇О"].ToString());
+ HBillNo = 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 = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,缁勭粐涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ }
+ else
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,缁勭粐浠g爜涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ //閮ㄩ棬浠g爜
+ if (HDeptNumber != "")
+ {
+ ds = oCN.RunProcReturn("select * from Gy_Department where HNumber='" + HDeptNumber + "' and Hname='" + HDeptName + "'", "Gy_Department");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,閮ㄩ棬涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HDeptID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ }
+ else
+ {
+ tb2.Rows[i]["HDeptID"] = "0";
+ }
+ //璐熻矗浜轰唬鐮�
+ if (HEmpNumber != "")
+ {
+ ds = oCN.RunProcReturn("select * from Gy_Employee where HNumber='" + HEmpNumber + "' and Hname='" + HEmpName + "'", "Gy_Employee");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,璐熻矗浜轰笉瀛樺湪锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HEmpID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ }
+ //鐗╂枡浠g爜
+ if (HMaterNumber != "")
+ {
+ ds = oCN.RunProcReturn("select * from Gy_Material where HNumber='" + HMaterNumber + "' and Hname='" + HMaterName + "'", "Gy_Material");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HMaterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ }
+ //宸ヨ壓鍙傛暟浠g爜
+ if (HTechParamNumber != "")
+ {
+ ds = oCN.RunProcReturn("select * from Gy_TechnologyParameter where HNumber='" + HTechParamNumber + "' and Hname='" + HTechParamName + "'", "Gy_TechnologyParameter");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,宸ヨ壓鍙傛暟涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HTechParamID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ }
+ //宸ヨ壓鍙傛暟鍗曚綅浠g爜
+ if (HTechParamUnitNumber != "")
+ {
+ ds = oCN.RunProcReturn("select * from Gy_TechnologyParameterUnit where HNumber='" + HTechParamUnitNumber + "' and Hname='" + HTechParamUnitName + "'", "Gy_TechnologyParameterUnit");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,宸ヨ壓鍙傛暟鍗曚綅涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HTechParamUnitID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ }
+ //鍗曟嵁鍙�
+ if (HBillNo == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,鍗曟嵁鍙蜂笉鑳戒负绌猴紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+
+ }
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = error;
+ objJsonResult.data = tb2;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 浜у搧宸ヨ壓鍙傛暟椤圭洰 瀵煎叆(淇濆瓨)
+ [Route("Gy_MaterialTechParamBill/Gy_MaterialTechParamBill_btnSave")]
+ [HttpPost]
+ public object Gy_MaterialTechParamBill_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_MaterialTechParamBillMain_Edit", 1, false, user))
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
+ List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+
+ foreach (JObject item in Excel)
+ {
+ Dictionary<string, string> dic = new Dictionary<string, string>();
+ foreach (var itm in item.Properties())
+ {
+ dic.Add(itm.Name, itm.Value.ToString());
+ }
+ list.Add(dic);
+ }
+
+ oCN.BeginTran();
+ int i = 1;
+ foreach (Dictionary<string, string> item in list)
+ {
+ string HBillType = "3334";
+ string HMaker = user;//鍒跺崟浜�
+ DateTime HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --鏃ユ湡
+ long HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+ long HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
+ string HBillNo = item["鍗曟嵁鍙�"].ToString();//鍗曟嵁鍙�
+ string HOrgID = item["HOrgID"].ToString();//缁勭粐ID
+ string HDeptID = item["HDeptID"].ToString() == "" ? "0" : item["HDeptID"].ToString();
+ string HEmpID = item["HEmpID"].ToString() == "" ? "0" : item["HEmpID"].ToString();
+ string HMaterID = item["HMaterID"].ToString()== "" ? "0" : item["HMaterID"].ToString();
+ string HRemark = item["澶囨敞"].ToString();
+ //瀛愯〃
+ string HTechParamID = item["HTechParamID"].ToString() == "" ? "0" : item["HTechParamID"].ToString();//宸ヨ壓鍙傛暟
+ string HTechParamUnitID = item["HTechParamUnitID"].ToString() == "" ? "0" : item["HTechParamUnitID"].ToString();//宸ヨ壓鍙傛暟浠g爜
+ string HStd = item["鏍囧噯鍊�"].ToString() == "" ? "0" : item["鏍囧噯鍊�"].ToString();
+ string HMax = item["涓婇檺"].ToString() == "" ? "0" : item["涓婇檺"].ToString();
+ string HMin = item["涓嬮檺"].ToString() == "" ? "0" : item["涓嬮檺"].ToString();
+ string HDataForm = item["閲囬泦鏉ユ簮"].ToString();
+ string HDataTimes = item["閲囬泦鍛ㄦ湡棰戠巼"].ToString() == "" ? "0" : item["閲囬泦鍛ㄦ湡棰戠巼"].ToString();
+ string HDataUnit = item["閲囬泦鍛ㄦ湡鍗曚綅"].ToString();
+ ds = oCN.RunProcReturn("select * from Gy_MaterialTechParamBillMain where HBillNo='" + HBillNo + "'", "Gy_MaterialTechParamBillMain");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ long HInterID = DBUtility.ClsPub.CreateBillID(HBillType, ref DBUtility.ClsPub.sExeReturnInfo);
+ //鎻掑叆涓昏〃
+ oCN.RunProc("insert into Gy_MaterialTechParamBillMain" +
+ "(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate,HBillNo,HRemark,HMaker,HMakeDate" +
+ ",HDeptID,HEmpID,HMaterID,HWorkCenterID,HEquipID,HOrgID,HProcID,HMouldID ) " +
+ "values(" +
+ "" + HYear.ToString() +
+ "," + HPeriod.ToString() +
+ ",'" + HBillType +
+ "','" + HBillType +
+ "'," + HInterID +
+ ",'" + HDate +
+ "','" + HBillNo +
+ "','" + HRemark +
+ "','" + HMaker +
+ "'," + "getdate()" +
+ "," + HDeptID +
+ "," + HEmpID +
+ ",'" + HMaterID +
+ "','" + 0 +
+ "','" + 0 +
+ "','" + HOrgID +
+ "','" + 0 +
+ "','" + 0 +
+ "')");
+ //鎻掑叆瀛愯〃
+ oCN.RunProc("insert into Gy_MaterialTechParamBillSub" +
+ "(HInterID,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" +
+ ",HTechParamID,HTechParamUnitID,HStd,HMax,HMin,HDataForm,HDataUnit,HDataTimes,HTechParamClassID,HSNO,HStdNextTimes,HTechParamIDStd) " +
+ " values(" +
+ "" + HInterID.ToString() +
+ "," + 1 +
+ "," + 0 +
+ "," + 0 +
+ ",'" + "" +
+ "','" + "" +
+ "','" + HTechParamID +
+ "','" + HTechParamUnitID +
+ "','" + HStd +
+ "','" + HMax +
+ "','" + HMin +
+ "','" + HDataForm +
+ "','" + HDataUnit +
+ "','" + HDataTimes +
+ "','" + 0 +
+ "','" + 0 +
+ "','" + 0 +
+ "','" + "" +
+ "')");
+ }
+ else
+ {
+ long HInterID = long.Parse(ds.Tables[0].Rows[0]["HInterID"].ToString());
+ //鑾峰彇鏈�澶у瓙id
+ DataSet ds2 = oCN.RunProcReturn("select max(HEntryID) HEntryID from Gy_MaterialTechParamBillSub where HInterID='" + HInterID + "'", "Gy_MaterialTechParamBillSub");
+ long HEntryID = 1;
+ if (ds2.Tables[0].Rows.Count > 0)
+ {
+ HEntryID = long.Parse(ds2.Tables[0].Rows[0]["HEntryID"].ToString()) + 1;
+ }
+ //鎻掑叆瀛愯〃
+ oCN.RunProc("insert into Gy_MaterialTechParamBillSub" +
+ "(HInterID,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType" +
+ ",HTechParamID,HTechParamUnitID,HStd,HMax,HMin,HDataForm,HDataUnit,HDataTimes,HTechParamClassID,HSNO,HStdNextTimes,HTechParamIDStd) " +
+ " values(" +
+ "" + HInterID.ToString() +
+ "," + HEntryID +
+ "," + 0 +
+ "," + 0 +
+ ",'" + "" +
+ "','" + "" +
+ "','" + HTechParamID +
+ "','" + HTechParamUnitID +
+ "','" + HStd +
+ "','" + HMax +
+ "','" + HMin +
+ "','" + HDataForm +
+ "','" + HDataUnit +
+ "','" + HDataTimes +
+ "','" + 0 +
+ "','" + 0 +
+ "','" + 0 +
+ "','" + "" +
+ "')");
+ }
+
+ i++;
+ }
+
+ oCN.Commit();
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = "瀵煎叆鎴愬姛!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ LogService.Write(e);
+ oCN.RollBack();
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+ #endregion
+
}
}
\ No newline at end of file
--
Gitblit v1.9.1