using DBUtility;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using Pub_Class;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.IO;
|
using System.Linq;
|
using System.Net;
|
using System.Net.Http;
|
using System.Web;
|
using System.Web.Http;
|
using WebAPI.Controllers.SCGL.日计划管理;
|
using WebAPI.Models;
|
|
namespace WebAPI.Controllers.生产管理.客户标签
|
{
|
public class Sc_CustomerTagController : ApiController
|
{
|
private json objJsonResult = new json();
|
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
|
DataSet ds;
|
public DAL.ClsSc_CustomerTagInfo BillOld = new DAL.ClsSc_CustomerTagInfo();
|
|
#region 客户标签信息 查询-分页
|
[Route("Sc_CustomerTagInfo/PageList")]
|
[HttpGet]
|
public object PageList(string sWhere, string user, string Organization, int page, int size)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>(); //定义声明变量 ,把通过 new List<object>()创建的 实例,赋值给变量
|
//判断是否有查询权限
|
if (!DBUtility.ClsPub.Security_Log("Sc_CustomerTagInfo_Query", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无权限查询!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
ds = oCN.RunProcReturn("exec h_p_Sc_CustomerTagInfoList " + page + "," + size + ",'" + Organization + "'," + "''", "h_p_Sc_CustomerTagInfoList");
|
}
|
else
|
{
|
sWhere = sWhere.Replace("'", "''");
|
ds = oCN.RunProcReturn("exec h_p_Sc_CustomerTagInfoList " + page + "," + size + ",'" + Organization + "','" + sWhere + "'", "h_p_Sc_CustomerTagInfoList");
|
}
|
|
//添加列名
|
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 = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.list = columnNameList;
|
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("Sc_CustomerTagInfo/EditCX")]
|
[HttpGet]
|
public object EditCX(long HInterID)
|
{
|
try
|
{
|
|
ds = oCN.RunProcReturn("select * from h_v_Sc_CustomerTagInfoEdit where hmainid=" + HInterID, "h_v_Sc_CustomerTagInfoEdit");
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "false!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
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("Sc_CustomerTagInfo/SaveCustomerTagInfo")]
|
[HttpPost]
|
public object SaveCustomerTagInfo([FromBody] JObject msg)
|
{
|
var _value = msg["msg"].ToString();
|
string msg1 = _value.ToString();
|
string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
|
string msg2 = sArray[0].ToString();
|
string msg3 = sArray[1].ToString();
|
string user = sArray[2].ToString();
|
string OperationType = sArray[3].ToString();
|
|
ListModels oListModels = new ListModels();
|
try
|
{
|
//判断权限
|
if (!DBUtility.ClsPub.Security_Log("Sc_CustomerTagInfo_Edit", 1, false, user))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "无保存权限";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
DAL.ClsSc_CustomerTagInfo oBill = new DAL.ClsSc_CustomerTagInfo();
|
List<Model.ClsSc_CustomerTagInfoMain> lsmain = new List<Model.ClsSc_CustomerTagInfoMain>();
|
msg2 = msg2.Replace("\\", "");
|
msg2 = msg2.Replace("\n", ""); //\n
|
lsmain = oListModels.getCustomerTagInfoMainByJson(msg2);
|
foreach (Model.ClsSc_CustomerTagInfoMain oItem in lsmain)
|
{
|
oItem.HMaker = user;
|
oItem.HUpDater = user;
|
|
if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!没有单据日期,无法保存!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
oBill.omodel = oItem;
|
}
|
//表体数据
|
//按 },{来拆分数组 //去掉【和】
|
msg3 = msg3.Substring(1, msg3.Length - 2);
|
msg3 = msg3.Replace("\\", "");
|
msg3 = msg3.Replace("\n", ""); //\n
|
List<Model.ClsSc_CustomerTagInfoSub> ls = new List<Model.ClsSc_CustomerTagInfoSub>();
|
ls = oListModels.getCustomerTagInfoSubByJson(msg3);
|
int i = 0;
|
foreach (Model.ClsSc_CustomerTagInfoSub oItemSub in ls)
|
{
|
i++;
|
oItemSub.HEntryID = i;
|
oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
|
oItemSub.HCloseType = false;
|
oItemSub.HCloseMan = "";
|
oBill.DetailColl.Add(oItemSub);
|
}
|
|
//进行 会计期间 结账 的判断和控制
|
string s = "";
|
int sYear = 0;
|
int sPeriod = 0;
|
DateTime HDate = DateTime.Now;
|
if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
|
{
|
objJsonResult.Message = s;
|
return objJsonResult;
|
}
|
|
//保存
|
//保存完毕后处理
|
bool bResult;
|
if (Convert.ToInt32(OperationType) == 1) //新增保存
|
{
|
bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
|
}
|
else if (Convert.ToInt32(OperationType) == 4) //下推保存
|
{
|
bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
|
}
|
else //编辑保存
|
{
|
if (BillOld.ShowBill(lsmain[0].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;
|
}
|
if (BillOld.omodel.HBillStatus > 1)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "此单据处于不可编辑状态,不允许修改!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld, ref s))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = s + ",不允许修改";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
|
bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
|
}
|
|
if (bResult)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "保存成功!";
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo;
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
}
|
catch (Exception e)
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "保存失败!" + e.ToString();
|
objJsonResult.data = 1;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 客户标签信息 文件上传
|
[Route("Sc_CustomerTagInfo/Sc_CustomerTagInfo_Excel")]
|
[HttpPost]
|
public object Sc_CustomerTagInfo_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("HCustID", 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();
|
}
|
//如果表格第i行的第一列为空,则判断为这一行的数据为空,跳出循环并且不把数据写入 tb2
|
if (ExcelDs.Tables[0].Rows[i][0].ToString() == "")
|
{
|
continue;
|
}
|
else
|
{
|
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("EPE%"))
|
error += "没有找到【EPE%】的标题,";
|
|
if (!tb2.Columns.Contains("PU%"))
|
error += "没有找到【PU%】的标题,";
|
|
if (!tb2.Columns.Contains("SKU"))
|
error += "没有找到【SKU】的标题,";
|
|
if (!tb2.Columns.Contains("SIZE1"))
|
error += "没有找到【SIZE1】的标题,";
|
|
if (!tb2.Columns.Contains("SIZE2"))
|
error += "没有找到【SIZE2】的标题,";
|
|
if (!tb2.Columns.Contains("LBS"))
|
error += "没有找到【LBS】的标题,";
|
|
if (!tb2.Columns.Contains("OZ"))
|
error += "没有找到【OZ】的标题,";
|
|
if (!tb2.Columns.Contains("UPC A"))
|
error += "没有找到【UPC A】的标题,";
|
|
if (!tb2.Columns.Contains("SKU2"))
|
error += "没有找到【SKU2】的标题,";
|
|
if (!tb2.Columns.Contains("FABRIC"))
|
error += "没有找到【FABRIC】的标题,";
|
|
if (!tb2.Columns.Contains("SN号"))
|
error += "没有找到【SN号】的标题,";
|
|
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 HMaterNumber = "";
|
string HMaterName = "";
|
string HCustNumber = "";
|
string HCustName = "";
|
string HEPE = "";
|
string HPU = "";
|
string HSKU = "";
|
string HSIZE1 = "";
|
string HSIZE2 = "";
|
string HLBS = "";
|
string HOZ = "";
|
string HUPC = "";
|
string HSKU2 = "";
|
string HFABRIC = "";
|
string HSN = "";
|
string HSize = "";
|
string HCustMaterNumber = "";
|
string HCustMaterName = "";
|
string HCustMaterModel = "";
|
|
|
HMaterNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["物料代码"].ToString());
|
HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["物料名称"].ToString());
|
HCustNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["客户代码"].ToString());
|
HCustName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["客户名称"].ToString());
|
HEPE = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["EPE%"].ToString());
|
HPU = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["PU%"].ToString());
|
HSKU = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["SKU"].ToString());
|
HSIZE1 = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["SIZE1"].ToString());
|
HSIZE2 = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["SIZE2"].ToString());
|
HLBS = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["LBS"].ToString());
|
HOZ = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["OZ"].ToString());
|
HUPC = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["UPC A"].ToString());
|
HSKU2 = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["SKU2"].ToString());
|
HFABRIC = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["FABRIC"].ToString());
|
HSN = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["SN号"].ToString());
|
HSize = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["尺寸"].ToString());
|
HCustMaterNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["客户指定代码"].ToString());
|
HCustMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["客户指定名称"].ToString());
|
HCustMaterModel = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["客户指定规格"].ToString());
|
|
|
//检查表格数据
|
int index = i + 1;
|
|
if (HMaterNumber != "" && HMaterName != "")
|
{
|
//查询物料
|
ds = oCN.RunProcReturn("select HItemID,HNumber,HName,HModel from Gy_Material with(nolock) where HNumber='" + HMaterNumber + "' and HName='" + HMaterName + "'", "Gy_Material");
|
|
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]["HMaterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
|
}
|
|
//查询客户
|
ds = oCN.RunProcReturn("select HItemID,HNumber,HName from Gy_Customer with(nolock) where HNumber='" + HCustNumber + "'", "Gy_Process");
|
|
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]["HCustID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
|
}
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
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("Sc_CustomerTagInfo/Sc_CustomerTagInfo_btnSave")]
|
[HttpPost]
|
public object Sc_CustomerTagInfo_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("Sc_CustomerTagInfo_Edit", 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();
|
long HInterID = DBUtility.ClsPub.CreateBillID("10003", ref DBUtility.ClsPub.sExeReturnInfo);
|
string HBillNo = DBUtility.ClsPub.CreateBillCode("10003", ref DBUtility.ClsPub.sExeReturnInfo,true);
|
|
string mainSql = "Insert Into Sc_CustomerTagInfoMain" +
|
"(HInterID,HBillNo,HDate,HYear,HPeriod,HRemark,HMaker,HMakeDate,HBillStatus" +
|
",HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType" +
|
") " +
|
"values(" +
|
"" + HInterID +
|
",'" + HBillNo + "'" +
|
",getdate()" +
|
",Year(getdate())" +
|
",Month(getdate())" +
|
"," + "''" +
|
",'" + "Excel" + "'" +
|
"," + "getdate()" + "" +
|
"," + "1" + "" +
|
"," + 0 + "" +
|
"," + 0 + "" +
|
",'" + "''" + "'" +
|
",'" + "''" + "'" +
|
") ";
|
|
oCN.RunProc(mainSql);
|
|
int i = 1;
|
foreach (Dictionary<string, string> item in list)
|
{
|
string HMaterNumber = item["物料代码"];
|
string HMaterName = item["物料名称"];
|
string HCustNumber = item["客户代码"];
|
string HCustName = item["客户名称"];
|
string HEPE = item["EPE%"];
|
string HPU = item["PU%"];
|
string HSKU = item["SKU"];
|
string HSIZE1 = item["SIZE1"];
|
string HSIZE2 = item["SIZE2"];
|
string HLBS = item["LBS"];
|
string HOZ = item["OZ"];
|
string HUPC = item["UPC A"];
|
string HSKU2 = item["SKU2"];
|
string HFABRIC = item["FABRIC"];
|
string HSN = item["SN号"];
|
string HSize = item["尺寸"];
|
string HCustMaterNumber = item["客户指定代码"];
|
string HCustMaterName = item["客户指定名称"];
|
string HCustMaterModel = item["客户指定规格"];
|
Int32 HMaterID = Convert.ToInt32(item["HMaterID"]);
|
Int32 HCustID = Convert.ToInt32(item["HCustID"]);
|
|
|
ds = oCN.RunProcReturn("select HMaterID,HCustID from Sc_CustomerTagInfoSub with(nolock) where HMaterID=" + HMaterID + " and HCustID = " + HCustID, "Sc_CustomerTagInfoSub");
|
|
if (ds.Tables[0].Rows.Count == 0)
|
{
|
string sql = "insert into Sc_CustomerTagInfoSub(HInterID,HEntryID,HRemark,HBillNo_bak,HMaterID,HCustID,HEPE,HPU,HSKU,HSIZE1,HSIZE2,HLBS,HOZ,HUPC,HSKU2" +
|
",HFABRIC,HSN,HSize,HCustMaterNumber,HCustMaterName,HCustMaterModel,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType)" +
|
$"values('{HInterID}', '{i}','{""}', '{HBillNo}', '{HMaterID}', '{HCustID}', '{HEPE}','{HPU}','{HSKU}','{HSIZE1}','{HSIZE2}','{HLBS}','{HOZ}','{HUPC}','{HSKU2}','{HFABRIC}','{HSN}','{HSize}','{HCustMaterNumber}','{HCustMaterName}','{HCustMaterModel}',{0},{0},'{""}','{""}')";
|
oCN.RunProc(sql);
|
|
i++;
|
}
|
else
|
{
|
oCN.RunProc("update Sc_CustomerTagInfoSub set HEPE='" + HEPE + "',HPU='" + HPU + "',HSKU='" + HSKU + "',HSIZE1='" + HSIZE1 + "',HSIZE2='" + HSIZE2 + "',HLBS='" + HLBS + "',HOZ='" + HOZ + "',HUPC='" + HUPC + "',HSKU2='" + HSKU2 + "',HFABRIC='" + HFABRIC + "',HSN='" + HSN + "',HSize='" + HSize + "',HCustMaterNumber='" + HCustMaterNumber + "',HCustMaterName='" + HCustMaterName + "',HCustMaterModel='" + HCustMaterModel + "' where HMaterID=" + HMaterID + " and HCustID=" + HCustID);
|
}
|
|
i++;
|
}
|
|
oCN.Commit();
|
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "导入成功!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
LogService.Write(e);
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "Exception!" + e.ToString();
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region [客户标签信息删除功能]
|
[Route("Sc_CustomerTagInfo/Delete")]
|
[HttpGet]
|
public object Delete(string HItemSubIDs, string user)
|
{
|
try
|
{
|
DataSet Ds;
|
DataSet Ds2;
|
|
if (HItemSubIDs == "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "[0000-1-009]选择客户标签信息为空!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
|
Ds = oCN.RunProcReturn("Select * from h_v_Sc_CustomerTagInfoList with(nolock) Where HItemSubID in (" + HItemSubIDs + ")", "h_v_Sc_CustomerTagInfoList");
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
oCN.BeginTran();
|
|
//删除客户标签信息--子表
|
oCN.RunProc("Delete from Sc_CustomerTagInfoSub Where HItemSubID in (" + HItemSubIDs + ")");
|
|
//写入系统日志
|
for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
|
{
|
oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','','" + "Sc_CustomerTagInfoList——Delete" + "','LMES-客户标签信息模块','" + DBUtility.ClsPub.IPAddress + "','" + user + "删除客户标签信息," + "客户名称:" + Ds.Tables[0].Rows[i]["客户名称"] + ",物料代码:" + Ds.Tables[0].Rows[i]["物料代码"] + ",单据号:" + Ds.Tables[0].Rows[i]["单据号"] + "'", ref DBUtility.ClsPub.sExeReturnInfo);
|
}
|
|
oCN.Commit();
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "[0000-1-008]删除成功";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "[0000-1-045]单据未找到";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "[0000-1-007]" + e.Message;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
|
#region 客户标签档案生成
|
[Route("Sc_CustomerTagBarCode/Save")]
|
[HttpGet]
|
public object BarCodeSave(string HICMOInterID, string HICMOEntryID)
|
{
|
try
|
{
|
|
if (HICMOInterID == null || HICMOInterID.Equals("") || HICMOEntryID == null || HICMOEntryID.Equals(""))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "订单信息不全!HICMOInterID:" + HICMOInterID + ",HICMOEntryID:" + HICMOEntryID;
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
else
|
{
|
ds = oCN.RunProcReturn("exec h_p_Sc_CustomerTagBarCode_AutoSave " + HICMOInterID + "," + HICMOEntryID, "h_p_Sc_CustomerTagBarCode_AutoSave");
|
}
|
|
if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
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("Sc_CustomerTagBarCode/BarPageList")]
|
[HttpGet]
|
public object BarPageList(string sWhere, string user, string Organization, int page, int size)
|
{
|
try
|
{
|
List<object> columnNameList = new List<object>(); //定义声明变量 ,把通过 new List<object>()创建的 实例,赋值给变量
|
|
if (sWhere == null || sWhere.Equals(""))
|
{
|
ds = oCN.RunProcReturn("exec h_p_Sc_CustomerTagBarCodeList " + page + "," + size + ",'" + Organization + "'," + "''", "h_p_Sc_CustomerTagBarCodeList");
|
}
|
else
|
{
|
sWhere = sWhere.Replace("'", "''");
|
ds = oCN.RunProcReturn("exec h_p_Sc_CustomerTagBarCodeList " + page + "," + size + ",'" + Organization + "','" + sWhere + "'", "h_p_Sc_CustomerTagBarCodeList");
|
}
|
|
//添加列名
|
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 = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
|
objJsonResult.Message = "Sucess!";
|
objJsonResult.list = columnNameList;
|
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("Sc_CustomerTagBarCode/DeleteBarCode")]
|
[HttpGet]
|
public object DeleteBarCode(string HItemIDs,string user)
|
{
|
try
|
{
|
DataSet Ds;
|
|
if (HItemIDs == "")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "[0000-1-009]选择条码为空!";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
|
|
Ds = oCN.RunProcReturn("Select * from h_v_Sc_CustomerTagBarCodeList with(nolock) Where HItemID in (" + HItemIDs + ")", "h_v_Sc_CustomerTagBarCodeList");
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
oCN.BeginTran();
|
|
//删除客户标签条码
|
oCN.RunProc("Delete from Sc_CustomerTagBarCode Where HItemID in (" + HItemIDs + ")");
|
|
//写入系统日志
|
for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
|
{
|
oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','','" + "Sc_CustomerTagBarCodeList——Delete" + "','LMES-客户标签条码模块','" + DBUtility.ClsPub.IPAddress + "','" + user + "删除客户标签条码," + "生产订单:" + Ds.Tables[0].Rows[i]["生产订单号"] + ",物料代码:" + Ds.Tables[0].Rows[i]["物料代码"] + ",流水号:" + Ds.Tables[0].Rows[i]["流水号"] + "'", ref DBUtility.ClsPub.sExeReturnInfo);
|
}
|
|
oCN.Commit();
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "[0000-1-008]删除成功";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "[0000-1-045]单据未找到";
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
catch (Exception e)
|
{
|
oCN.RollBack();
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "[0000-1-007]" + e.Message;
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
}
|
#endregion
|
|
#region 客户标签档案重新生成
|
[Route("Sc_CustomerTagBarCode/ReSave")]
|
[HttpGet]
|
public object BarCodeReSave(string HICMOInterID, string HICMOEntryID, string HSerialNum)
|
{
|
try
|
{
|
|
if (HICMOInterID == null || HICMOInterID.Equals("") || HICMOEntryID == null || HICMOEntryID.Equals("") || HSerialNum == null || HSerialNum.Equals(""))
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "订单信息不全!HICMOInterID:" + HICMOInterID + ",HICMOEntryID:" + HICMOEntryID + ",HSerialNum:" + HSerialNum;
|
objJsonResult.data = ds.Tables[0];
|
return objJsonResult;
|
}
|
else
|
{
|
ds = oCN.RunProcReturn("exec h_p_Sc_CustomerTagBarCode_AutoReSave " + HICMOInterID + "," + HICMOEntryID + "," + HSerialNum, "h_p_Sc_CustomerTagBarCode_AutoReSave");
|
}
|
|
if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
|
{
|
objJsonResult.code = "0";
|
objJsonResult.count = 0;
|
objJsonResult.Message = "失败!" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
|
objJsonResult.data = null;
|
return objJsonResult;
|
}
|
else
|
{
|
objJsonResult.code = "1";
|
objJsonResult.count = 1;
|
objJsonResult.Message = "Sucess!";
|
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
|
|
}
|
}
|