You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2519 lines
114 KiB
C#
2519 lines
114 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using DSWeb.MvcContainer.Models.MsOpCtnTkFitings;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
using DSWeb.Areas.CommMng.Models;
|
|
using HcUtility.Comm;
|
|
using DSWeb.MvcShipping.DAL.MsBaseInfoDAL;
|
|
using DSWeb.EntityDA;
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
using DSWeb.MvcContainer.DAL.MsOpCtnBsCard;
|
|
using DSWeb.MvcContainer.Models.MsOpCtnBsCard;
|
|
|
|
namespace DSWeb.MvcContainer.DAL.MsOpCtnTkFitings
|
|
{
|
|
public class MsOpCtnTkFitingsDAL
|
|
{
|
|
#region Inquery DataList
|
|
|
|
static public List<OpCtnTkFitings> GetDataList(string strCondition,string sort = null)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT GID,BSNO,CUSTOMERNAME,OPTYPE,OPDATE,OPDATE2,BSSTATUS,YARD,DESTYARD,REMARK,CREATEUSER,CREATETIME");
|
|
strSql.Append(",MODIFIEDUSER,SUBMITUSER,SUBMITTIME,MODIFIEDTIME,AUDITUSER,AUDITTIME,REASON ");
|
|
strSql.Append(",(select ShowName from [user] where GID=b.CREATEUSER) as CREATEUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=b.MODIFIEDUSER) as MODIFIEDUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=b.SUBMITUSER) as SUBMITUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=b.AUDITUSER) as AUDITUSERREF");
|
|
strSql.Append(" from op_ctntkFiting b ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else {
|
|
strSql.Append(" order by CREATETIME DESC ");
|
|
|
|
}
|
|
return SetData(strSql);
|
|
}
|
|
static public List<OpCtnTkFitings> GetAuditDataList(string strCondition, string sort = null)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT b.GID,b.BSNO,b.CUSTOMERNAME,b.OPTYPE,b.OPDATE,b.OPDATE2,b.BSSTATUS,b.YARD,b.DESTYARD,b.REMARK,b.CREATEUSER,b.CREATETIME");
|
|
strSql.Append(",b.MODIFIEDUSER,b.SUBMITUSER,b.SUBMITTIME,b.MODIFIEDTIME,b.AUDITUSER,b.AUDITTIME,b.REASON ");
|
|
strSql.Append(",(select ShowName from [user] where GID=b.CREATEUSER) as CREATEUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=b.MODIFIEDUSER) as MODIFIEDUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=b.SUBMITUSER) as SUBMITUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=b.AUDITUSER) as AUDITUSERREF");
|
|
strSql.Append(" from op_ctntkFiting b left join workflow_using wu on wu.bsno=b.GID ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by b.CREATETIME DESC ");
|
|
|
|
}
|
|
return SetData(strSql);
|
|
}
|
|
|
|
static public string GetDataListStr(string strCondition, string sort = null)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT GID,BSNO,CUSTOMERNAME,OPTYPE,OPDATE,OPDATE2,BSSTATUS,YARD,DESTYARD,REMARK,CREATEUSER,CREATETIME");
|
|
strSql.Append(",MODIFIEDUSER,SUBMITUSER,SUBMITTIME,MODIFIEDTIME,AUDITUSER,AUDITTIME,REASON ");
|
|
strSql.Append(",(select ShowName from [user] where GID=b.CREATEUSER) as CREATEUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=b.MODIFIEDUSER) as MODIFIEDUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=b.SUBMITUSER) as SUBMITUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=b.AUDITUSER) as AUDITUSERREF");
|
|
strSql.Append(" from op_ctntkFiting b ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by CREATETIME DESC ");
|
|
|
|
}
|
|
return strSql.ToString();
|
|
}
|
|
|
|
static public OpCtnTkFitings GetData(string condition)
|
|
{
|
|
OpCtnTkFitings data = null;
|
|
var list = GetDataList(condition);
|
|
if (list.Count > 0)
|
|
data = list[0];
|
|
|
|
if (data == null)
|
|
{
|
|
data = new OpCtnTkFitings();
|
|
//data.COMPANYID = companyid;
|
|
|
|
}
|
|
|
|
return data;
|
|
}
|
|
static public OpCtnTkFitings GetData(string condition,string userid)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT GID,BSNO,CUSTOMERNAME,OPTYPE,OPDATE,OPDATE2,BSSTATUS,YARD,DESTYARD,REMARK,CREATEUSER,CREATETIME");
|
|
strSql.Append(",MODIFIEDUSER,SUBMITUSER,SUBMITTIME,MODIFIEDTIME,AUDITUSER,AUDITTIME,REASON ");
|
|
strSql.Append(",(select ShowName from [user] where GID=b.CREATEUSER) as CREATEUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=b.MODIFIEDUSER) as MODIFIEDUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=b.SUBMITUSER) as SUBMITUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=b.AUDITUSER) as AUDITUSERREF");
|
|
strSql.Append(" from op_ctntkFiting b ");
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
strSql.Append(" where " + condition);
|
|
}
|
|
|
|
var list = SetData(strSql);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
return new OpCtnTkFitings();
|
|
}
|
|
|
|
private static List<OpCtnTkFitings> SetData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<OpCtnTkFitings>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
OpCtnTkFitings data = new OpCtnTkFitings();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
|
|
data.BSSTATUS = Convert.ToString(reader["BSSTATUS"]);
|
|
data.OPTYPE = Convert.ToString(reader["OPTYPE"]);
|
|
if (reader["OPDATE"] != DBNull.Value)
|
|
data.OPDATE = Convert.ToDateTime(reader["OPDATE"]).ToString("yyyy-MM-dd");
|
|
if (reader["OPDATE2"] != DBNull.Value)
|
|
data.OPDATE2 = Convert.ToDateTime(reader["OPDATE2"]).ToString("yyyy-MM-dd");
|
|
data.YARD = Convert.ToString(reader["YARD"]);
|
|
data.DESTYARD = Convert.ToString(reader["DESTYARD"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
|
|
data.CREATEUSERREF = Convert.ToString(reader["CREATEUSERREF"]);
|
|
if (reader["CREATETIME"] != DBNull.Value)
|
|
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
data.MODIFIEDUSER = Convert.ToString(reader["MODIFIEDUSER"]);
|
|
data.MODIFIEDUSERREF = Convert.ToString(reader["MODIFIEDUSERREF"]);
|
|
if (reader["MODIFIEDTIME"] != DBNull.Value)
|
|
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
data.SUBMITUSER = Convert.ToString(reader["SUBMITUSER"]);
|
|
data.SUBMITUSERREF = Convert.ToString(reader["SUBMITUSERREF"]);
|
|
if (reader["SUBMITTIME"] != DBNull.Value)
|
|
data.SUBMITTIME = Convert.ToDateTime(reader["SUBMITTIME"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
data.AUDITUSER = Convert.ToString(reader["AUDITUSER"]);
|
|
data.AUDITUSERREF = Convert.ToString(reader["AUDITUSERREF"]);
|
|
if (reader["AUDITTIME"] != DBNull.Value)
|
|
data.AUDITTIME = Convert.ToDateTime(reader["AUDITTIME"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
data.REASON = Convert.ToString(reader["REASON"]);
|
|
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
|
|
|
|
public static DBResult SubmitAuditBillNew(OpCtnTkFitings head, string userid)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
result.Success = true;
|
|
var msg = "";
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
if (head.OPTYPE == "采购") {
|
|
var _Comm = "update op_ctntkFiting set BSSTATUS='锁定' where GID=@GID";
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, head.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
result.Message2 = "1";
|
|
|
|
}
|
|
else
|
|
if (head.OPTYPE == "调拨"|| head.OPTYPE == "报损")
|
|
{
|
|
|
|
var tmpWorkFlowName = "CtnTkFitingsDb";
|
|
if (head.OPTYPE == "报损") tmpWorkFlowName = "CtnTkFitingsBs";
|
|
Resultmb WorkResult = WorkFlowDAL.WorkFlowStart(tmpWorkFlowName, head.GID, userid, head.BSNO, "", "","");
|
|
if (WorkResult.Success == true)
|
|
{
|
|
if (WorkResult.islast == true)
|
|
{
|
|
if (head.OPTYPE == "报损")
|
|
{
|
|
var _Comm = "update op_ctntkFiting set BSSTATUS='确认报损',SUBMITUSER='" + userid + "',SUBMITTIME=GETDATE(),AUDITUSER='" + userid + "',AUDITTIME=GETDATE() where GID=@GID";
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, head.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
}
|
|
else
|
|
{
|
|
var _Comm = "update op_ctntkFiting set BSSTATUS='确认调拨',SUBMITUSER='" + userid + "',SUBMITTIME=GETDATE(),AUDITUSER='" + userid + "',AUDITTIME=GETDATE() where GID=@GID";
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, head.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
}
|
|
result.Message2 = "1";
|
|
}
|
|
else
|
|
{
|
|
if (head.OPTYPE == "报损")
|
|
{
|
|
var _Comm = "update op_ctntkFiting set BSSTATUS='提交报损',SUBMITUSER='"+userid+ "',SUBMITTIME=GETDATE() where GID=@GID";
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, head.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
}
|
|
else
|
|
{
|
|
var _Comm = "update op_ctntkFiting set BSSTATUS='提交调拨',SUBMITUSER='" + userid + "',SUBMITTIME=GETDATE() where GID=@GID";
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, head.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
result.Success = false;
|
|
result.Message = "提交审核错误!";
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.Success = true;
|
|
result.Message = "提交审核成功";
|
|
result.Data = msg;
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "提交审核错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
public static DBResult CancelAuditBill(OpCtnTkFitings head, String USERID)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
var WorkFlowName = "PriceProjectAudit";
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update op_ctntkFiting set BSSTATUS='未提交' where GID=@GID");
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, head.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
var cmduDelete = db.GetSqlStringCommand("delete from op_ctntkFiting_detail where LINKGID IN (SELECT GID FROM op_ctntkFiting_body where LINKGID=@GID)");
|
|
|
|
|
|
cmduDelete.Parameters.Clear();
|
|
db.AddInParameter(cmduDelete, "@GID", DbType.String, head.GID);
|
|
db.ExecuteNonQuery(cmduDelete, tran);
|
|
|
|
|
|
//var saleid = "";
|
|
|
|
// if (saleid == "") saleid = USERID;
|
|
|
|
// Resultmb WorkResult = WorkFlowDAL.WorkFlowReset(WorkFlowName, GID, saleid);
|
|
// if (WorkResult.Success == true)
|
|
// {
|
|
// var cmdupdate = db.GetSqlStringCommand("update op_price set BSSTATUS='未提交',AUDITOPERATOR='',AUDITDATE=null where GID=@GID");
|
|
|
|
|
|
// cmdupdate.Parameters.Clear();
|
|
// db.AddInParameter(cmdupdate, "@GID", DbType.String, GID);
|
|
// db.ExecuteNonQuery(cmdupdate, tran);
|
|
// }
|
|
// else
|
|
// {
|
|
// result.Success = false;
|
|
// result.Message = "撤销提交错误!";
|
|
// }
|
|
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "撤销提交成功";
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "撤销提交错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
}
|
|
|
|
public static DBResult AuditBillList(List<OpCtnTkFitings> billList, string userid)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
|
|
try
|
|
{
|
|
|
|
foreach (var bill in billList)
|
|
{
|
|
|
|
var WorkFlowName = "CtnTkFitingsDb";
|
|
if (bill.OPTYPE == "报损") WorkFlowName = "CtnTkFitingsBs";
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
|
|
Resultmb WorkResult = WorkFlowDAL.InsertWorkFlowDo(WorkFlowName, bill.GID, userid, tran, "", bill.GID, "");
|
|
|
|
if (WorkResult.Success == true)
|
|
{
|
|
try
|
|
{
|
|
|
|
if (WorkResult.islast == true)
|
|
{
|
|
if (bill.OPTYPE == "报损")
|
|
{
|
|
var _Comm = "update op_ctntkFiting set BSSTATUS='确认报损',AUDITUSER='" + userid + "',AUDITTIME=GETDATE() where GID=@GID";
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, bill.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
bill.BSSTATUS = "确认报损";
|
|
}
|
|
else
|
|
{
|
|
var _Comm = "update op_ctntkFiting set BSSTATUS='确认调拨',AUDITUSER='" + userid + "',AUDITTIME=GETDATE() where GID=@GID";
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, bill.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
bill.BSSTATUS = "确认调拨";
|
|
}
|
|
result.Message2 = "1";
|
|
}
|
|
else
|
|
{
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update op_ctntkFiting set AUDITUSER='" + userid + "',AUDITTIME=GETDATE() where GID=@GID");
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, bill.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
result.Success = false;
|
|
result.Message = "审核错误!<" + WorkResult.Message + ">";
|
|
tran.Rollback();
|
|
}
|
|
if (bill.BSSTATUS == "确认报损" || bill.BSSTATUS == "确认调拨") {
|
|
|
|
SaveCgFitingsDetail(bill, bill.OPTYPE,userid);
|
|
UpdateFitingsKc();
|
|
}
|
|
|
|
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "审核成功";
|
|
tran.Commit();
|
|
}
|
|
else
|
|
{
|
|
result.Success = false;
|
|
result.Message = "审核错误!<" + WorkResult.Message + ">";
|
|
tran.Rollback();
|
|
//return result;
|
|
}
|
|
//}
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
//tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "审核错误<" + e.Message + ">,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public static DBResult AuditBillDbOverList(List<OpCtnTkFitings> billList,string OPDATE2,string userid)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
|
|
try
|
|
{
|
|
|
|
foreach (var bill in billList)
|
|
{
|
|
|
|
var tran = conn.BeginTransaction();
|
|
|
|
var _Comm = "update op_ctntkFiting set BSSTATUS='调拨完成', OPDATE2='"+OPDATE2+"',MODIFIEDUSER='" + userid + "',MODIFIEDTIME=GETDATE() where GID=@GID";
|
|
var cmdupdate = db.GetSqlStringCommand(_Comm);
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, bill.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
bill.BSSTATUS = "调拨完成";
|
|
result.Success = true;
|
|
result.Message = "调拨完成";
|
|
tran.Commit();
|
|
|
|
|
|
SaveCgFitingsDetail(bill,"调入", userid);
|
|
UpdateFitingsKc();
|
|
|
|
//}
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
//tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "审核错误<" + e.Message + ">,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public static DBResult AuditBillBack(List<OpCtnTkFitings> billList, String USERID, string reasean, string companyid)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
|
|
var i = 0;
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
var mblno = "";
|
|
result.Success = true;
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
foreach (var bill in billList)
|
|
{
|
|
|
|
Resultmb WorkResult = null;
|
|
var WorkFlowName = "CtnTkFitingsDb";
|
|
if (bill.OPTYPE == "报损") WorkFlowName = "CtnTkFitingsBs";
|
|
|
|
|
|
var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select count(*) BLCOUNT from workflow_using WHERE BSNO='" + bill.GID + "'");
|
|
|
|
if (BLCOUNT != "0")
|
|
{
|
|
WorkResult = WorkFlowDAL.DeleteWorkFlowDo(WorkFlowName, bill.GID, USERID, reasean, mblno, bill.GID, "", "");
|
|
}
|
|
|
|
if (BLCOUNT == "0" || WorkResult.Success == true)
|
|
{
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update op_ctntkFiting set BSSTATUS='驳回提交',REASON='" + reasean + "' where GID=@GID");
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, bill.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
var cmduDelete = db.GetSqlStringCommand("delete from op_ctntkFiting_detail where LINKGID IN (SELECT GID FROM op_ctntkFiting_body where LINKGID=@GID)");
|
|
|
|
|
|
cmduDelete.Parameters.Clear();
|
|
db.AddInParameter(cmduDelete, "@GID", DbType.String, bill.GID);
|
|
db.ExecuteNonQuery(cmduDelete, tran);
|
|
result.Message2 = "1";
|
|
|
|
}
|
|
else
|
|
{
|
|
i = i + 1;
|
|
result.Success = WorkResult.Success;
|
|
result.Message = WorkResult.Message;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if (result.Success == true)
|
|
{
|
|
|
|
result.Success = true;
|
|
result.Message = "驳回提交成功";
|
|
tran.Commit();
|
|
}
|
|
else
|
|
{
|
|
result.Success = true;
|
|
result.Message = "驳回完成,其中" + i.ToString() + "票驳回错误,错误信息" + result.Message;
|
|
|
|
tran.Commit();
|
|
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "驳回提交错误,请重试或联系系统管理员" + e.Message;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
}
|
|
|
|
public static DBResult SetStop(List<OpCtnTkFitings> billList,string userid,string isstop)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
var i = 0;
|
|
var mblno = "";
|
|
result.Success = true;
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
foreach (var bill in billList)
|
|
{
|
|
|
|
|
|
var cmdupdate = db.GetSqlStringCommand("update op_price set ISSTOP='"+ isstop + "' where GID=@GID");
|
|
|
|
|
|
cmdupdate.Parameters.Clear();
|
|
db.AddInParameter(cmdupdate, "@GID", DbType.String, bill.GID);
|
|
db.ExecuteNonQuery(cmdupdate, tran);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
if (result.Success == true)
|
|
{
|
|
result = new DBResult();
|
|
result.Success = true;
|
|
result.Message = "提交成功";
|
|
tran.Commit();
|
|
}
|
|
else
|
|
{
|
|
result.Success = true;
|
|
result.Message = "完成,其中" + i.ToString() + "票驳回错误,错误信息" + result.Message;
|
|
|
|
tran.Commit();
|
|
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "提交错误,请重试或联系系统管理员" + e.Message;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
}
|
|
|
|
public static DBResult DeleteOpCtnTkFitings(List<OpCtnTkFitings> headData)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
if (headData != null)
|
|
{
|
|
foreach (var enumValue in headData)
|
|
{
|
|
|
|
var cmdDelete = db.GetSqlStringCommand("delete from op_ctntkFiting where GID='" + enumValue.GID + "'");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
}
|
|
}
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "删除出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "删除成功";
|
|
|
|
return result;
|
|
}
|
|
|
|
public static bool GetBodyCount(string BSNO)
|
|
{
|
|
var isfee = false;
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("Select count(*) as count ");
|
|
strSql.Append(" from op_ctntkFiting_body ");
|
|
strSql.Append(" where LINKGID='" + BSNO + "'");
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
var evData = Convert.ToInt32(reader["count"]);
|
|
if (evData > 0) { isfee = true; };
|
|
}
|
|
reader.Close();
|
|
}
|
|
return isfee;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region FitingsDetail
|
|
|
|
|
|
|
|
static public List<OpCtnTkFitingsDetail> GetFitingsDetailList(string strCondition, string sort = null)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT GID,[LINKGID],[FITINGGID],[FITINGCODE],[FITINGNAME],[CTNGID],[CTNNO],[MODEL],DSTATUS");
|
|
strSql.Append(",[WMSTYPE],[OPDATE],[YARD],[PKGS],[NPKGS],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME]");
|
|
strSql.Append(",(select ShowName from [user] where GID=op_ctntkFiting_detail.CREATEUSER) as CREATEUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=op_ctntkFiting_detail.MODIFIEDUSER) as MODIFIEDUSERREF");
|
|
|
|
strSql.Append(" from op_ctntkFiting_detail ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by CREATETIME DESC");
|
|
|
|
}
|
|
return SetFitingsDetailData(strSql);
|
|
}
|
|
|
|
|
|
static public string GetFitingsDetailListStr(string strCondition, string sort = null)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT GID,[LINKGID],[FITINGGID],[FITINGCODE],[FITINGNAME],[CTNGID],[CTNNO],[MODEL],DSTATUS");
|
|
strSql.Append(",[WMSTYPE],[OPDATE],[YARD],[PKGS],[NPKGS],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME]");
|
|
strSql.Append(",(select ShowName from [user] where GID=op_ctntkFiting_detail.CREATEUSER) as CREATEUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=op_ctntkFiting_detail.MODIFIEDUSER) as MODIFIEDUSERREF");
|
|
|
|
strSql.Append(" from op_ctntkFiting_detail ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by CREATETIME DESC");
|
|
|
|
}
|
|
return strSql.ToString();
|
|
}
|
|
|
|
|
|
static public OpCtnTkFitingsDetail GetOpFitingsDetailData(string condition, string userid)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT GID,[LINKGID],[FITINGGID],[FITINGCODE],[FITINGNAME],[CTNGID],[CTNNO],[MODEL],DSTATUS");
|
|
strSql.Append(",[WMSTYPE],[OPDATE],[YARD],[PKGS],[NPKGS],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME]");
|
|
strSql.Append(",(select ShowName from [user] where GID=op_ctntkFiting_detail.CREATEUSER) as CREATEUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=op_ctntkFiting_detail.MODIFIEDUSER) as MODIFIEDUSERREF");
|
|
|
|
strSql.Append(" from op_ctntkFiting_detail ");
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
strSql.Append(" where " + condition);
|
|
}
|
|
|
|
var list = SetFitingsDetailData(strSql);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
return new OpCtnTkFitingsDetail();
|
|
}
|
|
|
|
private static List<OpCtnTkFitingsDetail> SetFitingsDetailData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<OpCtnTkFitingsDetail>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
OpCtnTkFitingsDetail data = new OpCtnTkFitingsDetail();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.LINKGID = Convert.ToString(reader["LINKGID"]);
|
|
data.FITINGGID = Convert.ToString(reader["FITINGGID"]);
|
|
data.FITINGCODE = Convert.ToString(reader["FITINGCODE"]);
|
|
data.FITINGNAME = Convert.ToString(reader["FITINGNAME"]);
|
|
data.CTNGID = Convert.ToString(reader["CTNGID"]);
|
|
data.CTNNO = Convert.ToString(reader["CTNNO"]);
|
|
data.MODEL = Convert.ToString(reader["MODEL"]);
|
|
data.DSTATUS = Convert.ToString(reader["DSTATUS"]);
|
|
|
|
if (reader["PKGS"] != DBNull.Value)
|
|
data.PKGS = Convert.ToDecimal(reader["PKGS"]);
|
|
if (reader["NPKGS"] != DBNull.Value)
|
|
data.NPKGS = Convert.ToDecimal(reader["NPKGS"]);
|
|
data.WMSTYPE = Convert.ToString(reader["WMSTYPE"]);
|
|
if (reader["OPDATE"] != DBNull.Value)
|
|
data.OPDATE = Convert.ToDateTime(reader["OPDATE"]).ToString("yyyy-MM-dd");
|
|
data.YARD = Convert.ToString(reader["YARD"]);
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
|
|
data.CREATEUSERREF = Convert.ToString(reader["CREATEUSERREF"]);
|
|
if (reader["CREATETIME"] != DBNull.Value)
|
|
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
data.MODIFIEDUSER = Convert.ToString(reader["MODIFIEDUSER"]);
|
|
data.MODIFIEDUSERREF = Convert.ToString(reader["MODIFIEDUSERREF"]);
|
|
if (reader["MODIFIEDTIME"] != DBNull.Value)
|
|
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
|
|
|
|
public static DBResult SaveCgFitingsDetail(OpCtnTkFitings HeadData,string OPTYPE,string userid)
|
|
{
|
|
var result = new DBResult();
|
|
var bodyList = GetFitingsBodyList("LINKGID='"+HeadData.GID+"'",OPTYPE);
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into op_ctntkFiting_detail (GID,[LINKGID],[FITINGGID],[FITINGCODE],[FITINGNAME],[CTNGID],[CTNNO],[MODEL]
|
|
,[WMSTYPE],[OPDATE],[YARD],[PKGS],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME])
|
|
values (@GID,@LINKGID,@FITINGGID,@FITINGCODE,@FITINGNAME,@CTNGID,@CTNNO,@MODEL
|
|
,@WMSTYPE,@OPDATE,@YARD,@PKGS,@REMARK,@CREATEUSER,@CREATETIME,@MODIFIEDUSER,@MODIFIEDTIME) ");
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"update op_ctntkFiting_detail set FITINGGID=@FITINGGID,FITINGCODE=@FITINGCODE,FITINGNAME=@FITINGNAME,CTNGID=@CTNGID,CTNNO=@CTNNO,MODEL=@MODEL,
|
|
WMSTYPE=@WMSTYPE,OPDATE=@OPDATE,YARD=@YARD,PKGS=@PKGS,REMARK=@REMARK,MODIFIEDUSER=@MODIFIEDUSER,MODIFIEDTIME=@MODIFIEDTIME where GID=@GID ");
|
|
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(enumValue.DETAILGID))
|
|
{
|
|
cmdInsert.Parameters.Clear();
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsert, "@LINKGID", DbType.String, enumValue.GID);
|
|
db.AddInParameter(cmdInsert, "@FITINGGID", DbType.String, enumValue.FITINGGID);
|
|
db.AddInParameter(cmdInsert, "@FITINGCODE", DbType.String, enumValue.FITINGCODE);
|
|
db.AddInParameter(cmdInsert, "@FITINGNAME", DbType.String, enumValue.FITINGNAME);
|
|
db.AddInParameter(cmdInsert, "@CTNGID", DbType.String,"");
|
|
db.AddInParameter(cmdInsert, "@CTNNO", DbType.String,"");
|
|
db.AddInParameter(cmdInsert, "@MODEL", DbType.String, enumValue.MODEL);
|
|
db.AddInParameter(cmdInsert, "@WMSTYPE", DbType.String, OPTYPE);
|
|
if (string.IsNullOrEmpty(HeadData.OPDATE))
|
|
db.AddInParameter(cmdInsert, "@OPDATE", DbType.String, null);
|
|
else
|
|
db.AddInParameter(cmdInsert, "@OPDATE", DbType.String, HeadData.OPDATE);
|
|
if (HeadData.BSSTATUS == "调拨完成")
|
|
db.AddInParameter(cmdInsert, "@YARD", DbType.String, HeadData.DESTYARD);
|
|
else
|
|
db.AddInParameter(cmdInsert, "@YARD", DbType.String, HeadData.YARD);
|
|
|
|
if (HeadData.OPTYPE=="采购"|| (HeadData.OPTYPE == "调拨"&&HeadData.BSSTATUS=="调拨完成"))
|
|
db.AddInParameter(cmdInsert, "@PKGS", DbType.Decimal, enumValue.PKGS);
|
|
else
|
|
db.AddInParameter(cmdInsert, "@PKGS", DbType.Decimal, -enumValue.PKGS);
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdInsert, "@CREATEUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsert, "@CREATETIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
}
|
|
else
|
|
{
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.DETAILGID);
|
|
db.AddInParameter(cmdUpdate, "@FITINGGID", DbType.String, enumValue.FITINGGID);
|
|
db.AddInParameter(cmdUpdate, "@FITINGCODE", DbType.String, enumValue.FITINGCODE);
|
|
db.AddInParameter(cmdUpdate, "@FITINGNAME", DbType.String, enumValue.FITINGNAME);
|
|
db.AddInParameter(cmdUpdate, "@CTNGID", DbType.String, "");
|
|
db.AddInParameter(cmdUpdate, "@CTNNO", DbType.String,"");
|
|
db.AddInParameter(cmdUpdate, "@MODEL", DbType.String, enumValue.MODEL);
|
|
db.AddInParameter(cmdUpdate, "@WMSTYPE", DbType.String, OPTYPE);
|
|
if (string.IsNullOrEmpty(HeadData.OPDATE))
|
|
db.AddInParameter(cmdUpdate, "@OPDATE", DbType.String, null);
|
|
else
|
|
db.AddInParameter(cmdUpdate, "@OPDATE", DbType.String, HeadData.OPDATE);
|
|
if (HeadData.BSSTATUS == "调拨完成")
|
|
db.AddInParameter(cmdUpdate, "@YARD", DbType.String, HeadData.DESTYARD);
|
|
else
|
|
db.AddInParameter(cmdUpdate, "@YARD", DbType.String, HeadData.YARD);
|
|
|
|
if (HeadData.OPTYPE == "采购" || HeadData.BSSTATUS == "调拨完成")
|
|
db.AddInParameter(cmdUpdate, "@PKGS", DbType.Decimal, enumValue.PKGS);
|
|
else
|
|
db.AddInParameter(cmdUpdate, "@PKGS", DbType.Decimal, -enumValue.PKGS);
|
|
db.AddInParameter(cmdUpdate, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdUpdate, "@MODIFIEDUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdUpdate, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员"+e.Message;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
public static DBResult SaveFitingsDetail(OpCtnBsCard opctnbscard, List<OpCtnTkFitingsDetail> bodyList, string LINKGID, string userid)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
var CtnKcList = GetFitingsCtnKcList("F.CTNGID='" + opctnbscard.CTNGID + "'");
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into op_ctntkFiting_detail (GID,[LINKGID],[FITINGGID],[FITINGCODE],[FITINGNAME],[CTNGID],[CTNNO],[MODEL]
|
|
,[WMSTYPE],[OPDATE],[YARD],[PKGS],[NPKGS],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],DSTATUS)
|
|
values (@GID,@LINKGID,@FITINGGID,@FITINGCODE,@FITINGNAME,@CTNGID,@CTNNO,@MODEL
|
|
,@WMSTYPE,@OPDATE,@YARD,@PKGS,@NPKGS,@REMARK,@CREATEUSER,@CREATETIME,@MODIFIEDUSER,@MODIFIEDTIME,@DSTATUS) ");
|
|
|
|
// var cmdInsertCtnFitings =
|
|
//db.GetSqlStringCommand(
|
|
// @"insert into code_ctntk_Fiting (GID,[LINKGID],BODYGID,[FITINGGID],[FITINGCODE],[FITINGNAME],[MODEL]
|
|
// ,[OPDATE],[YARD],[PKGS],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME])
|
|
// values (@GID,@LINKGID,@BODYGID,@FITINGGID,@FITINGCODE,@FITINGNAME,@MODEL
|
|
// ,@OPDATE,@YARD,@PKGS,@REMARK,@CREATEUSER,@CREATETIME,@MODIFIEDUSER,@MODIFIEDTIME) ");
|
|
|
|
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
cmdInsert.Parameters.Clear();
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsert, "@LINKGID", DbType.String, LINKGID);
|
|
db.AddInParameter(cmdInsert, "@FITINGGID", DbType.String, enumValue.FITINGGID);
|
|
db.AddInParameter(cmdInsert, "@FITINGCODE", DbType.String, enumValue.FITINGCODE);
|
|
db.AddInParameter(cmdInsert, "@FITINGNAME", DbType.String, enumValue.FITINGNAME);
|
|
db.AddInParameter(cmdInsert, "@CTNGID", DbType.String, opctnbscard.CTNGID);
|
|
db.AddInParameter(cmdInsert, "@CTNNO", DbType.String, opctnbscard.CTNNO);
|
|
db.AddInParameter(cmdInsert, "@MODEL", DbType.String, enumValue.MODEL);
|
|
db.AddInParameter(cmdInsert, "@WMSTYPE", DbType.String, enumValue.WMSTYPE);
|
|
db.AddInParameter(cmdInsert, "@OPDATE", DbType.String, enumValue.OPDATE);
|
|
db.AddInParameter(cmdInsert, "@YARD", DbType.String, enumValue.YARD);
|
|
|
|
if (enumValue.WMSTYPE == "拆")
|
|
db.AddInParameter(cmdInsert, "@PKGS", DbType.Decimal, enumValue.PKGS);
|
|
else if (enumValue.WMSTYPE == "装")
|
|
db.AddInParameter(cmdInsert, "@PKGS", DbType.Decimal, -enumValue.PKGS);
|
|
else if (enumValue.WMSTYPE == "损坏")
|
|
db.AddInParameter(cmdInsert, "@PKGS", DbType.Decimal, 0);
|
|
db.AddInParameter(cmdInsert, "@NPKGS", DbType.Decimal, enumValue.PKGS);
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdInsert, "@CREATEUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsert, "@CREATETIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
if (enumValue.WMSTYPE == "损坏")
|
|
db.AddInParameter(cmdInsert, "@DSTATUS", DbType.String,"提交审核");
|
|
else
|
|
db.AddInParameter(cmdInsert, "@DSTATUS", DbType.String, "");
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
if (enumValue.WMSTYPE != "损坏")
|
|
{
|
|
|
|
var ctnkc = CtnKcList.Find(x => x.FITINGGID == enumValue.FITINGGID);
|
|
if (ctnkc != null)
|
|
{
|
|
|
|
if (enumValue.WMSTYPE == "拆")
|
|
ctnkc.PKGS = ctnkc.PKGS - enumValue.PKGS;
|
|
else if (enumValue.WMSTYPE == "装")
|
|
ctnkc.PKGS = ctnkc.PKGS + enumValue.PKGS;
|
|
//else if (enumValue.WMSTYPE == "损坏")
|
|
// ctnkc.PKGS = ctnkc.PKGS - enumValue.PKGS;
|
|
}
|
|
else
|
|
{
|
|
var newctnck = new OpCtnTkFitingsDetail();
|
|
newctnck.GID = "*";
|
|
newctnck.CTNGID = opctnbscard.CTNGID;
|
|
newctnck.FITINGCODE = enumValue.FITINGCODE;
|
|
newctnck.FITINGGID = enumValue.FITINGGID;
|
|
newctnck.FITINGNAME = enumValue.FITINGNAME;
|
|
newctnck.MODEL = enumValue.MODEL;
|
|
if (enumValue.WMSTYPE == "拆")
|
|
newctnck.PKGS = -enumValue.PKGS;
|
|
else if (enumValue.WMSTYPE == "装")
|
|
newctnck.PKGS = enumValue.PKGS;
|
|
//else if (enumValue.WMSTYPE == "损坏")
|
|
// newctnck.PKGS =- enumValue.PKGS;
|
|
CtnKcList.Add(newctnck);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
//if (enumValue.WMSTYPE == "装")
|
|
//{
|
|
// cmdInsertCtnFitings.Parameters.Clear();
|
|
// db.AddInParameter(cmdInsertCtnFitings, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
// db.AddInParameter(cmdInsertCtnFitings, "@LINKGID", DbType.String, opctnbscard.CTNGID);
|
|
// db.AddInParameter(cmdInsertCtnFitings, "@FITINGGID", DbType.String, enumValue.FITINGGID);
|
|
// db.AddInParameter(cmdInsertCtnFitings, "@FITINGCODE", DbType.String, enumValue.FITINGCODE);
|
|
// db.AddInParameter(cmdInsertCtnFitings, "@FITINGNAME", DbType.String, enumValue.FITINGNAME);
|
|
// db.AddInParameter(cmdInsertCtnFitings, "@MODEL", DbType.String, enumValue.MODEL);
|
|
// db.AddInParameter(cmdInsertCtnFitings, "@OPDATE", DbType.String, enumValue.OPDATE);
|
|
// db.AddInParameter(cmdInsertCtnFitings, "@YARD", DbType.String, enumValue.YARD);
|
|
// if (enumValue.WMSTYPE == "拆")
|
|
// db.AddInParameter(cmdInsertCtnFitings, "@PKGS", DbType.Decimal, enumValue.PKGS);
|
|
// else
|
|
// db.AddInParameter(cmdInsertCtnFitings, "@PKGS", DbType.Decimal, -enumValue.PKGS);
|
|
// db.AddInParameter(cmdInsertCtnFitings, "@REMARK", DbType.String, enumValue.REMARK);
|
|
// db.AddInParameter(cmdInsertCtnFitings, "@CREATEUSER", DbType.String, userid);
|
|
// db.AddInParameter(cmdInsertCtnFitings, "@CREATETIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
// db.AddInParameter(cmdInsertCtnFitings, "@MODIFIEDUSER", DbType.String, userid);
|
|
// db.AddInParameter(cmdInsertCtnFitings, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
// db.ExecuteNonQuery(cmdInsertCtnFitings, tran);
|
|
//}
|
|
|
|
}
|
|
}
|
|
|
|
SaveFitingsCtnKc(CtnKcList);
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员"+e.Message;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
public static DBResult DeleteFitingsDetail(List<OpCtnTkFitingsDetail> headData)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
if (headData != null)
|
|
{
|
|
foreach (var enumValue in headData)
|
|
{
|
|
|
|
var cmdDelete = db.GetSqlStringCommand("delete from op_ctntkFiting_detail where GID='" + enumValue.GID + "'");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
}
|
|
}
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "删除出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "删除成功";
|
|
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region FitingsBody
|
|
|
|
static public List<OpCtnTkFitingsBody> GetFitingsBodyList(string strCondition, string optype="",string sort = null)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT GID,[LINKGID],[FITINGGID],[FITINGCODE],[FITINGNAME],[MODEL]");
|
|
strSql.Append(",[PKGS],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME]");
|
|
strSql.Append(",(select ShowName from [user] where GID=op_ctntkFiting_body.CREATEUSER) as CREATEUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=op_ctntkFiting_body.MODIFIEDUSER) as MODIFIEDUSERREF");
|
|
if (string.IsNullOrEmpty(optype))
|
|
{
|
|
strSql.Append(",isnull((select top 1 GID from op_ctntkFiting_detail where LINKGID=op_ctntkFiting_body.GID),'') as DETAILGID");
|
|
}
|
|
else {
|
|
strSql.Append(",isnull((select top 1 GID from op_ctntkFiting_detail where LINKGID=op_ctntkFiting_body.GID and WMSTYPE='"+optype+"'),'') as DETAILGID");
|
|
}
|
|
|
|
strSql.Append(" from op_ctntkFiting_body ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by CREATETIME DESC");
|
|
|
|
}
|
|
return SetFitingsBodyData(strSql);
|
|
}
|
|
|
|
|
|
static public string GetFitingsBodyListStr(string strCondition, string sort = null)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT GID,[LINKGID],[FITINGGID],[FITINGCODE],[FITINGNAME],[MODEL]");
|
|
strSql.Append(",[PKGS],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME]");
|
|
strSql.Append(",(select ShowName from [user] where GID=op_ctntkFiting_body.CREATEUSER) as CREATEUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=op_ctntkFiting_body.MODIFIEDUSER) as MODIFIEDUSERREF");
|
|
strSql.Append(",isnull((select top 1 GID from op_ctntkFiting_detail where LINKGID=op_ctntkFiting_body.GID),'') as DETAILGID");
|
|
|
|
strSql.Append(" from op_ctntkFiting_body ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by CREATETIME DESC");
|
|
|
|
}
|
|
return strSql.ToString();
|
|
}
|
|
|
|
|
|
static public OpCtnTkFitingsBody GetOpFitingsBodyData(string condition, string userid)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT GID,[LINKGID],[FITINGGID],[FITINGCODE],[FITINGNAME],[MODEL]");
|
|
strSql.Append(",[PKGS],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME]");
|
|
strSql.Append(",(select ShowName from [user] where GID=op_ctntkFiting_body.CREATEUSER) as CREATEUSERREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=op_ctntkFiting_body.MODIFIEDUSER) as MODIFIEDUSERREF");
|
|
strSql.Append(",isnull((select top 1 GID from op_ctntkFiting_detail where LINKGID=op_ctntkFiting_body.GID),'') as DETAILGID");
|
|
|
|
strSql.Append(" from op_ctntkFiting_body ");
|
|
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
strSql.Append(" where " + condition);
|
|
}
|
|
|
|
var list = SetFitingsBodyData(strSql);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
return new OpCtnTkFitingsBody();
|
|
}
|
|
|
|
private static List<OpCtnTkFitingsBody> SetFitingsBodyData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<OpCtnTkFitingsBody>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
OpCtnTkFitingsBody data = new OpCtnTkFitingsBody();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.LINKGID = Convert.ToString(reader["LINKGID"]);
|
|
data.FITINGGID = Convert.ToString(reader["FITINGGID"]);
|
|
data.FITINGCODE = Convert.ToString(reader["FITINGCODE"]);
|
|
data.FITINGNAME = Convert.ToString(reader["FITINGNAME"]);
|
|
data.MODEL = Convert.ToString(reader["MODEL"]);
|
|
if (reader["PKGS"] != DBNull.Value)
|
|
data.PKGS = Convert.ToDecimal(reader["PKGS"]);
|
|
|
|
data.REMARK = Convert.ToString(reader["REMARK"]);
|
|
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
|
|
data.CREATEUSERREF = Convert.ToString(reader["CREATEUSERREF"]);
|
|
if (reader["CREATETIME"] != DBNull.Value)
|
|
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
data.MODIFIEDUSER = Convert.ToString(reader["MODIFIEDUSER"]);
|
|
data.MODIFIEDUSERREF = Convert.ToString(reader["MODIFIEDUSERREF"]);
|
|
if (reader["MODIFIEDTIME"] != DBNull.Value)
|
|
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
data.DETAILGID = Convert.ToString(reader["DETAILGID"]);
|
|
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
public static DBResult SaveFitingsBody(List<OpCtnTkFitingsBody> bodyList, string PID, string userid)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into op_ctntkFiting_body (GID,[LINKGID],[FITINGGID],[FITINGCODE],[FITINGNAME],[MODEL]
|
|
,[PKGS],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME])
|
|
values (@GID,@LINKGID,@FITINGGID,@FITINGCODE,@FITINGNAME,@MODEL
|
|
,@PKGS,@REMARK,@CREATEUSER,@CREATETIME,@MODIFIEDUSER,@MODIFIEDTIME) ");
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"update op_ctntkFiting_body set FITINGGID=@FITINGGID,FITINGCODE=@FITINGCODE,FITINGNAME=@FITINGNAME,MODEL=@MODEL,
|
|
PKGS=@PKGS,REMARK=@REMARK,MODIFIEDUSER=@MODIFIEDUSER,MODIFIEDTIME=@MODIFIEDTIME where GID=@GID ");
|
|
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
|
|
|
|
|
|
if (enumValue.LINKGID == "*" || enumValue.LINKGID == "")
|
|
{
|
|
cmdInsert.Parameters.Clear();
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsert, "@LINKGID", DbType.String, PID);
|
|
db.AddInParameter(cmdInsert, "@FITINGGID", DbType.String, enumValue.FITINGGID);
|
|
db.AddInParameter(cmdInsert, "@FITINGCODE", DbType.String, enumValue.FITINGCODE);
|
|
db.AddInParameter(cmdInsert, "@FITINGNAME", DbType.String, enumValue.FITINGNAME);
|
|
db.AddInParameter(cmdInsert, "@MODEL", DbType.String, enumValue.MODEL);
|
|
db.AddInParameter(cmdInsert, "@PKGS", DbType.Decimal, enumValue.PKGS);
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdInsert, "@CREATEUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsert, "@CREATETIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
}
|
|
else
|
|
{
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
|
|
db.AddInParameter(cmdUpdate, "@FITINGGID", DbType.String, enumValue.FITINGGID);
|
|
db.AddInParameter(cmdUpdate, "@FITINGCODE", DbType.String, enumValue.FITINGCODE);
|
|
db.AddInParameter(cmdUpdate, "@FITINGNAME", DbType.String, enumValue.FITINGNAME);
|
|
db.AddInParameter(cmdUpdate, "@MODEL", DbType.String, enumValue.MODEL);
|
|
db.AddInParameter(cmdUpdate, "@PKGS", DbType.Decimal, enumValue.PKGS);
|
|
db.AddInParameter(cmdUpdate, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdUpdate, "@MODIFIEDUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdUpdate, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception E)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员"+E.Message;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
public static DBResult DeleteFitingsBody(List<OpCtnTkFitingsBody> headData)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
if (headData != null)
|
|
{
|
|
foreach (var enumValue in headData)
|
|
{
|
|
|
|
var cmdDelete = db.GetSqlStringCommand("delete from op_ctntkFiting_body where GID='" + enumValue.GID + "'");
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
}
|
|
}
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "删除出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "删除成功";
|
|
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region FitingsKc
|
|
|
|
static public List<OpCtnTkFitingsKc> GetFitingsKcList(string strCondition, string sort = null)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT GID,[FITINGGID],[FITINGCODE],[FITINGNAME],[MODEL]");
|
|
strSql.Append(",[PKGS],[YARD]");
|
|
strSql.Append(",(FITINGCODE+'-'+FITINGNAME+'-'+MODEL) as FITINGFULL");
|
|
|
|
strSql.Append(" from op_ctntkFiting_kc ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by FITINGNAME ");
|
|
|
|
}
|
|
return SetFitingsKcData(strSql);
|
|
}
|
|
|
|
|
|
static public string GetFitingsKcListStr(string strCondition, string sort = null)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT GID,[FITINGGID],[FITINGCODE],[FITINGNAME],[MODEL]");
|
|
strSql.Append(",[PKGS],[YARD]");
|
|
strSql.Append(",(FITINGNAME+'-'+MODEL) as FITINGFULL");
|
|
|
|
strSql.Append(" from op_ctntkFiting_kc ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by FITINGNAME");
|
|
|
|
}
|
|
return strSql.ToString();
|
|
}
|
|
|
|
static public List<OpCtnTkFitingsKc> GetFitingsKcSum()
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT '' GID,[FITINGGID],[FITINGCODE],[FITINGNAME],[MODEL]");
|
|
strSql.Append(",sum([PKGS]) PKGS,[YARD]");
|
|
strSql.Append(",'' as FITINGFULL");
|
|
|
|
strSql.Append(" from op_ctntkFiting_detail ");
|
|
strSql.Append(" GROUP BY [FITINGGID],[FITINGCODE],[FITINGNAME],[MODEL],[YARD] ");
|
|
|
|
return SetFitingsKcData(strSql);
|
|
}
|
|
static public List<OpCtnTkFitingsKc> GetFitingsCtnKcSum(string CTNGID)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT '' GID,[FITINGGID],[FITINGCODE],[FITINGNAME],[MODEL]");
|
|
strSql.Append(",sum(CASE WHEN WMSTYPE='装' THEN NPKGS ELSE -NPKGS END) PKGS");
|
|
strSql.Append(",'' as FITINGFULL,'' YARD ");
|
|
|
|
strSql.Append(" from op_ctntkFiting_detail WHERE CTNGID='"+ CTNGID + "' ");
|
|
|
|
|
|
strSql.Append(" GROUP BY [FITINGGID],[FITINGCODE],[FITINGNAME],[MODEL],[YARD] ");
|
|
|
|
return SetFitingsKcData(strSql);
|
|
}
|
|
|
|
private static List<OpCtnTkFitingsKc> SetFitingsKcData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<OpCtnTkFitingsKc>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
OpCtnTkFitingsKc data = new OpCtnTkFitingsKc();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.FITINGGID = Convert.ToString(reader["FITINGGID"]);
|
|
data.FITINGCODE = Convert.ToString(reader["FITINGCODE"]);
|
|
data.FITINGNAME = Convert.ToString(reader["FITINGNAME"]);
|
|
data.MODEL = Convert.ToString(reader["MODEL"]);
|
|
if (reader["PKGS"] != DBNull.Value)
|
|
data.PKGS = Convert.ToDecimal(reader["PKGS"]);
|
|
|
|
data.YARD = Convert.ToString(reader["YARD"]);
|
|
data.FITINGFULL = Convert.ToString(reader["FITINGFULL"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
public static DBResult UpdateFitingsKc()
|
|
{
|
|
var result = new DBResult();
|
|
|
|
var bodyList = GetFitingsKcSum();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into op_ctntkFiting_kc (GID,[FITINGGID],[FITINGCODE],[FITINGNAME],[MODEL]
|
|
,[PKGS],[YARD])
|
|
values (@GID,@FITINGGID,@FITINGCODE,@FITINGNAME,@MODEL
|
|
,@PKGS,@YARD) ");
|
|
|
|
var cmdDelete =
|
|
db.GetSqlStringCommand(
|
|
@"delete from op_ctntkFiting_kc ");
|
|
cmdDelete.Parameters.Clear();
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
cmdInsert.Parameters.Clear();
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsert, "@FITINGGID", DbType.String, enumValue.FITINGGID);
|
|
db.AddInParameter(cmdInsert, "@FITINGCODE", DbType.String, enumValue.FITINGCODE);
|
|
db.AddInParameter(cmdInsert, "@FITINGNAME", DbType.String, enumValue.FITINGNAME);
|
|
db.AddInParameter(cmdInsert, "@MODEL", DbType.String, enumValue.MODEL);
|
|
db.AddInParameter(cmdInsert, "@PKGS", DbType.Decimal, enumValue.PKGS);
|
|
db.AddInParameter(cmdInsert, "@YARD", DbType.String, enumValue.YARD);
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception E)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员" + E.Message;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
return result;
|
|
}
|
|
|
|
//public static DBResult UpdateFitingsCtnKc(string CTNGID)
|
|
//{
|
|
// var result = new DBResult();
|
|
|
|
// var bodyList = GetFitingsCtnKcSum(CTNGID);
|
|
|
|
// Database db = DatabaseFactory.CreateDatabase();
|
|
// using (var conn = db.CreateConnection())
|
|
// {
|
|
// conn.Open();
|
|
// var tran = conn.BeginTransaction();
|
|
|
|
// try
|
|
// {
|
|
|
|
// var cmdInsert =
|
|
// db.GetSqlStringCommand(
|
|
// @"insert into op_ctntkFiting_Ctnkc (GID,[FITINGGID],[FITINGCODE],[FITINGNAME],[MODEL]
|
|
// ,[PKGS],[CTNGID])
|
|
// values (@GID,@FITINGGID,@FITINGCODE,@FITINGNAME,@MODEL
|
|
// ,@PKGS,@CTNGID) ");
|
|
|
|
// var cmdDelete =
|
|
// db.GetSqlStringCommand(
|
|
// @"delete from op_ctntkFiting_Ctnkc WHERE CTNGID='"+CTNGID+"' ");
|
|
// cmdDelete.Parameters.Clear();
|
|
// db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
// if (bodyList != null)
|
|
// {
|
|
// foreach (var enumValue in bodyList)
|
|
// {
|
|
// cmdInsert.Parameters.Clear();
|
|
// db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
// db.AddInParameter(cmdInsert, "@FITINGGID", DbType.String, enumValue.FITINGGID);
|
|
// db.AddInParameter(cmdInsert, "@FITINGCODE", DbType.String, enumValue.FITINGCODE);
|
|
// db.AddInParameter(cmdInsert, "@FITINGNAME", DbType.String, enumValue.FITINGNAME);
|
|
// db.AddInParameter(cmdInsert, "@MODEL", DbType.String, enumValue.MODEL);
|
|
// db.AddInParameter(cmdInsert, "@PKGS", DbType.Decimal, enumValue.PKGS);
|
|
// db.AddInParameter(cmdInsert, "@CTNGID", DbType.String, CTNGID);
|
|
// db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
// }
|
|
// }
|
|
|
|
|
|
|
|
// tran.Commit();
|
|
// }
|
|
// catch (Exception E)
|
|
// {
|
|
// tran.Rollback();
|
|
|
|
// result.Success = false;
|
|
// result.Message = "保存出现错误,请重试或联系系统管理员" + E.Message;
|
|
|
|
// return result;
|
|
// }
|
|
// }
|
|
|
|
// result.Success = true;
|
|
// result.Message = "保存成功" + result.Message;
|
|
|
|
// return result;
|
|
//}
|
|
|
|
|
|
public static DBResult UpdateFitingsCtnKc(string CTNGID, List<OpCtnTkFitingsDetail> DetailList)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
var bodyList = GetFitingsCtnKcList("F.CTNGID='"+CTNGID+"'");
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into op_ctntkFiting_Ctnkc (GID,[FITINGGID],[FITINGCODE],[FITINGNAME],[MODEL]
|
|
,[PKGS],[CTNGID])
|
|
values (@GID,@FITINGGID,@FITINGCODE,@FITINGNAME,@MODEL
|
|
,@PKGS,@CTNGID) ");
|
|
|
|
var cmdDelete =
|
|
db.GetSqlStringCommand(
|
|
@"delete from op_ctntkFiting_Ctnkc WHERE CTNGID='" + CTNGID + "' ");
|
|
cmdDelete.Parameters.Clear();
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
cmdInsert.Parameters.Clear();
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsert, "@FITINGGID", DbType.String, enumValue.FITINGGID);
|
|
db.AddInParameter(cmdInsert, "@FITINGCODE", DbType.String, enumValue.FITINGCODE);
|
|
db.AddInParameter(cmdInsert, "@FITINGNAME", DbType.String, enumValue.FITINGNAME);
|
|
db.AddInParameter(cmdInsert, "@MODEL", DbType.String, enumValue.MODEL);
|
|
db.AddInParameter(cmdInsert, "@PKGS", DbType.Decimal, enumValue.PKGS);
|
|
db.AddInParameter(cmdInsert, "@CTNGID", DbType.String, CTNGID);
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception E)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员" + E.Message;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
public static DBResult SaveFitingsCtnKc(List<OpCtnTkFitingsDetail> bodyList)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into op_ctntkFiting_Ctnkc (GID,[FITINGGID],[FITINGCODE],[FITINGNAME],[MODEL]
|
|
,[PKGS],[CTNGID])
|
|
values (@GID,@FITINGGID,@FITINGCODE,@FITINGNAME,@MODEL
|
|
,@PKGS,@CTNGID) ");
|
|
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"update op_ctntkFiting_Ctnkc set FITINGGID=@FITINGGID,FITINGCODE=@FITINGCODE,FITINGNAME=@FITINGNAME,MODEL=@MODEL,
|
|
PKGS=@PKGS where GID=@GID ");
|
|
|
|
|
|
var cmdDelete =
|
|
db.GetSqlStringCommand(
|
|
@"delete from op_ctntkFiting_Ctnkc WHERE CTNGID=@CTNGID AND FITINGGID=@FITINGGID ");
|
|
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
if (enumValue.PKGS == 0)
|
|
{
|
|
cmdDelete.Parameters.Clear();
|
|
db.AddInParameter(cmdDelete, "@CTNGID", DbType.String, enumValue.CTNGID);
|
|
db.AddInParameter(cmdDelete, "@FITINGGID", DbType.String, enumValue.FITINGGID);
|
|
db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
if (enumValue.GID == "*")
|
|
{
|
|
cmdInsert.Parameters.Clear();
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsert, "@FITINGGID", DbType.String, enumValue.FITINGGID);
|
|
db.AddInParameter(cmdInsert, "@FITINGCODE", DbType.String, enumValue.FITINGCODE);
|
|
db.AddInParameter(cmdInsert, "@FITINGNAME", DbType.String, enumValue.FITINGNAME);
|
|
db.AddInParameter(cmdInsert, "@MODEL", DbType.String, enumValue.MODEL);
|
|
db.AddInParameter(cmdInsert, "@PKGS", DbType.Decimal, enumValue.PKGS);
|
|
db.AddInParameter(cmdInsert, "@CTNGID", DbType.String, enumValue.CTNGID);
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
}
|
|
else
|
|
{
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
|
|
db.AddInParameter(cmdUpdate, "@FITINGGID", DbType.String, enumValue.FITINGGID);
|
|
db.AddInParameter(cmdUpdate, "@FITINGCODE", DbType.String, enumValue.FITINGCODE);
|
|
db.AddInParameter(cmdUpdate, "@FITINGNAME", DbType.String, enumValue.FITINGNAME);
|
|
db.AddInParameter(cmdUpdate, "@MODEL", DbType.String, enumValue.MODEL);
|
|
db.AddInParameter(cmdUpdate, "@PKGS", DbType.Decimal, enumValue.PKGS);
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception E)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员" + E.Message;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
return result;
|
|
}
|
|
|
|
static public List<OpCtnTkFitingsDetail> GetFitingsCtnKcList(string strCondition, string sort = null)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT F.GID,F.[FITINGGID],F.[FITINGCODE],F.[FITINGNAME],F.[MODEL]");
|
|
strSql.Append(",F.[PKGS],F.[CTNGID]");
|
|
strSql.Append(",(F.FITINGNAME+'-'+F.MODEL) as FITINGFULL,C.CTNNO");
|
|
|
|
strSql.Append(" from op_ctntkFiting_Ctnkc F left join code_ctntk c on (c.GID=F.CTNGID)");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by CTNGID,FITINGNAME ");
|
|
|
|
}
|
|
return SetFitingsCtnKcData(strSql);
|
|
}
|
|
static public List<OpCtnTkFitingsDetail> GetFitingsCtnKcSumList(string strCondition, string sort = null)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT '' GID,F.[FITINGGID],F.[FITINGCODE],F.[FITINGNAME],F.[MODEL]");
|
|
strSql.Append(",SUM(F.[PKGS]) PKGS, '' CTNGID");
|
|
strSql.Append(",(F.FITINGNAME+'-'+F.MODEL) as FITINGFULL,'' CTNNO");
|
|
|
|
strSql.Append(" from op_ctntkFiting_Ctnkc F left join code_ctntk c on (c.GID=F.CTNGID) ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
strSql.Append(" GROUP BY F.[FITINGGID],F.[FITINGCODE],F.[FITINGNAME],F.[MODEL] ");
|
|
|
|
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by FITINGNAME ");
|
|
|
|
}
|
|
return SetFitingsCtnKcData(strSql);
|
|
}
|
|
static public OpCtnTkFitingsDetail GetFitingsCtnKc(string strCondition, string sort = null)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT F.GID,F.[FITINGGID],F.[FITINGCODE],F.[FITINGNAME],F.[MODEL]");
|
|
strSql.Append(",F.[PKGS],F.[CTNGID]");
|
|
strSql.Append(",(F.FITINGNAME+'-'+F.MODEL) as FITINGFULL,C.CTNNO");
|
|
|
|
strSql.Append(" from op_ctntkFiting_Ctnkc F left join code_ctntk c on (c.GID=F.CTNGID)");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
|
|
|
|
var list = SetFitingsCtnKcData(strSql);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
return new OpCtnTkFitingsDetail();
|
|
}
|
|
|
|
static public string GetFitingsCtnKcListStr(string strCondition, string sort = null)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT F.GID,F.[FITINGGID],F.[FITINGCODE],F.[FITINGNAME],F.[MODEL]");
|
|
strSql.Append(",F.[PKGS],F.[CTNGID]");
|
|
strSql.Append(",(F.FITINGNAME+'-'+F.MODEL) as FITINGFULL,C.CTNNO");
|
|
|
|
strSql.Append(" from op_ctntkFiting_Ctnkc F left join code_ctntk c on (c.GID=F.CTNGID)");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by CTNGID,FITINGNAME ");
|
|
|
|
}
|
|
return strSql.ToString();
|
|
}
|
|
|
|
private static List<OpCtnTkFitingsDetail> SetFitingsCtnKcData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<OpCtnTkFitingsDetail>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
OpCtnTkFitingsDetail data = new OpCtnTkFitingsDetail();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.FITINGGID = Convert.ToString(reader["FITINGGID"]);
|
|
data.FITINGCODE = Convert.ToString(reader["FITINGCODE"]);
|
|
data.FITINGNAME = Convert.ToString(reader["FITINGNAME"]);
|
|
data.FITINGFULL = Convert.ToString(reader["FITINGFULL"]);
|
|
data.CTNGID = Convert.ToString(reader["CTNGID"]);
|
|
data.CTNNO = Convert.ToString(reader["CTNNO"]);
|
|
data.MODEL = Convert.ToString(reader["MODEL"]);
|
|
if (reader["PKGS"] != DBNull.Value)
|
|
data.PKGS = Convert.ToDecimal(reader["PKGS"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
|
|
|
|
|
|
static public List<OpCtnTkFitingsDetail> GetFitingsBsCardCtnKcList(string strCondition, string sort = null)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT F.GID,F.[FITINGGID],F.[FITINGCODE],F.[FITINGNAME],F.[MODEL]");
|
|
strSql.Append(",F.[PKGS],F.[CTNGID]");
|
|
strSql.Append(",(F.FITINGNAME+'-'+F.MODEL) as FITINGFULL,B.CTNNO");
|
|
strSql.Append(",B.GID LINKGID,F.[CTNGID]");
|
|
strSql.Append(",D.PKGS MPKGS,D.YARD,D.WMSTYPE,D.OPDATE,D.OPSTATUS,D.GID BODYGID ");
|
|
|
|
strSql.Append(" from op_ctntkFiting_Ctnkc F left join op_ctnbscard B on (B.CTNGID=F.CTNGID)");
|
|
strSql.Append(" left join op_ctntkFiting_body D on (D.LINKGID=B.GID AND F.FITINGGID=D.FITINGGID)");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by F.CTNGID,F.FITINGNAME ");
|
|
|
|
}
|
|
return SetFitingsBsCardCtnKcData(strSql);
|
|
}
|
|
|
|
static public string GetFitingsBsCardCtnKcListStr(string strCondition, string sort = null)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT F.GID,F.[FITINGGID],F.[FITINGCODE],F.[FITINGNAME],F.[MODEL]");
|
|
strSql.Append(",F.[PKGS],F.[CTNGID]");
|
|
strSql.Append(",(F.FITINGNAME+'-'+F.MODEL) as FITINGFULL,B.CTNNO");
|
|
strSql.Append(",B.GID LINKGID,F.[CTNGID]");
|
|
strSql.Append(",D.PKGS MPKGS,D.YARD,D.WMSTYPE,D.OPDATE,D.OPSTATUS,D.GID BODYGID ");
|
|
|
|
strSql.Append(" from op_ctntkFiting_Ctnkc F left join op_ctnbscard B on (B.CTNGID=F.CTNGID)");
|
|
strSql.Append(" left join op_ctntkFiting_body D on (D.LINKGID=B.GID AND F.FITINGGID=D.FITINGGID)");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append(" order by F.CTNGID,F.FITINGNAME ");
|
|
|
|
}
|
|
return strSql.ToString();
|
|
}
|
|
|
|
private static List<OpCtnTkFitingsDetail> SetFitingsBsCardCtnKcData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<OpCtnTkFitingsDetail>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
OpCtnTkFitingsDetail data = new OpCtnTkFitingsDetail();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.FITINGGID = Convert.ToString(reader["FITINGGID"]);
|
|
data.FITINGCODE = Convert.ToString(reader["FITINGCODE"]);
|
|
data.FITINGNAME = Convert.ToString(reader["FITINGNAME"]);
|
|
data.FITINGFULL = Convert.ToString(reader["FITINGFULL"]);
|
|
data.CTNGID = Convert.ToString(reader["CTNGID"]);
|
|
data.CTNNO = Convert.ToString(reader["CTNNO"]);
|
|
data.MODEL = Convert.ToString(reader["MODEL"]);
|
|
if (reader["PKGS"] != DBNull.Value)
|
|
data.PKGS = Convert.ToDecimal(reader["PKGS"]);
|
|
if (reader["MPKGS"] != DBNull.Value)
|
|
data.NPKGS = Convert.ToDecimal(reader["MPKGS"]);
|
|
data.WMSTYPE = Convert.ToString(reader["WMSTYPE"]);
|
|
if (reader["OPDATE"] != DBNull.Value)
|
|
data.OPDATE = Convert.ToDateTime(reader["OPDATE"]).ToString("yyyy-MM-dd");
|
|
data.YARD = Convert.ToString(reader["YARD"]);
|
|
data.BODYGID = Convert.ToString(reader["BODYGID"]);
|
|
data.LINKGID = Convert.ToString(reader["LINKGID"]);
|
|
data.OPSTATUS = Convert.ToString(reader["OPSTATUS"]);
|
|
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
public static DBResult SaveBsCardFitingsBody(List<OpCtnTkFitingsDetail> bodyList,string userid)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into op_ctntkFiting_body (GID,[LINKGID],[FITINGGID],[FITINGCODE],[FITINGNAME],[MODEL]
|
|
,[PKGS],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],WMSTYPE,OPDATE,YARD,OPSTATUS)
|
|
values (@GID,@LINKGID,@FITINGGID,@FITINGCODE,@FITINGNAME,@MODEL
|
|
,@PKGS,@REMARK,@CREATEUSER,@CREATETIME,@MODIFIEDUSER,@MODIFIEDTIME,@WMSTYPE,@OPDATE,@YARD,@OPSTATUS) ");
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"update op_ctntkFiting_body set FITINGGID=@FITINGGID,FITINGCODE=@FITINGCODE,FITINGNAME=@FITINGNAME,MODEL=@MODEL,
|
|
PKGS=@PKGS,REMARK=@REMARK,MODIFIEDUSER=@MODIFIEDUSER,MODIFIEDTIME=@MODIFIEDTIME,WMSTYPE=@WMSTYPE,OPDATE=@OPDATE,
|
|
YARD=@YARD where GID=@GID ");
|
|
|
|
var cmdDelete =
|
|
db.GetSqlStringCommand(
|
|
@"delete from op_ctntkFiting_body WHERE CTNGID=@CTNGID ");
|
|
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
|
|
|
|
if (enumValue.NPKGS != 0)
|
|
{
|
|
if (string.IsNullOrEmpty(enumValue.BODYGID))
|
|
{
|
|
cmdInsert.Parameters.Clear();
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsert, "@LINKGID", DbType.String, enumValue.LINKGID);
|
|
db.AddInParameter(cmdInsert, "@FITINGGID", DbType.String, enumValue.FITINGGID);
|
|
db.AddInParameter(cmdInsert, "@FITINGCODE", DbType.String, enumValue.FITINGCODE);
|
|
db.AddInParameter(cmdInsert, "@FITINGNAME", DbType.String, enumValue.FITINGNAME);
|
|
db.AddInParameter(cmdInsert, "@MODEL", DbType.String, enumValue.MODEL);
|
|
db.AddInParameter(cmdInsert, "@PKGS", DbType.Decimal, enumValue.NPKGS);
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdInsert, "@CREATEUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsert, "@CREATETIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdInsert, "@WMSTYPE", DbType.String, enumValue.WMSTYPE);
|
|
db.AddInParameter(cmdInsert, "@OPDATE", DbType.String, enumValue.OPDATE);
|
|
db.AddInParameter(cmdInsert, "@YARD", DbType.String, enumValue.YARD);
|
|
db.AddInParameter(cmdInsert, "@OPSTATUS", DbType.String, "0");
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
}
|
|
else
|
|
{
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
|
|
db.AddInParameter(cmdUpdate, "@FITINGGID", DbType.String, enumValue.FITINGGID);
|
|
db.AddInParameter(cmdUpdate, "@FITINGCODE", DbType.String, enumValue.FITINGCODE);
|
|
db.AddInParameter(cmdUpdate, "@FITINGNAME", DbType.String, enumValue.FITINGNAME);
|
|
db.AddInParameter(cmdUpdate, "@MODEL", DbType.String, enumValue.MODEL);
|
|
db.AddInParameter(cmdUpdate, "@PKGS", DbType.Decimal, enumValue.NPKGS);
|
|
db.AddInParameter(cmdUpdate, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdUpdate, "@MODIFIEDUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdUpdate, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdUpdate, "@WMSTYPE", DbType.String, enumValue.WMSTYPE);
|
|
db.AddInParameter(cmdUpdate, "@OPDATE", DbType.String, enumValue.OPDATE);
|
|
db.AddInParameter(cmdUpdate, "@YARD", DbType.String, enumValue.YARD);
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
}
|
|
}
|
|
else {
|
|
//if (!string.IsNullOrEmpty(enumValue.BODYGID))
|
|
//{
|
|
// cmdDelete.Parameters.Clear();
|
|
// db.AddInParameter(cmdDelete, "@GID", DbType.String, enumValue.BODYGID);
|
|
// db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception E)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员" + E.Message;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
public static DBResult AuditBsCardFitingsBody(List<OpCtnTkFitingsDetail> bodyList, string userid)
|
|
{
|
|
var result = new DBResult();
|
|
var CtnKcList = new List<OpCtnTkFitingsDetail>();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdInsert =
|
|
db.GetSqlStringCommand(
|
|
@"insert into op_ctntkFiting_body (GID,[LINKGID],[FITINGGID],[FITINGCODE],[FITINGNAME],[MODEL]
|
|
,[PKGS],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],WMSTYPE,OPDATE,YARD,OPSTATUS)
|
|
values (@GID,@LINKGID,@FITINGGID,@FITINGCODE,@FITINGNAME,@MODEL
|
|
,@PKGS,@REMARK,@CREATEUSER,@CREATETIME,@MODIFIEDUSER,@MODIFIEDTIME,@WMSTYPE,@OPDATE,@YARD,@OPSTATUS) ");
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"update op_ctntkFiting_body set FITINGGID=@FITINGGID,FITINGCODE=@FITINGCODE,FITINGNAME=@FITINGNAME,MODEL=@MODEL,
|
|
PKGS=@PKGS,REMARK=@REMARK,MODIFIEDUSER=@MODIFIEDUSER,MODIFIEDTIME=@MODIFIEDTIME,WMSTYPE=@WMSTYPE,OPDATE=@OPDATE,
|
|
YARD=@YARD,OPSTATUS=@OPSTATUS where GID=@GID ");
|
|
|
|
var cmdDelete =
|
|
db.GetSqlStringCommand(
|
|
@"delete from op_ctntkFiting_body WHERE CTNGID=@CTNGID ");
|
|
|
|
var cmdInsertDetail =
|
|
db.GetSqlStringCommand(
|
|
@"insert into op_ctntkFiting_detail (GID,[LINKGID],[FITINGGID],[FITINGCODE],[FITINGNAME],[CTNGID],[CTNNO],[MODEL]
|
|
,[WMSTYPE],[OPDATE],[YARD],[PKGS],[NPKGS],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],DSTATUS)
|
|
values (@GID,@LINKGID,@FITINGGID,@FITINGCODE,@FITINGNAME,@CTNGID,@CTNNO,@MODEL
|
|
,@WMSTYPE,@OPDATE,@YARD,@PKGS,@NPKGS,@REMARK,@CREATEUSER,@CREATETIME,@MODIFIEDUSER,@MODIFIEDTIME,@DSTATUS) ");
|
|
|
|
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
|
|
|
|
if (enumValue.NPKGS != 0)
|
|
{
|
|
if (string.IsNullOrEmpty(enumValue.BODYGID))
|
|
{
|
|
cmdInsert.Parameters.Clear();
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsert, "@LINKGID", DbType.String, enumValue.LINKGID);
|
|
db.AddInParameter(cmdInsert, "@FITINGGID", DbType.String, enumValue.FITINGGID);
|
|
db.AddInParameter(cmdInsert, "@FITINGCODE", DbType.String, enumValue.FITINGCODE);
|
|
db.AddInParameter(cmdInsert, "@FITINGNAME", DbType.String, enumValue.FITINGNAME);
|
|
db.AddInParameter(cmdInsert, "@MODEL", DbType.String, enumValue.MODEL);
|
|
db.AddInParameter(cmdInsert, "@PKGS", DbType.Decimal, enumValue.NPKGS);
|
|
db.AddInParameter(cmdInsert, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdInsert, "@CREATEUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsert, "@CREATETIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdInsert, "@MODIFIEDUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsert, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdInsert, "@WMSTYPE", DbType.String, enumValue.WMSTYPE);
|
|
db.AddInParameter(cmdInsert, "@OPDATE", DbType.String, enumValue.OPDATE);
|
|
db.AddInParameter(cmdInsert, "@YARD", DbType.String, enumValue.YARD);
|
|
db.AddInParameter(cmdInsert, "@OPSTATUS", DbType.String, "1");
|
|
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
}
|
|
else
|
|
{
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
|
|
db.AddInParameter(cmdUpdate, "@FITINGGID", DbType.String, enumValue.FITINGGID);
|
|
db.AddInParameter(cmdUpdate, "@FITINGCODE", DbType.String, enumValue.FITINGCODE);
|
|
db.AddInParameter(cmdUpdate, "@FITINGNAME", DbType.String, enumValue.FITINGNAME);
|
|
db.AddInParameter(cmdUpdate, "@MODEL", DbType.String, enumValue.MODEL);
|
|
db.AddInParameter(cmdUpdate, "@PKGS", DbType.Decimal, enumValue.NPKGS);
|
|
db.AddInParameter(cmdUpdate, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdUpdate, "@MODIFIEDUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdUpdate, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdUpdate, "@WMSTYPE", DbType.String, enumValue.WMSTYPE);
|
|
db.AddInParameter(cmdUpdate, "@OPDATE", DbType.String, enumValue.OPDATE);
|
|
db.AddInParameter(cmdUpdate, "@YARD", DbType.String, enumValue.YARD);
|
|
db.AddInParameter(cmdUpdate, "@OPSTATUS", DbType.String, "1");
|
|
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
}
|
|
cmdInsertDetail.Parameters.Clear();
|
|
db.AddInParameter(cmdInsertDetail, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsertDetail, "@LINKGID", DbType.String, enumValue.LINKGID);
|
|
db.AddInParameter(cmdInsertDetail, "@FITINGGID", DbType.String, enumValue.FITINGGID);
|
|
db.AddInParameter(cmdInsertDetail, "@FITINGCODE", DbType.String, enumValue.FITINGCODE);
|
|
db.AddInParameter(cmdInsertDetail, "@FITINGNAME", DbType.String, enumValue.FITINGNAME);
|
|
db.AddInParameter(cmdInsertDetail, "@CTNGID", DbType.String, enumValue.CTNGID);
|
|
db.AddInParameter(cmdInsertDetail, "@CTNNO", DbType.String, enumValue.CTNNO);
|
|
db.AddInParameter(cmdInsertDetail, "@MODEL", DbType.String, enumValue.MODEL);
|
|
db.AddInParameter(cmdInsertDetail, "@WMSTYPE", DbType.String, enumValue.WMSTYPE);
|
|
db.AddInParameter(cmdInsertDetail, "@OPDATE", DbType.String, enumValue.OPDATE);
|
|
db.AddInParameter(cmdInsertDetail, "@YARD", DbType.String, enumValue.YARD);
|
|
|
|
if (enumValue.WMSTYPE == "拆")
|
|
db.AddInParameter(cmdInsertDetail, "@PKGS", DbType.Decimal, enumValue.NPKGS);
|
|
else if (enumValue.WMSTYPE == "装")
|
|
db.AddInParameter(cmdInsertDetail, "@PKGS", DbType.Decimal, -enumValue.NPKGS);
|
|
else if (enumValue.WMSTYPE == "损坏")
|
|
db.AddInParameter(cmdInsertDetail, "@PKGS", DbType.Decimal, 0);
|
|
db.AddInParameter(cmdInsertDetail, "@NPKGS", DbType.Decimal, enumValue.NPKGS);
|
|
db.AddInParameter(cmdInsertDetail, "@REMARK", DbType.String, enumValue.REMARK);
|
|
db.AddInParameter(cmdInsertDetail, "@CREATEUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsertDetail, "@CREATETIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdInsertDetail, "@MODIFIEDUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsertDetail, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
if (enumValue.WMSTYPE == "损坏")
|
|
db.AddInParameter(cmdInsertDetail, "@DSTATUS", DbType.String, "提交审核");
|
|
else
|
|
db.AddInParameter(cmdInsertDetail, "@DSTATUS", DbType.String, "");
|
|
db.ExecuteNonQuery(cmdInsertDetail, tran);
|
|
|
|
if (enumValue.WMSTYPE != "损坏")
|
|
{
|
|
var ctnkc = GetFitingsCtnKc("F.CTNGID='" + enumValue.CTNGID + "' AND F.FITINGGID='" + enumValue.FITINGGID + "'");
|
|
if (ctnkc != null && !string.IsNullOrEmpty(ctnkc.FITINGGID))
|
|
{
|
|
|
|
if (enumValue.WMSTYPE == "拆")
|
|
ctnkc.PKGS = ctnkc.PKGS - enumValue.NPKGS;
|
|
else if (enumValue.WMSTYPE == "装")
|
|
ctnkc.PKGS = ctnkc.PKGS + enumValue.NPKGS;
|
|
//else if (enumValue.WMSTYPE == "损坏")
|
|
// ctnkc.PKGS = ctnkc.PKGS - enumValue.NPKGS;
|
|
CtnKcList.Add(ctnkc);
|
|
|
|
}
|
|
else
|
|
{
|
|
var newctnck = new OpCtnTkFitingsDetail();
|
|
newctnck.GID = "*";
|
|
newctnck.CTNGID = enumValue.CTNGID;
|
|
newctnck.FITINGCODE = enumValue.FITINGCODE;
|
|
newctnck.FITINGGID = enumValue.FITINGGID;
|
|
newctnck.FITINGNAME = enumValue.FITINGNAME;
|
|
newctnck.MODEL = enumValue.MODEL;
|
|
if (enumValue.WMSTYPE == "拆")
|
|
newctnck.PKGS = -enumValue.NPKGS;
|
|
else if (enumValue.WMSTYPE == "装")
|
|
newctnck.PKGS = enumValue.NPKGS;
|
|
//else if (enumValue.WMSTYPE == "损坏")
|
|
// newctnck.PKGS = -enumValue.NPKGS;
|
|
CtnKcList.Add(newctnck);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
//if (!string.IsNullOrEmpty(enumValue.BODYGID))
|
|
//{
|
|
// cmdDelete.Parameters.Clear();
|
|
// db.AddInParameter(cmdDelete, "@GID", DbType.String, enumValue.BODYGID);
|
|
// db.ExecuteNonQuery(cmdDelete, tran);
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
tran.Commit();
|
|
if (CtnKcList.Count!=0)
|
|
SaveFitingsCtnKc(CtnKcList);
|
|
|
|
}
|
|
catch (Exception E)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员" + E.Message;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
public static DBResult AuditFitingsDetail(List<OpCtnTkFitingsDetail> bodyList, string userid)
|
|
{
|
|
var result = new DBResult();
|
|
var CtnKcList = new List<OpCtnTkFitingsDetail>();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"update op_ctntkFiting_detail set DSTATUS=@DSTATUS,AUDITUSER=@AUDITUSER,AUDITTIME=@AUDITTIME where GID=@GID ");
|
|
|
|
var cmdDelete =
|
|
db.GetSqlStringCommand(
|
|
@"delete from op_ctntkFiting_body WHERE CTNGID=@CTNGID ");
|
|
|
|
var cmdInsertDetail =
|
|
db.GetSqlStringCommand(
|
|
@"insert into op_ctntkFiting_detail (GID,[LINKGID],[FITINGGID],[FITINGCODE],[FITINGNAME],[CTNGID],[CTNNO],[MODEL]
|
|
,[WMSTYPE],[OPDATE],[YARD],[PKGS],[NPKGS],[REMARK],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],DSTATUS)
|
|
values (@GID,@LINKGID,@FITINGGID,@FITINGCODE,@FITINGNAME,@CTNGID,@CTNNO,@MODEL
|
|
,@WMSTYPE,@OPDATE,@YARD,@PKGS,@NPKGS,@REMARK,@CREATEUSER,@CREATETIME,@MODIFIEDUSER,@MODIFIEDTIME,@DSTATUS) ");
|
|
|
|
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
|
|
db.AddInParameter(cmdUpdate, "@AUDITUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdUpdate, "@AUDITTIME", DbType.String, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
db.AddInParameter(cmdUpdate, "@DSTATUS", DbType.String, "审核通过");
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
var ctnkc = GetFitingsCtnKc("F.CTNGID='" + enumValue.CTNGID + "' AND F.FITINGGID='" + enumValue.FITINGGID + "'");
|
|
if (ctnkc != null && !string.IsNullOrEmpty(ctnkc.FITINGGID))
|
|
{
|
|
if (enumValue.WMSTYPE == "损坏")
|
|
ctnkc.PKGS = ctnkc.PKGS - enumValue.NPKGS;
|
|
CtnKcList.Add(ctnkc);
|
|
|
|
}
|
|
else
|
|
{
|
|
var newctnck = new OpCtnTkFitingsDetail();
|
|
newctnck.GID = "*";
|
|
newctnck.CTNGID = enumValue.CTNGID;
|
|
newctnck.FITINGCODE = enumValue.FITINGCODE;
|
|
newctnck.FITINGGID = enumValue.FITINGGID;
|
|
newctnck.FITINGNAME = enumValue.FITINGNAME;
|
|
newctnck.MODEL = enumValue.MODEL;
|
|
if (enumValue.WMSTYPE == "损坏")
|
|
newctnck.PKGS = -enumValue.NPKGS;
|
|
CtnKcList.Add(newctnck);
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
tran.Commit();
|
|
if (CtnKcList.Count != 0)
|
|
SaveFitingsCtnKc(CtnKcList);
|
|
|
|
}
|
|
catch (Exception E)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员" + E.Message;
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功" + result.Message;
|
|
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|