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.
589 lines
27 KiB
C#
589 lines
27 KiB
C#
|
|
using System;
|
|
using System.Data;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using DSWeb.MvcShipping.Models.MsChFeeAgent;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
using DSWeb.EntityDA;
|
|
using HcUtility.Comm;
|
|
using System.Data.SqlClient;
|
|
using WebSqlHelper;
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
|
namespace DSWeb.Areas.MvcShipping.DAL.MsChFeeAgentDcDAL
|
|
{
|
|
public class MsChFeeAgentDcDAL
|
|
{
|
|
#region Inquery DataList
|
|
|
|
static public List<ChFeeAgentDC> GetDataList(string strCondition)
|
|
{
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("[GID],[BSNO],[DCNO],[AGENT],[FEENAME],[CURRENCY],[AMOUNTDR],[AMOUNTCR]");
|
|
strSql.Append(",[AMOUNTBAL],[ISCREATEFEE],[FEEAGENT],[DCTYPE],[AMOUNTTOTALSTR],[REMARK],[CREATETIME],[CREATEUSER],[EXCHANGERATE]");
|
|
strSql.Append(",(CASE WHEN ISCREATEFEE=1 THEN '是' ELSE '否' END) as ISCREATEFEEREF");
|
|
strSql.Append(",(select ShowName from [user] where GID=ch_fee_agentdc.CREATEUSER) as CREATEUSERREF");
|
|
strSql.Append(" from ch_fee_agentdc ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
return SetData(strSql);
|
|
}
|
|
|
|
static public ChFeeAgentDC GetData(string condition)
|
|
{
|
|
var list = GetDataList(condition);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
|
|
return new ChFeeAgentDC();
|
|
}
|
|
|
|
|
|
private static List<ChFeeAgentDC> SetData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<ChFeeAgentDC>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
ChFeeAgentDC data = new ChFeeAgentDC();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.BSNO = Convert.ToString(reader["BSNO"]);
|
|
data.DCNO = Convert.ToString(reader["DCNO"]);
|
|
data.AGENT = Convert.ToString(reader["AGENT"]);
|
|
data.FEENAME = Convert.ToString(reader["FEENAME"]);
|
|
data.CURRENCY = Convert.ToString(reader["CURRENCY"]);
|
|
if (reader["AMOUNTDR"] != DBNull.Value)
|
|
data.AMOUNTDR = Convert.ToDecimal(reader["AMOUNTDR"]);
|
|
if (reader["AMOUNTCR"] != DBNull.Value)
|
|
data.AMOUNTCR = Convert.ToDecimal(reader["AMOUNTCR"]);
|
|
if (reader["AMOUNTBAL"] != DBNull.Value)
|
|
data.AMOUNTBAL = Convert.ToDecimal(reader["AMOUNTBAL"]);
|
|
if (reader["ISCREATEFEE"] != DBNull.Value)
|
|
data.ISCREATEFEE = Convert.ToBoolean(reader["ISCREATEFEE"]);
|
|
if (reader["EXCHANGERATE"] != DBNull.Value)
|
|
data.EXCHANGERATE = Convert.ToDecimal(reader["EXCHANGERATE"]);
|
|
|
|
data.ISCREATEFEEREF = Convert.ToString(reader["ISCREATEFEEREF"]);
|
|
data.FEEAGENT = Convert.ToString(reader["FEEAGENT"]);
|
|
data.DCTYPE = Convert.ToString(reader["DCTYPE"]);
|
|
data.AMOUNTTOTALSTR = Convert.ToString(reader["AMOUNTTOTALSTR"]);
|
|
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");
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
|
|
|
|
public static DBResult CreateFeeBl(ChFeeAgentDC headData,string bsno, string userid, string username)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdInsertFee =
|
|
db.GetSqlStringCommand(
|
|
@"INSERT INTO ch_fee(GID, BSNO, FEETYPE, FEENAME, FEEDESCRIPTION, CUSTOMERTYPE, CUSTOMERNAME, UNIT, UNITPRICE, QUANTITY, AMOUNT, CURRENCY,
|
|
EXCHANGERATE, REASON, REMARK, COMMISSIONRATE,ENTEROPERATOR, ENTERDATE,ISOPEN, ISADVANCEDPAY, SORT, FEESTATUS, FEEFRT,CARGO_GID,
|
|
TAXRATE,NOTAXAMOUNT,ACCTAXRATE,LINENUM,TAXUNITPRICE,MODIFIEDUSER,MODIFIEDTIME,WMSOUTBSNO,PREAMOUNT,ISINVOICE,INPUTMODE,LOCALCURR,MANAGER,ISACC)
|
|
VALUES(@GID,@BSNO,@FEETYPE,@FEENAME,@FEEDESCRIPTION,@CUSTOMERTYPE,@CUSTOMERNAME,@UNIT,@UNITPRICE,@QUANTITY,@AMOUNT,@CURRENCY,
|
|
@EXCHANGERATE, @REASON, @REMARK, @COMMISSIONRATE,@ENTEROPERATOR, @ENTERDATE,@ISOPEN, @ISADVANCEDPAY, @SORT, @FEESTATUS, @FEEFRT,@CARGO_GID,
|
|
@TAXRATE,@NOTAXAMOUNT,@ACCTAXRATE,@LINENUM,@TAXUNITPRICE,@MODIFIEDUSER,@MODIFIEDTIME,@WMSOUTBSNO,@PREAMOUNT,@ISINVOICE,@INPUTMODE,@LOCALCURR,@MANAGER,@ISACC)
|
|
");
|
|
|
|
if (!GetTruckFeeCount(headData.GID))
|
|
{
|
|
|
|
cmdInsertFee.Parameters.Clear();
|
|
var amoutbal = headData.AMOUNTDR - headData.AMOUNTCR;
|
|
db.AddInParameter(cmdInsertFee, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsertFee, "@BSNO", DbType.String, bsno);
|
|
if (amoutbal > 0)
|
|
{
|
|
db.AddInParameter(cmdInsertFee, "@FEETYPE", DbType.Int16, 1);
|
|
db.AddInParameter(cmdInsertFee, "@UNITPRICE", DbType.Decimal, headData.AMOUNTBAL);
|
|
db.AddInParameter(cmdInsertFee, "@AMOUNT", DbType.Decimal, headData.AMOUNTBAL);
|
|
db.AddInParameter(cmdInsertFee, "@NOTAXAMOUNT", DbType.Decimal, headData.AMOUNTBAL);
|
|
db.AddInParameter(cmdInsertFee, "@TAXUNITPRICE", DbType.Decimal, headData.AMOUNTBAL);
|
|
}
|
|
else
|
|
{
|
|
db.AddInParameter(cmdInsertFee, "@FEETYPE", DbType.Int16, 2);
|
|
db.AddInParameter(cmdInsertFee, "@UNITPRICE", DbType.Decimal, headData.AMOUNTBAL);
|
|
db.AddInParameter(cmdInsertFee, "@AMOUNT", DbType.Decimal, headData.AMOUNTBAL);
|
|
db.AddInParameter(cmdInsertFee, "@NOTAXAMOUNT", DbType.Decimal, headData.AMOUNTBAL);
|
|
db.AddInParameter(cmdInsertFee, "@TAXUNITPRICE", DbType.Decimal, headData.AMOUNTBAL);
|
|
}
|
|
db.AddInParameter(cmdInsertFee, "@FEENAME", DbType.String, headData.FEENAME);
|
|
db.AddInParameter(cmdInsertFee, "@FEEDESCRIPTION", DbType.String, "");
|
|
db.AddInParameter(cmdInsertFee, "@CUSTOMERTYPE", DbType.String, "代理");
|
|
db.AddInParameter(cmdInsertFee, "@CUSTOMERNAME", DbType.String, headData.FEEAGENT);
|
|
db.AddInParameter(cmdInsertFee, "@UNIT", DbType.String, "票");
|
|
db.AddInParameter(cmdInsertFee, "@QUANTITY", DbType.Decimal, 1);
|
|
db.AddInParameter(cmdInsertFee, "@CURRENCY", DbType.String, headData.CURRENCY);
|
|
db.AddInParameter(cmdInsertFee, "@EXCHANGERATE", DbType.Decimal, headData.EXCHANGERATE);
|
|
db.AddInParameter(cmdInsertFee, "@REASON", DbType.String, "");
|
|
db.AddInParameter(cmdInsertFee, "@REMARK", DbType.String,headData.DCNO);
|
|
db.AddInParameter(cmdInsertFee, "@COMMISSIONRATE", DbType.Decimal, 0);
|
|
db.AddInParameter(cmdInsertFee, "@ENTEROPERATOR", DbType.String, userid);
|
|
db.AddInParameter(cmdInsertFee, "@ENTERDATE", DbType.String, DateTime.Now.ToString());
|
|
db.AddInParameter(cmdInsertFee, "@ISOPEN", DbType.Boolean, false);
|
|
db.AddInParameter(cmdInsertFee, "@ISADVANCEDPAY", DbType.Boolean, false);
|
|
db.AddInParameter(cmdInsertFee, "@SORT", DbType.Int16, 1);
|
|
db.AddInParameter(cmdInsertFee, "@FEESTATUS", DbType.Int16, 1);
|
|
db.AddInParameter(cmdInsertFee, "@FEEFRT", DbType.String, "PP");
|
|
db.AddInParameter(cmdInsertFee, "@CARGO_GID", DbType.String, headData.GID);
|
|
db.AddInParameter(cmdInsertFee, "@TAXRATE", DbType.Decimal, 0);
|
|
db.AddInParameter(cmdInsertFee, "@ACCTAXRATE", DbType.Decimal, 0);
|
|
db.AddInParameter(cmdInsertFee, "@LINENUM", DbType.Int16, 1);
|
|
db.AddInParameter(cmdInsertFee, "@MODIFIEDUSER", DbType.String, userid);
|
|
db.AddInParameter(cmdInsertFee, "@MODIFIEDTIME", DbType.String, DateTime.Now.ToString());
|
|
|
|
db.AddInParameter(cmdInsertFee, "@WMSOUTBSNO", DbType.String, "");
|
|
db.AddInParameter(cmdInsertFee, "@PREAMOUNT", DbType.Decimal, 0);
|
|
db.AddInParameter(cmdInsertFee, "@ISINVOICE", DbType.Boolean, false);
|
|
db.AddInParameter(cmdInsertFee, "@INPUTMODE", DbType.String, "");
|
|
db.AddInParameter(cmdInsertFee, "@LOCALCURR", DbType.String, "RMB");
|
|
db.AddInParameter(cmdInsertFee, "@MANAGER", DbType.String, username);
|
|
db.AddInParameter(cmdInsertFee, "@ISACC", DbType.Boolean, false);
|
|
|
|
db.ExecuteNonQuery(cmdInsertFee, tran);
|
|
|
|
var cmdUpdateBL =
|
|
db.GetSqlStringCommand(
|
|
@"update ch_fee_agentdc set ISCREATEFEE=1 where GID=@GID ");
|
|
cmdUpdateBL.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdateBL, "@GID", DbType.String, headData.GID);
|
|
db.ExecuteNonQuery(cmdUpdateBL, tran);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "生成费用出现错误,请重试或联系系统管理员" + e.Message;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "生成成功";
|
|
|
|
return result;
|
|
}
|
|
public static DBResult DeleteFeeBl(ChFeeAgentDC headData)
|
|
{
|
|
var result = new DBResult();
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
|
|
try
|
|
{
|
|
|
|
var cmdInsertFee =
|
|
db.GetSqlStringCommand(
|
|
@"delete from ch_fee where BSNO=@BSNO AND CARGO_GID=@CARGO_GID ");
|
|
|
|
if (headData.ISCREATEFEE ==true)
|
|
{
|
|
|
|
cmdInsertFee.Parameters.Clear();
|
|
|
|
db.AddInParameter(cmdInsertFee, "@BSNO", DbType.String, headData.BSNO);
|
|
db.AddInParameter(cmdInsertFee, "@CARGO_GID", DbType.String, headData.GID);
|
|
|
|
db.ExecuteNonQuery(cmdInsertFee, tran);
|
|
|
|
var cmdUpdateBL =
|
|
db.GetSqlStringCommand(
|
|
@"update ch_fee_agentdc set ISCREATEFEE=0 where GID=@GID ");
|
|
cmdUpdateBL.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdateBL, "@GID", DbType.String, headData.GID);
|
|
db.ExecuteNonQuery(cmdUpdateBL, tran);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "生成费用出现错误,请重试或联系系统管理员" + e.Message;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "生成成功";
|
|
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 明细表
|
|
|
|
static public List<ChFeeAgentDcDetail> GetBodyList(string strCondition, string sort = null)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("[GID],[DCGID],[FEENAME],[FEEENAME],[CURRENCY],[EXCHANGERATE],[DRPP]");
|
|
strSql.Append(",[DRCC],[CRPP],[CRCC],[FZPR],[AMOUNTDR],[AMOUNTCR],[UNIT],[UNITPRICE],[QUANTITY],[FEEDESCRIPTION],SORT");
|
|
strSql.Append(" from ch_fee_agentdc_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 SORT ");
|
|
}
|
|
|
|
return SetBodyData(strSql);
|
|
}
|
|
|
|
private static List<ChFeeAgentDcDetail> SetBodyData(StringBuilder strSql)
|
|
{
|
|
var bodyList = new List<ChFeeAgentDcDetail>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
ChFeeAgentDcDetail data = new ChFeeAgentDcDetail();
|
|
#region Set DB data to Object
|
|
data.GID = Convert.ToString(reader["GID"]);
|
|
data.DCGID = Convert.ToString(reader["DCGID"]);
|
|
|
|
data.FEENAME = Convert.ToString(reader["FEENAME"]);
|
|
data.FEEENAME = Convert.ToString(reader["FEEENAME"]);
|
|
data.CURRENCY = Convert.ToString(reader["CURRENCY"]);
|
|
if (reader["EXCHANGERATE"] != DBNull.Value)
|
|
data.EXCHANGERATE = Convert.ToDecimal(reader["EXCHANGERATE"]);
|
|
if (reader["DRPP"] != DBNull.Value)
|
|
data.DRPP = Convert.ToDecimal(reader["DRPP"]);
|
|
if (reader["DRCC"] != DBNull.Value)
|
|
data.DRCC = Convert.ToDecimal(reader["DRCC"]);
|
|
if (reader["CRPP"] != DBNull.Value)
|
|
data.CRPP = Convert.ToDecimal(reader["CRPP"]);
|
|
if (reader["CRCC"] != DBNull.Value)
|
|
data.CRCC = Convert.ToDecimal(reader["CRCC"]);
|
|
if (reader["FZPR"] != DBNull.Value)
|
|
data.FZPR = Convert.ToString(reader["FZPR"]);
|
|
if (reader["AMOUNTDR"] != DBNull.Value)
|
|
data.AMOUNTDR = Convert.ToDecimal(reader["AMOUNTDR"]);
|
|
if (reader["AMOUNTCR"] != DBNull.Value)
|
|
data.AMOUNTCR = Convert.ToDecimal(reader["AMOUNTCR"]);
|
|
data.UNIT = Convert.ToString(reader["UNIT"]);
|
|
if (reader["UNITPRICE"] != DBNull.Value)
|
|
data.UNITPRICE = Convert.ToDecimal(reader["UNITPRICE"]);
|
|
if (reader["QUANTITY"] != DBNull.Value)
|
|
data.QUANTITY = Convert.ToDecimal(reader["QUANTITY"]);
|
|
data.FEEDESCRIPTION = Convert.ToString(reader["FEEDESCRIPTION"]);
|
|
if (reader["SORT"] != DBNull.Value)
|
|
data.SORT = Convert.ToInt16(reader["SORT"]);
|
|
|
|
|
|
#endregion
|
|
|
|
bodyList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
return bodyList;
|
|
}
|
|
|
|
|
|
|
|
|
|
public static DBResult SaveDetail(ChFeeAgentDC headData, List<ChFeeAgentDcDetail> 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 ch_fee_agentdc_detail (GID,DCGID,FEENAME,FEEENAME,CURRENCY,EXCHANGERATE,DRPP,DRCC,CRPP,CRCC,FZPR,AMOUNTDR,AMOUNTCR,UNIT,UNITPRICE,QUANTITY,FEEDESCRIPTION,SORT)
|
|
values (@GID,@DCGID,@FEENAME,@FEEENAME,@CURRENCY,@EXCHANGERATE,@DRPP,@DRCC,@CRPP,@CRCC,@FZPR,@AMOUNTDR,@AMOUNTCR,@UNIT,@UNITPRICE,@QUANTITY,@FEEDESCRIPTION,@SORT) ");
|
|
|
|
var cmdUpdate =
|
|
db.GetSqlStringCommand(
|
|
@"update ch_fee_agentdc_detail set FEENAME=@FEENAME,FEEENAME=@FEEENAME,CURRENCY=@CURRENCY,EXCHANGERATE=@EXCHANGERATE,DRPP=@DRPP,DRCC=@DRCC,CRPP=@CRPP,CRCC=@CRCC,FZPR=@FZPR
|
|
,AMOUNTDR=@AMOUNTDR,AMOUNTCR=@AMOUNTCR,UNIT=@UNIT,UNITPRICE=@UNITPRICE,QUANTITY=@QUANTITY,FEEDESCRIPTION=@FEEDESCRIPTION,SORT=@SORT
|
|
WHERE GID=@GID ");
|
|
|
|
|
|
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
|
|
if (enumValue.DCGID == "*")
|
|
{
|
|
cmdInsert.Parameters.Clear();
|
|
|
|
db.AddInParameter(cmdInsert, "@GID", DbType.String, Guid.NewGuid().ToString());
|
|
db.AddInParameter(cmdInsert, "@DCGID", DbType.String, headData.GID);
|
|
db.AddInParameter(cmdInsert, "@FEENAME", DbType.String, enumValue.FEENAME);
|
|
db.AddInParameter(cmdInsert, "@FEEENAME", DbType.String, enumValue.FEEENAME);
|
|
db.AddInParameter(cmdInsert, "@CURRENCY", DbType.String, enumValue.CURRENCY);
|
|
db.AddInParameter(cmdInsert, "@EXCHANGERATE", DbType.Decimal, enumValue.EXCHANGERATE);
|
|
db.AddInParameter(cmdInsert, "@DRPP", DbType.Decimal, enumValue.DRPP);
|
|
db.AddInParameter(cmdInsert, "@DRCC", DbType.Decimal, enumValue.DRCC);
|
|
db.AddInParameter(cmdInsert, "@CRPP", DbType.Decimal, enumValue.CRPP);
|
|
db.AddInParameter(cmdInsert, "@CRCC", DbType.Decimal, enumValue.CRCC);
|
|
db.AddInParameter(cmdInsert, "@FZPR", DbType.String, enumValue.FZPR);
|
|
db.AddInParameter(cmdInsert, "@AMOUNTDR", DbType.Decimal, enumValue.AMOUNTDR);
|
|
db.AddInParameter(cmdInsert, "@AMOUNTCR", DbType.Decimal, enumValue.AMOUNTCR);
|
|
db.AddInParameter(cmdInsert, "@UNIT", DbType.String, enumValue.UNIT);
|
|
db.AddInParameter(cmdInsert, "@UNITPRICE", DbType.Decimal, enumValue.UNITPRICE);
|
|
db.AddInParameter(cmdInsert, "@QUANTITY", DbType.Decimal, enumValue.QUANTITY);
|
|
db.AddInParameter(cmdInsert, "@FEEDESCRIPTION", DbType.String, enumValue.FEEDESCRIPTION);
|
|
db.AddInParameter(cmdInsert, "@SORT", DbType.Int32, enumValue.SORT);
|
|
db.ExecuteNonQuery(cmdInsert, tran);
|
|
}
|
|
else {
|
|
cmdUpdate.Parameters.Clear();
|
|
db.AddInParameter(cmdUpdate, "@GID", DbType.String, enumValue.GID);
|
|
db.AddInParameter(cmdUpdate, "@FEENAME", DbType.String, enumValue.FEENAME);
|
|
db.AddInParameter(cmdUpdate, "@FEEENAME", DbType.String, enumValue.FEEENAME);
|
|
db.AddInParameter(cmdUpdate, "@CURRENCY", DbType.String, enumValue.CURRENCY);
|
|
db.AddInParameter(cmdUpdate, "@EXCHANGERATE", DbType.Decimal, enumValue.EXCHANGERATE);
|
|
db.AddInParameter(cmdUpdate, "@DRPP", DbType.Decimal, enumValue.DRPP);
|
|
db.AddInParameter(cmdUpdate, "@DRCC", DbType.Decimal, enumValue.DRCC);
|
|
db.AddInParameter(cmdUpdate, "@CRPP", DbType.Decimal, enumValue.CRPP);
|
|
db.AddInParameter(cmdUpdate, "@CRCC", DbType.Decimal, enumValue.CRCC);
|
|
db.AddInParameter(cmdUpdate, "@FZPR", DbType.String, enumValue.FZPR);
|
|
db.AddInParameter(cmdUpdate, "@AMOUNTDR", DbType.Decimal, enumValue.AMOUNTDR);
|
|
db.AddInParameter(cmdUpdate, "@AMOUNTCR", DbType.Decimal, enumValue.AMOUNTCR);
|
|
db.AddInParameter(cmdUpdate, "@UNIT", DbType.String, enumValue.UNIT);
|
|
db.AddInParameter(cmdUpdate, "@UNITPRICE", DbType.Decimal, enumValue.UNITPRICE);
|
|
db.AddInParameter(cmdUpdate, "@QUANTITY", DbType.Decimal, enumValue.QUANTITY);
|
|
db.AddInParameter(cmdUpdate, "@FEEDESCRIPTION", DbType.String, enumValue.FEEDESCRIPTION);
|
|
db.AddInParameter(cmdUpdate, "@SORT", DbType.Int32, enumValue.SORT);
|
|
db.ExecuteNonQuery(cmdUpdate, tran);
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
tran.Commit();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tran.Rollback();
|
|
|
|
result.Success = false;
|
|
result.Message = "保存出现错误,请重试或联系系统管理员";
|
|
|
|
return result;
|
|
}
|
|
}
|
|
|
|
result.Success = true;
|
|
result.Message = "保存成功";
|
|
|
|
return result;
|
|
}
|
|
|
|
public static DBResult DeleteDetailList(List<ChFeeAgentDcDetail> bodyList)
|
|
{
|
|
var result = new DBResult();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
try
|
|
{
|
|
if (bodyList != null)
|
|
{
|
|
foreach (var enumValue in bodyList)
|
|
{
|
|
var cmdDelete = db.GetSqlStringCommand("delete from ch_fee_agentdc_detail where GID='" + enumValue.GID + "'");
|
|
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 = "操作成功";
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 删除
|
|
public static DBResult DeleteDetail(ChFeeAgentDC headData)
|
|
{
|
|
var result = new DBResult();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (var conn = db.CreateConnection())
|
|
{
|
|
conn.Open();
|
|
var tran = conn.BeginTransaction();
|
|
try
|
|
{
|
|
var cmdDelete = db.GetSqlStringCommand("delete from ch_fee_agentdc_detail where DCGID='" + headData.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 GetFeeCount(ChFeeAgentDC headData)
|
|
{
|
|
var isfee = false;
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("Select count(*) as count ");
|
|
strSql.Append(" from ch_fee ");
|
|
strSql.Append(" where BSNO='" + headData.BSNO + "' and CARGO_GID='"+headData.GID+"'");
|
|
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;
|
|
}
|
|
|
|
public static bool GetTruckFeeCount(string LE_ID)
|
|
{
|
|
var isfee = false;
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("Select count(*) as count ");
|
|
strSql.Append(" from ch_fee ");
|
|
strSql.Append(" where CARGO_GID='" + LE_ID + "'");
|
|
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;
|
|
}
|
|
|
|
public static bool UpdateTruckStatus(string BSNO)
|
|
{
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
var BLCOUNT = T_ALL_DA.GetStrSQL("BLCOUNT", "select sum(CTNNUM) BLCOUNT from op_ctn where BSNO='" + BSNO + "'");
|
|
if (BLCOUNT == "0")
|
|
{
|
|
var blUpSQL = " update op_seae set TRUCKSTATUS='' WHERE BSNO='" + BSNO + "'";
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
|
|
}
|
|
else {
|
|
var PCCOUNT = T_ALL_DA.GetStrSQL("PCCOUNT", "select sum(CTNNUM) PCCOUNT from op_letter_yard_ctn c left join op_letter_truck l on (l.LE_ID=c.LE_ID) where l.BSNO = '"+BSNO+"' and l.TRUCKSTATUS in ('已发单', '派车中', '已派车') ");
|
|
var blUpSQL = " update op_seae set TRUCKSTATUS='"+PCCOUNT+"/"+BLCOUNT+"' WHERE BSNO='" + BSNO + "'";
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(blUpSQL);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 参照部分
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|