From d145c38d85c1962e4564d6730695dacfa3116ccf Mon Sep 17 00:00:00 2001
From: llj <132905093+newwwwwwtree@users.noreply.github.com>
Date: 星期一, 03 十一月 2025 10:46:39 +0800
Subject: [PATCH] 供应商平台,添加新增送货物料信息的保存权限、删除权限,条码档案添加删除权限
---
WebAPI/Controllers/MaterialHandingController.cs | 567 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 550 insertions(+), 17 deletions(-)
diff --git a/WebAPI/Controllers/MaterialHandingController.cs b/WebAPI/Controllers/MaterialHandingController.cs
index 324b55c..a6cea28 100644
--- a/WebAPI/Controllers/MaterialHandingController.cs
+++ b/WebAPI/Controllers/MaterialHandingController.cs
@@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
+using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
@@ -34,6 +35,14 @@
string VsWhere = sWhere;
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
DataSet ds;
+ if (!DBUtility.ClsPub.Security_Log("Gy_SupMaterPack_Query", 1, false, user))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
//鍏朵粬杩囨护
//string sql = " where 1 = 1 " + sqlWhere;
////杞崲鐗规畩瀛楃
@@ -86,12 +95,12 @@
[Route("MaterialHandingController/OpenMaterial")]
[HttpGet]
- public object OpenMaterial(int HInterID, int IsUse, string CurUserName)
+ public object OpenMaterial(int HInterID, int IsUse, string CurUserName,string HMaterID)
{
try
{
-
var ds = oCN.RunProcReturn("select * from Gy_UserMaterRelation where HItemID=" + HInterID, "Gy_UserMaterRelation");
+ var ds_1 = oCN.RunProcReturn("select * from Gy_UserMaterRelation where HMaterID=" + HMaterID+ "order by HItemID desc", "Gy_UserMaterRelation");
if (ds.Tables[0].Rows.Count > 0)
{
IsUse = Convert.ToInt32(ds.Tables[0].Rows[0]["HUseFlag"]) ;
@@ -106,7 +115,19 @@
return objJsonResult;
}
}
+ else
+ {
+ if (ds_1.Tables[0].Rows.Count > 1)
+ {
+ string sql = "update Gy_UserMaterRelation set HUseFlag=0 where HMaterID= " + "'" + HMaterID + "'" + "and HItemID!=" + HInterID;
+ oCN.BeginTran();
+ oCN.RunProc(sql);
+ oCN.Commit();
+
+ }
+ }
}
+
else
{
objJsonResult.code = "0";
@@ -174,10 +195,14 @@
//==================================================================================
- objJsonResult.code = "1";
- objJsonResult.count = 1;
- objJsonResult.Message = "鍚敤鎴愬姛";
- objJsonResult.data = null;
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍚敤鎴愬姛";
+ objJsonResult.data = null;
+
+
+
}
//if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂�
//{
@@ -257,12 +282,12 @@
#region 鐗╂枡鏍¢獙
[Route("MaterialHandingController/CheckMaterial")]
[HttpGet]
- public object CheckMaterial(string HMaterID, string user, int param,string OrganizationID)
+ public object CheckMaterial(string HMaterID, string user, int param,string OrganizationID,string SupID)
{
try
{
//ds1鑾峰彇鐨剆ql鍚庢湡璁板緱鏀瑰洖渚涘簲鍟嗭紝淇敼浜�->渚涘簲鍟�
- var ds1 = oCN.RunProcReturn("select * from h_v_Gy_UserMaterRelationEdit where 鐗╂枡浠g爜='" + HMaterID + "'" + "and 淇敼浜�='" + user + "'", "h_v_Gy_UserMaterRelationEdit");
+ var ds1 = oCN.RunProcReturn("select * from h_v_Gy_UserMaterRelationEdit where 鐗╂枡浠g爜='" + HMaterID + "'" + "and HSupID ='" + SupID + "'", "h_v_Gy_UserMaterRelationEdit");
var ds = oCN.RunProcReturn("select * from Gy_Material where HNumber='" + HMaterID+ "'"+ " and HUSEORGID="+"'"+ OrganizationID+"'", "Gy_Material");
if(ds.Tables[0].Rows.Count == 0)
{
@@ -283,7 +308,8 @@
else
{
oCN.BeginTran();
- string sqlUpd = "UPDATE Gy_UserMaterRelation set HUseFlag=0 where HMaterID="+ ds.Tables[0].Rows[0]["HItemID"];
+ string sqlUpd = "UPDATE a set a.HUseFlag=0 from Gy_UserMaterRelation a with(nolock) left join Gy_Material m with(nolock) " +
+ "on a.HMaterID = m.HItemID where a.HSupID=" + SupID + " and m.HNumber = '" + HMaterID + "'";
oCN.RunProc(sqlUpd);
oCN.Commit();
@@ -358,19 +384,25 @@
{
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();
+
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();
+ string msg1 = _value.ToString();
+ string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+ string msg2 = sArray[0].ToString();//
+ string OrganizationID = sArray[1].ToString();//
//鍙嶅簭鍒楀寲
msg2 = "[" + msg2.ToString() + "]";
List<Model.Cls_MaterialHandingModel> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.Cls_MaterialHandingModel>>(msg2);
- var ds = oCN.RunProcReturn("select * from Gy_Material where HNumber='" + list[0].HMaterNumber + "'", "Gy_Material");
+ var ds = oCN.RunProcReturn("select * from Gy_Material where HNumber='" + list[0].HMaterNumber + "' and HUSEORGID = " + OrganizationID, "Gy_Material");
int HItemID =Convert.ToInt32(list[0].HItemID);
string HMaterNumber = list[0].HMaterNumber;
@@ -552,8 +584,15 @@
objJsonResult.data = null;
return objJsonResult;
}
-
- oCN.BeginTran();
+ if (!DBUtility.ClsPub.Security_Log("Gy_SupMaterPack_Delete", 1, false, user))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ oCN.BeginTran();
// oCN.RunProc("delete from Gy_UserMaterRelation where HInterID = " + HItemID);
oCN.RunProc("delete from Gy_UserMaterRelation where HItemID='" + HItemID + "'");
@@ -581,7 +620,501 @@
}
//#endregion
+ #region 涓婚〉闈㈠惎鐢�
+ [Route("MaterialHandingController/CheckMaterialCount")]
+ [HttpGet]
+ public object CheckMaterialCount(string HMaterID, string HSupID, int HInterID)
+ {
+ try
+ {
+ //妫�鏌ュ悓渚涘簲鍟嗕笅鏄惁鏈夊叾浠栫墿鏂�
+ string sql = "SELECT COUNT(*) as Count FROM Gy_UserMaterRelation " +
+ "WHERE HMaterID = '" + HMaterID + "' AND HSupID = " + HSupID +
+ " AND HItemID != " + HInterID;
+ var ds = oCN.RunProcReturn(sql, "Gy_UserMaterRelation");
+ int count = Convert.ToInt32(ds.Tables[0].Rows[0]["Count"]);
+ objJsonResult.code = "1";
+ objJsonResult.count = count;
+ objJsonResult.Message = "鏌ヨ鎴愬姛";
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏌ヨ澶辫触: " + e.Message;
+ return objJsonResult;
+ }
+ }
+
+ [Route("MaterialHandingController/OpenMaterial")]
+ [HttpGet]
+ public object OpenMaterial(int HInterID, int IsUse, string CurUserName, string HMaterID, string HSupID, int disableOthers)
+ {
+ try
+ {
+ var ds = oCN.RunProcReturn("SELECT * FROM Gy_UserMaterRelation WHERE HItemID=" + HInterID, "Gy_UserMaterRelation");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+ return objJsonResult;
+ }
+
+ int currentUseFlag = Convert.ToInt32(ds.Tables[0].Rows[0]["HUseFlag"]);
+
+ // 妫�鏌ユ槸鍚﹀凡鍚敤
+ if (currentUseFlag == 1)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍗曟嵁宸插惎鐢�!涓嶈兘鍐嶆鍚敤锛�";
+ return objJsonResult;
+ }
+
+ oCN.BeginTran();
+
+ // 濡傛灉鐢ㄦ埛閫夋嫨绂佺敤
+ if (disableOthers == 1)
+ {
+ string disableSql = "UPDATE Gy_UserMaterRelation SET HUseFlag=0 " +
+ "WHERE HMaterID='" + HMaterID + "' AND HSupID=" + HSupID +
+ " AND HItemID!=" + HInterID;
+ oCN.RunProc(disableSql);
+ }
+
+ // 鍚敤鍓嶆帶鍒�
+ string sql1 = "EXEC h_p_Gy_MaterPrice_BeforeStopCtrl " + HInterID + ",'" + CurUserName + "'";
+ ds = oCN.RunProcReturn(sql1, "h_p_Gy_MaterPrice_BeforeStopCtrl");
+
+ if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍚敤澶辫触!鍘熷洜:鍚敤鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+ oCN.RollBack();
+ return objJsonResult;
+ }
+
+ if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍚敤澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString();
+ oCN.RollBack();
+ return objJsonResult;
+ }
+
+ // 鍚敤褰撳墠璁板綍
+ oCN.RunProc("UPDATE Gy_UserMaterRelation SET HUpDater='" + CurUserName +
+ "', HUpDateDate=GETDATE(), HUseFlag=1 WHERE HItemID=" + HInterID);
+
+ // 鍚敤鍚庢帶鍒�
+ string sql2 = "EXEC h_p_Gy_MaterPrice_AfterStopCtrl " + HInterID + ",'" + CurUserName + "'";
+ ds = oCN.RunProcReturn(sql2, "h_p_Gy_MaterPrice_AfterStopCtrl");
+
+ if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍚敤澶辫触!鍘熷洜:鍚敤鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+ oCN.RollBack();
+ return objJsonResult;
+ }
+
+ if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍚敤澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString();
+ oCN.RollBack();
+ return objJsonResult;
+ }
+
+ oCN.Commit();
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍚敤鎴愬姛";
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ oCN.RollBack();
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍚敤澶辫触!" + e.Message;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ [Route("MaterialHandingController/list")]
+ [HttpGet]
+ public object list(string sWhere, string user, string Organization)
+ {
+ try
+ {
+ string sql1 = "";
+ List<object> columnNameList = new List<object>();
+ if (user == "admin")
+ {
+ sql1 = string.Format(@"select * from h_v_UserSupplierRelationMater where 1=1");
+ }
+ else
+ {
+ sql1 = string.Format(@"select * from h_v_UserSupplierRelationMater where 鐢ㄦ埛鍚嶇О='" + user + "'");
+ }
+
+ if (sWhere == null || sWhere.Equals(""))
+ {
+ ds = oCN.RunProcReturn(sql1 + sWhere, "h_v_UserSupplierRelationMater");
+ }
+ else
+ {
+ string sql = sql1 + sWhere;
+ ds = oCN.RunProcReturn(sql, "h_v_UserSupplierRelationMater");
+ }
+
+ //娣诲姞鍒楀悕
+ 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));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+ }
+
+ 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;
+ }
+ }
+
+ #region 閫佽揣鐗╂枡淇℃伅 鏂囦欢涓婁紶
+ [Route("Gy_SupMaterPack/SupMaterPack_Excel")]
+ [HttpPost]
+ public object SupMaterPack_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("HMaterID", typeof(Int32));//鐗╂枡ID
+ tb2.Columns.Add("HSupID", typeof(Int32));//渚涘簲鍟咺D
+ tb2.Columns.Add("HUSEORGID", 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
+ if (ExcelDs.Tables[0].Rows[i][0].ToString() == "")
+ {
+ continue;
+ }
+ else
+ {
+ tb2.Rows.Add(row);
+ }
+ }
+
+ var error = "";
+
+ //鏌ヨ閫佽揣鐗╂枡淇℃伅涓病鏈夌殑鍒�
+ if (!tb2.Columns.Contains("缁勭粐浠g爜"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("缁勭粐鍚嶇О"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囧悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("渚涘簲鍟嗕唬鐮�"))
+ error += "娌℃湁鎵惧埌銆愪緵搴斿晢浠g爜銆戠殑鏍囬,";
+
+ 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 (error.Length > 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ string HOrgNumber = "";
+ string HOrgName = "";
+ string HSupNumber = "";
+ string HSupName = "";
+ string HMaterNumber = "";
+ string HMaterName = "";
+ string HMaterModel = "";
+ double HInBoxPackQty = 0;
+ double HMinPackQty = 0;
+
+ for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+ {
+ HOrgNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString());
+ HOrgName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].ToString());
+ HSupNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟嗕唬鐮�"].ToString());
+ HSupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟嗗悕绉�"].ToString());
+ HMaterNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡浠g爜"].ToString());
+ HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡鍚嶇О"].ToString());
+ HMaterModel = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瑙勬牸鍨嬪彿"].ToString());
+ HInBoxPackQty = DBUtility.ClsPub.isDoule(tb2.Rows[i]["鏍囧噯鍖呰鏁伴噺"].ToString());
+ HMinPackQty = DBUtility.ClsPub.isDoule(tb2.Rows[i]["鏈�灏忓寘瑁呮暟閲�"].ToString());
+
+ //妫�鏌ヨ〃鏍兼暟鎹�
+ int index = i + 1;
+
+ if (HOrgNumber != "" && HSupNumber != "" && HMaterNumber != "" && HInBoxPackQty != 0)
+ {
+ //鏌ヨ缁勭粐
+ ds = oCN.RunProcReturn("select HItemID from Xt_ORGANIZATIONS org with(nolock) where HNumber='" + HOrgNumber + "'", "Xt_ORGANIZATIONS");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,缁勭粐涓嶅瓨鍦紒" + "缁勭粐浠g爜锛�" + HOrgNumber;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HUSEORGID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+
+
+ //鏌ヨ鐗╂枡
+ ds = oCN.RunProcReturn("select m.HItemID from Gy_Material m with(nolock) " +
+ "left join Xt_ORGANIZATIONS org with(nolock) on m.HUSEORGID = org.HItemID " +
+ "where m.HNumber='" + HMaterNumber + "' and org.HNumber='" + HOrgNumber + "'"
+ , "Gy_Material");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡涓嶅瓨鍦紒" + "浣跨敤缁勭粐浠g爜锛�" + HOrgNumber + " 锛岀墿鏂欎唬鐮侊細" + HMaterNumber;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HMaterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+
+
+ //鏌ヨ渚涘簲鍟�
+ ds = oCN.RunProcReturn("select s.HItemID from Gy_Supplier s with(nolock) " +
+ "left join Xt_ORGANIZATIONS org with(nolock) on s.HUSEORGID = org.HItemID " +
+ "where s.HNumber='" + HSupNumber + "' and org.HNumber='" + HOrgNumber + "'"
+ , "Gy_Supplier");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,渚涘簲鍟嗕笉瀛樺湪锛�" + "浣跨敤缁勭粐浠g爜锛�" + HOrgNumber + " 锛屼緵搴斿晢浠g爜锛�" + HSupNumber; ;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HSupID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,淇℃伅涓嶅叏锛堢粍缁囦唬鐮�,渚涘簲鍟嗕唬鐮�,鐗╂枡浠g爜,鏍囧噯鍖呰鏁伴噺锛�";
+ 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_SupMaterPack/SupMaterPack_btnSave")]
+ [HttpPost]
+ public object SupMaterPack_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_SupMaterPack_Query", 1, false, user))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ 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 HSupID = item["HSupID"].ToString();//渚涘簲鍟�
+ string HSupNumber = item["渚涘簲鍟嗕唬鐮�"].ToString();//渚涘簲鍟嗕唬鐮�
+ string HMaterID = item["HMaterID"].ToString();//鐗╂枡
+ string HUSEORGID = item["HUSEORGID"].ToString();//缁勭粐
+ string HInBoxPackQty = item["鏍囧噯鍖呰鏁伴噺"].ToString();//鏍囧噯鍖呰鏁伴噺
+ string HMinPackQty = item["鏈�灏忓寘瑁呮暟閲�"].ToString();//鏈�灏忓寘瑁呮暟閲�
+
+ //鎷兼帴鏂板璇彞
+ string sql = "insert into Gy_UserMaterRelation(HMaterID,HUserID,HMinPackQty,HInBoxPackQty,HUSEORGID,HUseFlag,HSupID,HMaker,HMakeTime)" +
+ $"values({HMaterID}, '{HSupNumber}',{HMinPackQty}, {HInBoxPackQty}, {HUSEORGID},'1',{HSupID}, '{user}',getdate())";
+
+ //鏌ヨ姝や緵搴斿晢鏄惁宸茬粡娣诲姞杩囬�佽揣鐗╂枡淇℃伅
+ ds = oCN.RunProcReturn("select HInBoxPackQty from Gy_UserMaterRelation with(nolock) where HSupID = " + HSupID + " and HMaterID = " + HMaterID + " and HUSEORGID = " + HUSEORGID, "Gy_UserMaterRelation");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ //鎵ц鏂板璇彞
+ oCN.RunProc(sql);
+ }
+ else
+ {
+ var HIsReturn = "false";
+
+ for (var k = 0; k < ds.Tables[0].Rows.Count; k++)
+ {
+ if (Convert.ToDecimal(ds.Tables[0].Rows[k]["HInBoxPackQty"]) == Convert.ToDecimal(HInBoxPackQty))
+ {
+ HIsReturn = "true";
+ break;
+ }
+ }
+
+ if (HIsReturn == "true")
+ {
+ //鏈excel瀵煎叆鐨勭墿鏂欏寘瑁呮暟閲忓凡缁忔坊鍔犺繃锛屽垯璺宠繃鏈娣诲姞
+ continue;
+ }
+ else
+ {
+ //鏇存柊鍘熸潵鐨勯�佽揣鐗╂枡淇℃伅涓哄緟鍚敤鐘舵��
+ string sql2 = "update a set HUseFlag = 0,HUpDater = '" + user + "',HUpDateDate = getdate() from Gy_UserMaterRelation a with(nolock) where HSupID = " + HSupID + " and HMaterID = " + HMaterID + " and HUSEORGID = " + HUSEORGID;
+ //鎵ц鏇存柊璇彞
+ oCN.RunProc(sql2);
+
+ //鎵ц鏂板璇彞
+ oCN.RunProc(sql);
+ }
+ }
+
+ 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
}
}
\ No newline at end of file
--
Gitblit v1.9.1