|
|
using System;
|
|
|
using System.Text;
|
|
|
using System.Data;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data.SqlClient;
|
|
|
using DSWeb.Models;
|
|
|
using WebSqlHelper;
|
|
|
|
|
|
namespace DSWeb.EntityDA
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 数据访问类:wms_out_detail
|
|
|
/// </summary>
|
|
|
public partial class WmsOutDetailDA
|
|
|
{
|
|
|
public WmsOutDetailDA()
|
|
|
{ }
|
|
|
#region Method
|
|
|
|
|
|
/// <summary>
|
|
|
/// 是否存在该记录
|
|
|
/// </summary>
|
|
|
public bool Exists(string GID)
|
|
|
{
|
|
|
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
{
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("select count(1) from wms_out_detail");
|
|
|
strSql.Append(" where GID=@GID ");
|
|
|
SqlParameter[] parameters = {
|
|
|
new SqlParameter("@GID", SqlDbType.VarChar,100) };
|
|
|
parameters[0].Value = GID;
|
|
|
|
|
|
//return DbHelperSQL.Exists(strSql.ToString(), parameters);
|
|
|
try
|
|
|
{
|
|
|
return bool.Parse(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters).ToString());
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 增加一条数据
|
|
|
/// </summary>
|
|
|
public bool Add(WmsOutDetailEntity model)
|
|
|
{
|
|
|
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
{
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("insert into wms_out_detail(");
|
|
|
strSql.Append("GID,INBSNO,BSNO,CLIENTGID,CLIENTCODE,CUSTOMERNAME,DODATE,STORAGECODE,STORAGENAME,AREACODE,AREANAME,GOODSCODE,GOODSNAME,GOODSTYPE,GOODSMODEL,GOODSSTANDARD,GOODSPACK,CHARGEUNIT,GOODSPFSL,GOODSOUTFEE,CREATEUSER,CREATETIME,REMARK,GOODSPACKPFSL,GOODSOUTFEEAP,ARFEE,APFEE)");
|
|
|
strSql.Append(" values (");
|
|
|
strSql.Append("@GID,@INBSNO,@BSNO,@CLIENTGID,@CLIENTCODE,@CUSTOMERNAME,@DODATE,@STORAGECODE,@STORAGENAME,@AREACODE,@AREANAME,@GOODSCODE,@GOODSNAME,@GOODSTYPE,@GOODSMODEL,@GOODSSTANDARD,@GOODSPACK,@CHARGEUNIT,@GOODSPFSL,@GOODSOUTFEE,@CREATEUSER,getdate(),@REMARK,@GOODSPACKPFSL,@GOODSOUTFEEAP,@ARFEE,@APFEE)");
|
|
|
SqlParameter[] parameters = {
|
|
|
new SqlParameter("@GID", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@INBSNO", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@BSNO", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@CLIENTGID", SqlDbType.VarChar,36),
|
|
|
new SqlParameter("@CLIENTCODE", SqlDbType.VarChar,20),
|
|
|
new SqlParameter("@CUSTOMERNAME", SqlDbType.VarChar,20),
|
|
|
new SqlParameter("@DODATE", SqlDbType.DateTime),
|
|
|
new SqlParameter("@STORAGECODE", SqlDbType.VarChar,50),
|
|
|
new SqlParameter("@STORAGENAME", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@AREACODE", SqlDbType.VarChar,50),
|
|
|
new SqlParameter("@AREANAME", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@GOODSCODE", SqlDbType.VarChar,50),
|
|
|
new SqlParameter("@GOODSNAME", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@GOODSTYPE", SqlDbType.VarChar,50),
|
|
|
new SqlParameter("@GOODSMODEL", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@GOODSSTANDARD", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@GOODSPACK", SqlDbType.VarChar,50),
|
|
|
new SqlParameter("@CHARGEUNIT", SqlDbType.VarChar,10),
|
|
|
new SqlParameter("@GOODSPFSL", SqlDbType.Decimal),
|
|
|
new SqlParameter("@GOODSOUTFEE", SqlDbType.Decimal),
|
|
|
new SqlParameter("@CREATEUSER", SqlDbType.VarChar,36),
|
|
|
//new SqlParameter("@CREATETIME", SqlDbType.DateTime),
|
|
|
new SqlParameter("@REMARK", SqlDbType.VarChar,1024),
|
|
|
new SqlParameter("@GOODSPACKPFSL", SqlDbType.Decimal),
|
|
|
new SqlParameter("@GOODSOUTFEEAP", SqlDbType.Decimal),
|
|
|
new SqlParameter("@ARFEE", SqlDbType.Decimal),
|
|
|
new SqlParameter("@APFEE", SqlDbType.Decimal)
|
|
|
};
|
|
|
parameters[0].Value = model.GID;
|
|
|
parameters[1].Value = model.INBSNO;
|
|
|
parameters[2].Value = model.BSNO;
|
|
|
parameters[3].Value = model.CLIENTGID;
|
|
|
parameters[4].Value = model.CLIENTCODE;
|
|
|
parameters[5].Value = model.CUSTOMERNAME;
|
|
|
parameters[6].Value = model.DODATE;
|
|
|
parameters[7].Value = model.STORAGECODE;
|
|
|
parameters[8].Value = model.STORAGENAME;
|
|
|
parameters[9].Value = model.AREACODE;
|
|
|
parameters[10].Value = model.AREANAME;
|
|
|
parameters[11].Value = model.GOODSCODE;
|
|
|
parameters[12].Value = model.GOODSNAME;
|
|
|
parameters[13].Value = model.GOODSTYPE;
|
|
|
parameters[14].Value = model.GOODSMODEL;
|
|
|
parameters[15].Value = model.GOODSSTANDARD;
|
|
|
parameters[16].Value = model.GOODSPACK;
|
|
|
parameters[17].Value = model.CHARGEUNIT;
|
|
|
parameters[18].Value = model.GOODSPFSL;
|
|
|
parameters[19].Value = model.GOODSOUTFEE;
|
|
|
parameters[20].Value = model.CREATEUSER;
|
|
|
//parameters[19].Value = model.CREATETIME;
|
|
|
parameters[21].Value = model.REMARK;
|
|
|
parameters[22].Value = model.GOODSPACKPFSL;
|
|
|
parameters[23].Value = model.GOODSOUTFEEAP;
|
|
|
parameters[24].Value = model.ARFEE;
|
|
|
parameters[25].Value = model.APFEE;
|
|
|
//int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
|
|
|
int rows = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters);
|
|
|
if (rows > 0)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 更新一条数据
|
|
|
/// </summary>
|
|
|
public bool Update(WmsOutDetailEntity model)
|
|
|
{
|
|
|
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
{
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("update wms_out_detail set ");
|
|
|
strSql.Append("INBSNO=@INBSNO,");
|
|
|
strSql.Append("BSNO=@BSNO,");
|
|
|
strSql.Append("CLIENTGID=@CLIENTGID,");
|
|
|
strSql.Append("CLIENTCODE=@CLIENTCODE,");
|
|
|
strSql.Append("CUSTOMERNAME=@CUSTOMERNAME,");
|
|
|
strSql.Append("DODATE=@DODATE,");
|
|
|
strSql.Append("STORAGECODE=@STORAGECODE,");
|
|
|
strSql.Append("STORAGENAME=@STORAGENAME,");
|
|
|
strSql.Append("AREACODE=@AREACODE,");
|
|
|
strSql.Append("AREANAME=@AREANAME,");
|
|
|
strSql.Append("GOODSCODE=@GOODSCODE,");
|
|
|
strSql.Append("GOODSNAME=@GOODSNAME,");
|
|
|
strSql.Append("GOODSTYPE=@GOODSTYPE,");
|
|
|
strSql.Append("GOODSMODEL=@GOODSMODEL,");
|
|
|
strSql.Append("GOODSSTANDARD=@GOODSSTANDARD,");
|
|
|
strSql.Append("GOODSPACK=@GOODSPACK,");
|
|
|
strSql.Append("CHARGEUNIT=@CHARGEUNIT,");
|
|
|
strSql.Append("GOODSPFSL=@GOODSPFSL,");
|
|
|
strSql.Append("GOODSOUTFEE=@GOODSOUTFEE,");
|
|
|
//strSql.Append("CREATEUSER=@CREATEUSER,");
|
|
|
//strSql.Append("CREATETIME=@CREATETIME,");
|
|
|
strSql.Append("REMARK=@REMARK,");
|
|
|
strSql.Append("GOODSPACKPFSL=@GOODSPACKPFSL,");
|
|
|
strSql.Append("GOODSOUTFEEAP=@GOODSOUTFEEAP,");
|
|
|
strSql.Append("ARFEE=@ARFEE,");
|
|
|
strSql.Append("APFEE=@APFEE");
|
|
|
strSql.Append(" where GID=@GID ");
|
|
|
SqlParameter[] parameters = {
|
|
|
new SqlParameter("@INBSNO", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@BSNO", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@CLIENTGID", SqlDbType.VarChar,36),
|
|
|
new SqlParameter("@CLIENTCODE", SqlDbType.VarChar,20),
|
|
|
new SqlParameter("@CUSTOMERNAME", SqlDbType.VarChar,20),
|
|
|
new SqlParameter("@DODATE", SqlDbType.DateTime),
|
|
|
new SqlParameter("@STORAGECODE", SqlDbType.VarChar,50),
|
|
|
new SqlParameter("@STORAGENAME", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@AREACODE", SqlDbType.VarChar,50),
|
|
|
new SqlParameter("@AREANAME", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@GOODSCODE", SqlDbType.VarChar,50),
|
|
|
new SqlParameter("@GOODSNAME", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@GOODSTYPE", SqlDbType.VarChar,50),
|
|
|
new SqlParameter("@GOODSMODEL", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@GOODSSTANDARD", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@GOODSPACK", SqlDbType.VarChar,50),
|
|
|
new SqlParameter("@CHARGEUNIT", SqlDbType.VarChar,10),
|
|
|
new SqlParameter("@GOODSPFSL", SqlDbType.Decimal),
|
|
|
new SqlParameter("@GOODSOUTFEE", SqlDbType.Decimal),
|
|
|
//new SqlParameter("@CREATEUSER", SqlDbType.VarChar,36),
|
|
|
//new SqlParameter("@CREATETIME", SqlDbType.DateTime),
|
|
|
new SqlParameter("@REMARK", SqlDbType.VarChar,1024),
|
|
|
new SqlParameter("@GOODSPACKPFSL", SqlDbType.Decimal),
|
|
|
new SqlParameter("@GID", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@GOODSOUTFEEAP", SqlDbType.Decimal),
|
|
|
new SqlParameter("@ARFEE", SqlDbType.Decimal),
|
|
|
new SqlParameter("@APFEE", SqlDbType.Decimal)
|
|
|
};
|
|
|
parameters[0].Value = model.INBSNO;
|
|
|
parameters[1].Value = model.BSNO;
|
|
|
parameters[2].Value = model.CLIENTCODE;
|
|
|
parameters[3].Value = model.CLIENTCODE;
|
|
|
parameters[4].Value = model.CUSTOMERNAME;
|
|
|
parameters[5].Value = model.DODATE;
|
|
|
parameters[6].Value = model.STORAGECODE;
|
|
|
parameters[7].Value = model.STORAGENAME;
|
|
|
parameters[8].Value = model.AREACODE;
|
|
|
parameters[9].Value = model.AREANAME;
|
|
|
parameters[10].Value = model.GOODSCODE;
|
|
|
parameters[11].Value = model.GOODSNAME;
|
|
|
parameters[12].Value = model.GOODSTYPE;
|
|
|
parameters[13].Value = model.GOODSMODEL;
|
|
|
parameters[14].Value = model.GOODSSTANDARD;
|
|
|
parameters[15].Value = model.GOODSPACK;
|
|
|
parameters[16].Value = model.CHARGEUNIT;
|
|
|
parameters[17].Value = model.GOODSPFSL;
|
|
|
parameters[18].Value = model.GOODSOUTFEE;
|
|
|
parameters[19].Value = model.CREATEUSER;
|
|
|
parameters[20].Value = model.CREATETIME;
|
|
|
parameters[21].Value = model.REMARK;
|
|
|
parameters[22].Value = model.GOODSPACKPFSL;
|
|
|
parameters[23].Value = model.GID;
|
|
|
parameters[24].Value = model.GOODSOUTFEEAP;
|
|
|
parameters[25].Value = model.ARFEE;
|
|
|
parameters[26].Value = model.APFEE;
|
|
|
|
|
|
//int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
|
|
|
int rows = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters);
|
|
|
if (rows > 0)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 增加一条数据
|
|
|
/// </summary>
|
|
|
public bool Add(WmsOutDetailEntity model, string addmodel)
|
|
|
{
|
|
|
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
{
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append(" insert into wms_out_detail(");
|
|
|
strSql.Append("GID,INBSNO,OUTBSNO,BSNO,CUSTOMERNAME,DODATE,STORAGENAME,GOODSNAME,GOODSMODEL,GOODSPFSL,GOODSOUTFEE,CREATEUSER,CREATETIME,REMARK,TRUCKNO,ASSOCIATEDNO,GOODSPACKPFSL,GOODSOUTFEEAP,ARFEE,APFEE)");
|
|
|
strSql.Append(" values (");
|
|
|
strSql.Append("@GID,@INBSNO,@OUTBSNO,@BSNO,@CUSTOMERNAME,@DODATE,@STORAGENAME,@GOODSNAME,@GOODSMODEL,@GOODSPFSL,@GOODSOUTFEE,@CREATEUSER,getdate(),@REMARK,@TRUCKNO,@ASSOCIATEDNO,@GOODSPACKPFSL,@GOODSOUTFEEAP,@ARFEE,@APFEE)");
|
|
|
SqlParameter[] parameters = {
|
|
|
new SqlParameter("@GID", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@INBSNO", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@OUTBSNO", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@BSNO", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@CUSTOMERNAME", SqlDbType.VarChar,20),
|
|
|
new SqlParameter("@DODATE", SqlDbType.DateTime),
|
|
|
new SqlParameter("@STORAGENAME", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@GOODSNAME", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@GOODSMODEL", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@GOODSPFSL", SqlDbType.Decimal),
|
|
|
new SqlParameter("@GOODSOUTFEE", SqlDbType.Decimal),
|
|
|
new SqlParameter("@CREATEUSER", SqlDbType.VarChar,36),
|
|
|
new SqlParameter("@REMARK", SqlDbType.VarChar,1024),
|
|
|
new SqlParameter("@TRUCKNO", SqlDbType.VarChar,50),
|
|
|
new SqlParameter("@ASSOCIATEDNO", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@GOODSPACKPFSL", SqlDbType.Decimal),
|
|
|
new SqlParameter("@GOODSOUTFEEAP", SqlDbType.Decimal),
|
|
|
new SqlParameter("@ARFEE", SqlDbType.Decimal),
|
|
|
new SqlParameter("@APFEE", SqlDbType.Decimal)
|
|
|
};
|
|
|
parameters[0].Value = model.GID;
|
|
|
parameters[1].Value = model.INBSNO;
|
|
|
parameters[2].Value = model.OUTBSNO;
|
|
|
parameters[3].Value = model.BSNO;
|
|
|
parameters[4].Value = model.CUSTOMERNAME;
|
|
|
parameters[5].Value = model.DODATE;
|
|
|
parameters[6].Value = model.STORAGENAME;
|
|
|
parameters[7].Value = model.GOODSNAME;
|
|
|
parameters[8].Value = model.GOODSMODEL;
|
|
|
parameters[9].Value = model.GOODSPFSL;
|
|
|
parameters[10].Value = model.GOODSOUTFEE;
|
|
|
parameters[11].Value = model.CREATEUSER;
|
|
|
parameters[12].Value = model.REMARK;
|
|
|
parameters[13].Value = model.TRUCKNO;
|
|
|
parameters[14].Value = model.ASSOCIATEDNO;
|
|
|
parameters[15].Value = model.GOODSPACKPFSL;
|
|
|
parameters[16].Value = model.GOODSOUTFEEAP;
|
|
|
parameters[17].Value = model.ARFEE;
|
|
|
parameters[18].Value = model.APFEE;
|
|
|
int rows = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters);
|
|
|
if (rows > 0)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 更新一条数据
|
|
|
/// </summary>
|
|
|
public bool Update(WmsOutDetailEntity model, string updatemodel)
|
|
|
{
|
|
|
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
{
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("update wms_out_detail set ");
|
|
|
strSql.Append("GOODSPFSL=@GOODSPFSL,");
|
|
|
strSql.Append("GOODSOUTFEE=@GOODSOUTFEE");
|
|
|
strSql.Append(" where GID=@GID ");
|
|
|
SqlParameter[] parameters = {
|
|
|
new SqlParameter("@GOODSPFSL", SqlDbType.Decimal),
|
|
|
new SqlParameter("@GOODSOUTFEE", SqlDbType.Decimal),
|
|
|
new SqlParameter("@GID", SqlDbType.VarChar,100)};
|
|
|
parameters[0].Value = model.GOODSPFSL;
|
|
|
parameters[1].Value = model.GOODSOUTFEE;
|
|
|
parameters[2].Value = model.GID;
|
|
|
|
|
|
//int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
|
|
|
int rows = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters);
|
|
|
if (rows > 0)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#region 删除数据
|
|
|
/// <summary>
|
|
|
/// 删除一条数据
|
|
|
/// </summary>
|
|
|
public bool Delete(string GID)
|
|
|
{
|
|
|
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
{
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("delete from wms_out_detail ");
|
|
|
strSql.Append(" where GID=@GID ");
|
|
|
SqlParameter[] parameters = {
|
|
|
new SqlParameter("@GID", SqlDbType.VarChar,100) };
|
|
|
parameters[0].Value = GID;
|
|
|
|
|
|
//int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
|
|
|
int rows = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters);
|
|
|
if (rows > 0)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 批量删除数据
|
|
|
/// </summary>
|
|
|
public bool DeleteList(string GIDlist)
|
|
|
{
|
|
|
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
{
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("delete from wms_out_detail ");
|
|
|
strSql.Append(" where GID in (" + GIDlist + ") ");
|
|
|
//int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
|
|
|
int rows = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString());
|
|
|
if (rows > 0)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获得数据列表
|
|
|
/// <summary>
|
|
|
/// 得到一个对象实体
|
|
|
/// </summary>
|
|
|
public WmsOutDetailEntity GetModel(string GID)
|
|
|
{
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("select top 1 GID,INBSNO,BSNO,CLIENTGID,CLIENTCODE,CUSTOMERNAME,DODATE,STORAGECODE,STORAGENAME,AREACODE,AREANAME,GOODSCODE,GOODSNAME,GOODSTYPE,GOODSMODEL,GOODSSTANDARD,GOODSPACK,CHARGEUNIT,GOODSPFSL,GOODSOUTFEE,CREATEUSER,CREATETIME,REMARK,GOODSPACKPFSL,GOODSOUTFEEAP,ARFEE,APFEE,ISCHANGE from wms_out_detail ");
|
|
|
strSql.Append(" where GID=@GID ");
|
|
|
SqlParameter[] parameters = {
|
|
|
new SqlParameter("@GID", SqlDbType.VarChar,100) };
|
|
|
parameters[0].Value = GID;
|
|
|
|
|
|
WmsOutDetailEntity model = new WmsOutDetailEntity();
|
|
|
using(SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString(), parameters))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
while (sqlRead.Read())
|
|
|
{
|
|
|
if (sqlRead["GID"] != null && sqlRead["GID"].ToString() != "")
|
|
|
{
|
|
|
model.GID = sqlRead["GID"].ToString();
|
|
|
}
|
|
|
if (sqlRead["INBSNO"] != null && sqlRead["INBSNO"].ToString() != "")
|
|
|
{
|
|
|
model.INBSNO = sqlRead["INBSNO"].ToString();
|
|
|
}
|
|
|
if (sqlRead["BSNO"] != null && sqlRead["BSNO"].ToString() != "")
|
|
|
{
|
|
|
model.BSNO = sqlRead["BSNO"].ToString();
|
|
|
}
|
|
|
if (sqlRead["CLIENTGID"] != null && sqlRead["CLIENTGID"].ToString() != "")
|
|
|
{
|
|
|
model.CLIENTGID = sqlRead["CLIENTGID"].ToString();
|
|
|
}
|
|
|
if (sqlRead["CLIENTCODE"] != null && sqlRead["CLIENTCODE"].ToString() != "")
|
|
|
{
|
|
|
model.CLIENTCODE = sqlRead["CLIENTCODE"].ToString();
|
|
|
}
|
|
|
if (sqlRead["CUSTOMERNAME"] != null && sqlRead["CUSTOMERNAME"].ToString() != "")
|
|
|
{
|
|
|
model.CUSTOMERNAME = sqlRead["CUSTOMERNAME"].ToString();
|
|
|
}
|
|
|
if (sqlRead["DODATE"] != null && sqlRead["DODATE"].ToString() != "")
|
|
|
{
|
|
|
model.DODATE = DateTime.Parse(sqlRead["DODATE"].ToString());
|
|
|
}
|
|
|
if (sqlRead["STORAGECODE"] != null && sqlRead["STORAGECODE"].ToString() != "")
|
|
|
{
|
|
|
model.STORAGECODE = sqlRead["STORAGECODE"].ToString();
|
|
|
}
|
|
|
if (sqlRead["STORAGENAME"] != null && sqlRead["STORAGENAME"].ToString() != "")
|
|
|
{
|
|
|
model.STORAGENAME = sqlRead["STORAGENAME"].ToString();
|
|
|
}
|
|
|
if (sqlRead["AREACODE"] != null && sqlRead["AREACODE"].ToString() != "")
|
|
|
{
|
|
|
model.AREACODE = sqlRead["AREACODE"].ToString();
|
|
|
}
|
|
|
if (sqlRead["AREANAME"] != null && sqlRead["AREANAME"].ToString() != "")
|
|
|
{
|
|
|
model.AREANAME = sqlRead["AREANAME"].ToString();
|
|
|
}
|
|
|
if (sqlRead["GOODSCODE"] != null && sqlRead["GOODSCODE"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSCODE = sqlRead["GOODSCODE"].ToString();
|
|
|
}
|
|
|
if (sqlRead["GOODSNAME"] != null && sqlRead["GOODSNAME"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSNAME = sqlRead["GOODSNAME"].ToString();
|
|
|
}
|
|
|
if (sqlRead["GOODSTYPE"] != null && sqlRead["GOODSTYPE"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSTYPE = sqlRead["GOODSTYPE"].ToString();
|
|
|
}
|
|
|
if (sqlRead["GOODSMODEL"] != null && sqlRead["GOODSMODEL"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSMODEL = sqlRead["GOODSMODEL"].ToString();
|
|
|
}
|
|
|
if (sqlRead["GOODSSTANDARD"] != null && sqlRead["GOODSSTANDARD"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSSTANDARD = sqlRead["GOODSSTANDARD"].ToString();
|
|
|
}
|
|
|
if (sqlRead["GOODSPACK"] != null && sqlRead["GOODSPACK"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSPACK = sqlRead["GOODSPACK"].ToString();
|
|
|
}
|
|
|
if (sqlRead["CHARGEUNIT"] != null && sqlRead["CHARGEUNIT"].ToString() != "")
|
|
|
{
|
|
|
model.CHARGEUNIT = sqlRead["CHARGEUNIT"].ToString();
|
|
|
}
|
|
|
if (sqlRead["GOODSPFSL"] != null && sqlRead["GOODSPFSL"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSPFSL = decimal.Parse(sqlRead["GOODSPFSL"].ToString());
|
|
|
}
|
|
|
if (sqlRead["GOODSOUTFEE"] != null && sqlRead["GOODSOUTFEE"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSOUTFEE = decimal.Parse(sqlRead["GOODSOUTFEE"].ToString());
|
|
|
}
|
|
|
if (sqlRead["CREATEUSER"] != null && sqlRead["CREATEUSER"].ToString() != "")
|
|
|
{
|
|
|
model.CREATEUSER = sqlRead["CREATEUSER"].ToString();
|
|
|
}
|
|
|
if (sqlRead["CREATETIME"] != null && sqlRead["CREATETIME"].ToString() != "")
|
|
|
{
|
|
|
model.CREATETIME = DateTime.Parse(sqlRead["CREATETIME"].ToString());
|
|
|
}
|
|
|
if (sqlRead["REMARK"] != null && sqlRead["REMARK"].ToString() != "")
|
|
|
{
|
|
|
model.REMARK = sqlRead["REMARK"].ToString();
|
|
|
}
|
|
|
if (sqlRead["GOODSPACKPFSL"] != null && sqlRead["GOODSPACKPFSL"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSPACKPFSL = decimal.Parse(sqlRead["GOODSPACKPFSL"].ToString());
|
|
|
}
|
|
|
if (sqlRead["GOODSOUTFEEAP"] != null && sqlRead["GOODSOUTFEEAP"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSOUTFEEAP = decimal.Parse(sqlRead["GOODSOUTFEEAP"].ToString());
|
|
|
}
|
|
|
if (sqlRead["ARFEE"] != null && sqlRead["ARFEE"].ToString() != "")
|
|
|
{
|
|
|
model.ARFEE = decimal.Parse(sqlRead["ARFEE"].ToString());
|
|
|
}
|
|
|
if (sqlRead["APFEE"] != null && sqlRead["APFEE"].ToString() != "")
|
|
|
{
|
|
|
model.APFEE = decimal.Parse(sqlRead["APFEE"].ToString());
|
|
|
}
|
|
|
if (sqlRead["ISCHANGE"] != null && sqlRead["ISCHANGE"].ToString() != "")
|
|
|
{
|
|
|
if ((sqlRead["ISCHANGE"].ToString() == "1") || (sqlRead["ISCHANGE"].ToString().ToLower() == "true"))
|
|
|
{
|
|
|
model.ISCHANGE = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
model.ISCHANGE = false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception exceError)
|
|
|
{
|
|
|
//抛出异常
|
|
|
throw exceError;
|
|
|
}
|
|
|
}
|
|
|
return model;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获得数据列表
|
|
|
/// </summary>
|
|
|
public List<WmsOutDetailEntity> GetModels(string strWhere)
|
|
|
{
|
|
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("select GID,INBSNO,BSNO,CLIENTGID,CLIENTCODE,CUSTOMERNAME,DODATE,STORAGECODE,STORAGENAME,AREACODE,AREANAME,GOODSCODE,GOODSNAME,GOODSTYPE,GOODSMODEL,GOODSSTANDARD,GOODSPACK,CHARGEUNIT,GOODSPFSL,GOODSOUTFEE,CREATEUSER,CREATETIME,REMARK,GOODSPACKPFSL,GOODSOUTFEEAP,ARFEE,APFEE ");
|
|
|
strSql.Append(" FROM wms_out_detail ");
|
|
|
if (strWhere.Trim() != "")
|
|
|
{
|
|
|
strSql.Append(" where " + strWhere);
|
|
|
}
|
|
|
//return DbHelperSQL.Query(strSql.ToString());
|
|
|
//return SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString());
|
|
|
List<WmsOutDetailEntity> models = new List<WmsOutDetailEntity>();
|
|
|
WmsOutDetailEntity model = new WmsOutDetailEntity();
|
|
|
using (SqlDataReader sqlRead = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString(), null))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
while (sqlRead.Read())
|
|
|
{
|
|
|
if (sqlRead["GID"] != null && sqlRead["GID"].ToString() != "")
|
|
|
{
|
|
|
model.GID = sqlRead["GID"].ToString();
|
|
|
}
|
|
|
if (sqlRead["INBSNO"] != null && sqlRead["INBSNO"].ToString() != "")
|
|
|
{
|
|
|
model.INBSNO = sqlRead["INBSNO"].ToString();
|
|
|
}
|
|
|
if (sqlRead["BSNO"] != null && sqlRead["BSNO"].ToString() != "")
|
|
|
{
|
|
|
model.BSNO = sqlRead["BSNO"].ToString();
|
|
|
}
|
|
|
if (sqlRead["CLIENTGID"] != null && sqlRead["CLIENTGID"].ToString() != "")
|
|
|
{
|
|
|
model.CLIENTGID = sqlRead["CLIENTGID"].ToString();
|
|
|
}
|
|
|
if (sqlRead["CLIENTCODE"] != null && sqlRead["CLIENTCODE"].ToString() != "")
|
|
|
{
|
|
|
model.CLIENTCODE = sqlRead["CLIENTCODE"].ToString();
|
|
|
}
|
|
|
if (sqlRead["CUSTOMERNAME"] != null && sqlRead["CUSTOMERNAME"].ToString() != "")
|
|
|
{
|
|
|
model.CUSTOMERNAME = sqlRead["CUSTOMERNAME"].ToString();
|
|
|
}
|
|
|
if (sqlRead["DODATE"] != null && sqlRead["DODATE"].ToString() != "")
|
|
|
{
|
|
|
model.DODATE = DateTime.Parse(sqlRead["DODATE"].ToString());
|
|
|
}
|
|
|
if (sqlRead["STORAGECODE"] != null && sqlRead["STORAGECODE"].ToString() != "")
|
|
|
{
|
|
|
model.STORAGECODE = sqlRead["STORAGECODE"].ToString();
|
|
|
}
|
|
|
if (sqlRead["STORAGENAME"] != null && sqlRead["STORAGENAME"].ToString() != "")
|
|
|
{
|
|
|
model.STORAGENAME = sqlRead["STORAGENAME"].ToString();
|
|
|
}
|
|
|
if (sqlRead["AREACODE"] != null && sqlRead["AREACODE"].ToString() != "")
|
|
|
{
|
|
|
model.AREACODE = sqlRead["AREACODE"].ToString();
|
|
|
}
|
|
|
if (sqlRead["AREANAME"] != null && sqlRead["AREANAME"].ToString() != "")
|
|
|
{
|
|
|
model.AREANAME = sqlRead["AREANAME"].ToString();
|
|
|
}
|
|
|
if (sqlRead["GOODSCODE"] != null && sqlRead["GOODSCODE"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSCODE = sqlRead["GOODSCODE"].ToString();
|
|
|
}
|
|
|
if (sqlRead["GOODSNAME"] != null && sqlRead["GOODSNAME"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSNAME = sqlRead["GOODSNAME"].ToString();
|
|
|
}
|
|
|
if (sqlRead["GOODSTYPE"] != null && sqlRead["GOODSTYPE"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSTYPE = sqlRead["GOODSTYPE"].ToString();
|
|
|
}
|
|
|
if (sqlRead["GOODSMODEL"] != null && sqlRead["GOODSMODEL"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSMODEL = sqlRead["GOODSMODEL"].ToString();
|
|
|
}
|
|
|
if (sqlRead["GOODSSTANDARD"] != null && sqlRead["GOODSSTANDARD"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSSTANDARD = sqlRead["GOODSSTANDARD"].ToString();
|
|
|
}
|
|
|
if (sqlRead["GOODSPACK"] != null && sqlRead["GOODSPACK"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSPACK = sqlRead["GOODSPACK"].ToString();
|
|
|
}
|
|
|
if (sqlRead["CHARGEUNIT"] != null && sqlRead["CHARGEUNIT"].ToString() != "")
|
|
|
{
|
|
|
model.CHARGEUNIT = sqlRead["CHARGEUNIT"].ToString();
|
|
|
}
|
|
|
if (sqlRead["GOODSPFSL"] != null && sqlRead["GOODSPFSL"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSPFSL = decimal.Parse(sqlRead["GOODSPFSL"].ToString());
|
|
|
}
|
|
|
if (sqlRead["GOODSOUTFEE"] != null && sqlRead["GOODSOUTFEE"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSOUTFEE = decimal.Parse(sqlRead["GOODSOUTFEE"].ToString());
|
|
|
}
|
|
|
if (sqlRead["CREATEUSER"] != null && sqlRead["CREATEUSER"].ToString() != "")
|
|
|
{
|
|
|
model.CREATEUSER = sqlRead["CREATEUSER"].ToString();
|
|
|
}
|
|
|
if (sqlRead["CREATETIME"] != null && sqlRead["CREATETIME"].ToString() != "")
|
|
|
{
|
|
|
model.CREATETIME = DateTime.Parse(sqlRead["CREATETIME"].ToString());
|
|
|
}
|
|
|
if (sqlRead["REMARK"] != null && sqlRead["REMARK"].ToString() != "")
|
|
|
{
|
|
|
model.REMARK = sqlRead["REMARK"].ToString();
|
|
|
}
|
|
|
if (sqlRead["GOODSPACKPFSL"] != null && sqlRead["GOODSPACKPFSL"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSPACKPFSL = decimal.Parse(sqlRead["GOODSPACKPFSL"].ToString());
|
|
|
}
|
|
|
if (sqlRead["GOODSOUTFEEAP"] != null && sqlRead["GOODSOUTFEEAP"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSOUTFEEAP = decimal.Parse(sqlRead["GOODSOUTFEEAP"].ToString());
|
|
|
}
|
|
|
if (sqlRead["ARFEE"] != null && sqlRead["ARFEE"].ToString() != "")
|
|
|
{
|
|
|
model.ARFEE = decimal.Parse(sqlRead["ARFEE"].ToString());
|
|
|
}
|
|
|
if (sqlRead["APFEE"] != null && sqlRead["APFEE"].ToString() != "")
|
|
|
{
|
|
|
model.APFEE = decimal.Parse(sqlRead["APFEE"].ToString());
|
|
|
}
|
|
|
models.Add(model);
|
|
|
}
|
|
|
return models;
|
|
|
}
|
|
|
catch (Exception exceError)
|
|
|
{
|
|
|
//抛出异常
|
|
|
throw exceError;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获得数据列表
|
|
|
/// </summary>
|
|
|
public DataSet GetList(string strWhere)
|
|
|
{
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("select GID,INBSNO,BSNO,CLIENTGID,CLIENTCODE,CUSTOMERNAME,DODATE,STORAGECODE,STORAGENAME,AREACODE,AREANAME,GOODSCODE,GOODSNAME,GOODSTYPE,GOODSMODEL,GOODSSTANDARD,GOODSPACK,CHARGEUNIT,GOODSPFSL,GOODSOUTFEE,CREATEUSER,CREATETIME,REMARK,GOODSPACKPFSL,GOODSOUTFEEAP,ARFEE,APFEE ");
|
|
|
strSql.Append(" FROM wms_out_detail ");
|
|
|
if (strWhere.Trim() != "")
|
|
|
{
|
|
|
strSql.Append(" where " + strWhere);
|
|
|
}
|
|
|
//return DbHelperSQL.Query(strSql.ToString());
|
|
|
return SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString());
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获得前几行数据
|
|
|
/// <summary>
|
|
|
/// 获得前几行数据
|
|
|
/// </summary>
|
|
|
public DataSet GetList(int Top, string strWhere, string filedOrder)
|
|
|
{
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("select ");
|
|
|
if (Top > 0)
|
|
|
{
|
|
|
strSql.Append(" top " + Top.ToString());
|
|
|
}
|
|
|
strSql.Append(" GID,INBSNO,BSNO,CLIENTGID,CLIENTCODE,CUSTOMERNAME,DODATE,STORAGECODE,STORAGENAME,AREACODE,AREANAME,GOODSCODE,GOODSNAME,GOODSTYPE,GOODSMODEL,GOODSSTANDARD,GOODSPACK,CHARGEUNIT,GOODSPFSL,GOODSOUTFEE,CREATEUSER,CREATETIME,REMARK,GOODSPACKPFSL,GOODSOUTFEEAP,ARFEE,APFEE ");
|
|
|
strSql.Append(" FROM wms_out_detail ");
|
|
|
if (strWhere.Trim() != "")
|
|
|
{
|
|
|
strSql.Append(" where " + strWhere);
|
|
|
}
|
|
|
strSql.Append(" order by " + filedOrder);
|
|
|
//return DbHelperSQL.Query(strSql.ToString());
|
|
|
return SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString());
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获取记录总数
|
|
|
/// <summary>
|
|
|
/// 获取记录总数
|
|
|
/// </summary>
|
|
|
public int GetRecordCount(string strWhere)
|
|
|
{
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("select count(1) FROM wms_out_detail ");
|
|
|
if (strWhere.Trim() != "")
|
|
|
{
|
|
|
strSql.Append(" where " + strWhere);
|
|
|
}
|
|
|
//object obj = DbHelperSQL.GetSingle(strSql.ToString());
|
|
|
object obj = SqlHelper.GetSingle(SqlHelper.ConnectionStringLocalTransaction, strSql.ToString());
|
|
|
if (obj == null)
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return Convert.ToInt32(obj);
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 分页获取数据列表
|
|
|
/// <summary>
|
|
|
/// 分页获取数据列表
|
|
|
/// </summary>
|
|
|
public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
|
|
|
{
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT * FROM ( ");
|
|
|
strSql.Append(" SELECT ROW_NUMBER() OVER (");
|
|
|
if (!string.IsNullOrEmpty(orderby.Trim()))
|
|
|
{
|
|
|
strSql.Append("order by T." + orderby);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strSql.Append("order by T.GID desc");
|
|
|
}
|
|
|
strSql.Append(")AS Row, T.* from wms_out_detail T ");
|
|
|
if (!string.IsNullOrEmpty(strWhere.Trim()))
|
|
|
{
|
|
|
strSql.Append(" WHERE " + strWhere);
|
|
|
}
|
|
|
strSql.Append(" ) TT");
|
|
|
strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
|
|
|
//return DbHelperSQL.Query(strSql.ToString());
|
|
|
return SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString());
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 分页获取数据列表
|
|
|
/// </summary>
|
|
|
public DataSet GetList(int PageSize,int PageIndex,string strWhere)
|
|
|
{
|
|
|
SqlParameter[] parameters = {
|
|
|
new SqlParameter("@tblName", SqlDbType.VarChar, 255),
|
|
|
new SqlParameter("@fldName", SqlDbType.VarChar, 255),
|
|
|
new SqlParameter("@PageSize", SqlDbType.Int),
|
|
|
new SqlParameter("@PageIndex", SqlDbType.Int),
|
|
|
new SqlParameter("@IsReCount", SqlDbType.Bit),
|
|
|
new SqlParameter("@OrderType", SqlDbType.Bit),
|
|
|
new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
|
|
|
};
|
|
|
parameters[0].Value = "wms_out_detail";
|
|
|
parameters[1].Value = "GID";
|
|
|
parameters[2].Value = PageSize;
|
|
|
parameters[3].Value = PageIndex;
|
|
|
parameters[4].Value = 0;
|
|
|
parameters[5].Value = 0;
|
|
|
parameters[6].Value = strWhere;
|
|
|
//return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
|
|
|
return SqlHelper.RunProcedure(SqlHelper.ConnectionStringLocalTransaction, "UP_GetRecordByPage", parameters, "ds");
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 根据SQL语句查询仓储费率数据集
|
|
|
/// <summary>
|
|
|
/// 根据SQL语句查询仓储费率数据集
|
|
|
/// </summary>
|
|
|
/// <param name="strSql"></param>
|
|
|
/// <returns></returns>
|
|
|
public DataSet GetRateListByCondition(string strSql)
|
|
|
{
|
|
|
DataSet userSet = new DataSet();
|
|
|
|
|
|
userSet = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql);
|
|
|
return userSet;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算仓储时间差 +1
|
|
|
/// <summary>
|
|
|
/// 计算仓储时间差 +1
|
|
|
/// </summary>
|
|
|
public int GetDaysCount(string ymd, string indate, string outdate)
|
|
|
{
|
|
|
string strSql = String.Format(" select datediff({0},'{1}','{2}') ", ymd, indate, outdate);
|
|
|
if (ymd == "day")
|
|
|
{
|
|
|
strSql = String.Format(" select datediff({0},'{1}','{2}')+1 ", ymd, indate, outdate);
|
|
|
}
|
|
|
object obj = SqlHelper.GetSingle(SqlHelper.ConnectionStringLocalTransaction, strSql.ToString());
|
|
|
if (obj == null)
|
|
|
{
|
|
|
return 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (ymd == "month")
|
|
|
{
|
|
|
int inum = int.Parse(obj.ToString());
|
|
|
DateTime dt = DateTime.Parse(indate).AddMonths(inum).AddDays(-1);
|
|
|
if (DateTime.Parse(outdate) > dt)
|
|
|
{
|
|
|
inum = inum + 1;
|
|
|
return Convert.ToInt32(inum);
|
|
|
}
|
|
|
}
|
|
|
return Convert.ToInt32(obj);
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 计算仓储费
|
|
|
/// <summary>
|
|
|
/// 计算仓储费
|
|
|
/// </summary>
|
|
|
/// <param name="sqlTran">事务</param>
|
|
|
/// <param name="strSTARTBILLINGDATE">开始计费日期</param>
|
|
|
/// <param name="strOLDCUSTFEEDATE">上家承担仓储期限</param>
|
|
|
/// <param name="strINBSNO">出库明细关联的入库单wms或wms_in的BSNO</param>
|
|
|
/// <param name="strCUSTOMERNAME">出库主表的客户名称</param>
|
|
|
/// <param name="outnums">出库量</param>
|
|
|
/// <param name="strASSOCIATEDNO">关联wms_out_detail的GID</param>
|
|
|
/// <param name="strFEETYPE">区别费用收、付类型</param>
|
|
|
/// <param name="strUserID">登陆用户GID</param>
|
|
|
/// <param name="strShowName">登陆用户名</param>
|
|
|
/// <param name="sBillno">出库单号或其他单据号</param>
|
|
|
/// <param name="ck_jsfee">是否计算仓储费</param>
|
|
|
/// <returns></returns>
|
|
|
public String getWmsRate(SqlTransaction sqlTran, string strSTARTBILLINGDATE, string strOLDCUSTFEEDATE, string strINBSNO, string strCUSTOMERNAME,
|
|
|
Decimal outnums, string strASSOCIATEDNO, int strFEETYPE, string strUserID, string strShowName,string sBillno,bool ck_jsfee,bool isKuCun)
|
|
|
{
|
|
|
string sR = "";
|
|
|
int iState = 0;
|
|
|
int result = 0;
|
|
|
string Sqlstr = "";
|
|
|
|
|
|
#region 计算仓储费
|
|
|
WmsOutDetailDA WmsOutDetailDA = new EntityDA.WmsOutDetailDA();
|
|
|
IList<WmsRateDetailEntity> tempWmsRateDetailEntities = new List<WmsRateDetailEntity>();
|
|
|
int totalfeedays = 0;//总计费区间仓储天数
|
|
|
int feedays = 0;//区间仓储数
|
|
|
int prescale = 0;//总计费区间仓储数
|
|
|
int feeMonth = 0;//区间仓储月数
|
|
|
Decimal sumfee = 0;//总仓储费
|
|
|
string strSTARTBILLINGDATE2 = strSTARTBILLINGDATE;//按区间计费的开始计费日期
|
|
|
|
|
|
#region 删除费率出库明细表的区间仓储费
|
|
|
Sqlstr = "delete from wms_rate_detail where ASSOCIATEDNO = '" + strASSOCIATEDNO.Trim() + "' and FEETYPE=" + strFEETYPE;
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState < 0)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -9;
|
|
|
//Clearh();
|
|
|
return result.ToString();
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
if (ck_jsfee)//是否计算仓储费
|
|
|
{
|
|
|
#region 如果入库有免仓储期,则出库时插入费率出库明细表
|
|
|
//按仓储费率计算仓储费
|
|
|
Sqlstr = "SELECT top 1 * FROM wms where GID='" + strINBSNO + "' or gid in (select ASSOCIATEDNO from wms_in where gid='" + strINBSNO + "')";
|
|
|
DataSet dsrate = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (dsrate != null)
|
|
|
{
|
|
|
if (dsrate.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
string sAP = dsrate.Tables[0].Rows[0]["FREESTORAGEPERIOD"].ToString().Trim();
|
|
|
if (strFEETYPE == 2)
|
|
|
{
|
|
|
sAP = dsrate.Tables[0].Rows[0]["FREESTORAGEPERIODAP"].ToString().Trim();
|
|
|
}
|
|
|
if (sAP != "0")
|
|
|
{
|
|
|
WmsRateDetailEntity model3 = new WmsRateDetailEntity();
|
|
|
model3.FEEPRICE = 0;
|
|
|
model3.GOODSPFSL = outnums;
|
|
|
model3.OUTFEE = 0;
|
|
|
model3.FEEUNIT = dsrate.Tables[0].Rows[0]["CHARGEUNIT"].ToString().Trim() + "天";
|
|
|
model3.STARTBILLINGDATE = DateTime.Parse(dsrate.Tables[0].Rows[0]["WMSDATE"].ToString().Trim());
|
|
|
DateTime dt = DateTime.Parse(dsrate.Tables[0].Rows[0]["STARTBILLINGDATE"].ToString().Trim()).AddDays(-1);
|
|
|
if (DateTime.Parse(strOLDCUSTFEEDATE) < dt)
|
|
|
{
|
|
|
dt = DateTime.Parse(strOLDCUSTFEEDATE);
|
|
|
}
|
|
|
model3.ENDBILLINGDATE = dt;
|
|
|
model3.FEESCALE = int.Parse(WmsOutDetailDA.GetDaysCount("day", model3.STARTBILLINGDATE.ToString().Trim(), dt.ToString().Trim()).ToString());
|
|
|
model3.FEEGRADE = 0;
|
|
|
model3.REMARK = "";
|
|
|
model3.CREATEUSER = strUserID;
|
|
|
model3.MODIFIEDUSER = strUserID;
|
|
|
model3.ASSOCIATEDNO = strASSOCIATEDNO;
|
|
|
model3.CUSTOMERNAME = strCUSTOMERNAME;
|
|
|
model3.FEETYPE = strFEETYPE;
|
|
|
tempWmsRateDetailEntities.Add(model3);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
feedays = WmsOutDetailDA.GetDaysCount("day", strSTARTBILLINGDATE, strOLDCUSTFEEDATE.Trim());//WmsOutEntity.DODATE.ToString() 出库-开始计费日期+1
|
|
|
if (feedays > 0)
|
|
|
{
|
|
|
totalfeedays = feedays;
|
|
|
//按仓储费率计算仓储费
|
|
|
Sqlstr = "SELECT GID,FEEGRADE,FEETYPE,FEESCALE,FEEPRICE,ADDPRICE,FEEUNIT,convert(char(10),ENDBILLINGDATE,20) AS ENDBILLINGDATE,REMARK,CREATEUSER,CREATETIME,BSNO,CAPPRICE FROM wms_rate where (BSNO='" + strINBSNO + "' or BSNO in (select ASSOCIATEDNO from wms_in where gid='" + strINBSNO + "')) and FEETYPE=" + strFEETYPE + " order by FEEGRADE ";
|
|
|
dsrate = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (dsrate != null)
|
|
|
{
|
|
|
if (dsrate.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
int nowscale = 0;//区间计费区间(仓储月数/天数)
|
|
|
Decimal price = 0;//计费单价
|
|
|
Decimal gradefee = 0;//区间仓储费
|
|
|
int nowgrade = 1;
|
|
|
|
|
|
for (int i = 0; i < dsrate.Tables[0].Rows.Count; i++)
|
|
|
{
|
|
|
if (isKuCun)
|
|
|
{
|
|
|
if (DateTime.Parse(strSTARTBILLINGDATE) > DateTime.Parse(dsrate.Tables[0].Rows[i]["ENDBILLINGDATE"].ToString()))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
WmsRateDetailEntity model = new WmsRateDetailEntity();
|
|
|
//nowgrade = int.Parse(dsrate.Tables[0].Rows[i]["FEEGRADE"].ToString());//计费等级
|
|
|
nowscale = int.Parse(dsrate.Tables[0].Rows[i]["FEESCALE"].ToString());//计费区间
|
|
|
price = Decimal.Parse(dsrate.Tables[0].Rows[i]["FEEPRICE"].ToString());//计费单价
|
|
|
Decimal ADDPRICE = Decimal.Parse(dsrate.Tables[0].Rows[i]["ADDPRICE"].ToString());//增值价
|
|
|
Decimal CAPPRICE = Decimal.Parse(dsrate.Tables[0].Rows[i]["CAPPRICE"].ToString());//
|
|
|
string FEEUNIT = dsrate.Tables[0].Rows[i]["FEEUNIT"].ToString();//计费单位
|
|
|
string ENDBILLINGDATE = dsrate.Tables[0].Rows[i]["ENDBILLINGDATE"].ToString();//结束计费日期
|
|
|
//计算区间是按天或按月
|
|
|
string DorM = "day";
|
|
|
if (FEEUNIT.IndexOf("月") > -1)
|
|
|
{
|
|
|
DorM = "month";
|
|
|
}
|
|
|
#region 按区间计算仓储费
|
|
|
feedays = WmsOutDetailDA.GetDaysCount(DorM, strSTARTBILLINGDATE2, strOLDCUSTFEEDATE.Trim());//总仓储月数
|
|
|
if (feedays > nowscale) //总仓储月数 > 区间计费区间(仓储月数/天数)
|
|
|
{
|
|
|
feeMonth = WmsOutDetailDA.GetDaysCount(DorM, strSTARTBILLINGDATE2, ENDBILLINGDATE.Trim());//i区间仓储月数
|
|
|
if (feeMonth > nowscale)//i区间仓储月数 > 区间计费区间(仓储月数/天数)
|
|
|
{
|
|
|
int sjMonth = 0;//实际仓储月数
|
|
|
int sjMonth2 = 0;//实际仓储月数,如果是最后一条的判断数
|
|
|
if (feedays > feeMonth)//总仓储月数 > i区间仓储月数
|
|
|
{
|
|
|
sjMonth = nowscale;// feeMonth;// (feeMonth - nowscale);//实际仓储月数
|
|
|
sjMonth2 = feeMonth;//实际仓储月数,如果是最后一条的判断数
|
|
|
if ((i + 1) == dsrate.Tables[0].Rows.Count)//即最后一条时,以后的时间都按最后一条取值
|
|
|
{
|
|
|
if (ADDPRICE <= 0)//增值价>0,则求增值费率
|
|
|
{
|
|
|
sjMonth = feedays;//(feedays - nowscale);//实际仓储月数
|
|
|
ENDBILLINGDATE = strOLDCUSTFEEDATE;
|
|
|
}
|
|
|
sjMonth2 = feedays;// (feedays - nowscale);//实际仓储月数
|
|
|
}
|
|
|
}
|
|
|
else//总仓储月数 <= i区间仓储月数
|
|
|
{
|
|
|
//sjMonth = feedays;//(feedays - nowscale);//实际仓储月数
|
|
|
sjMonth = nowscale;// feeMonth;// (feeMonth - nowscale);//实际仓储月数
|
|
|
sjMonth2 = feedays;//实际仓储月数,如果是最后一条的判断数
|
|
|
ENDBILLINGDATE = strOLDCUSTFEEDATE;
|
|
|
}
|
|
|
//
|
|
|
#region 增值价>0,则求增值费率
|
|
|
if (ADDPRICE > 0)//增值价>0,则求增值费率
|
|
|
{
|
|
|
//int idiv = (int)(sjMonth / nowscale);
|
|
|
//int imod = (int)(sjMonth % nowscale);
|
|
|
int idiv = (int)(sjMonth2 / nowscale);
|
|
|
int imod = (int)(sjMonth2 % nowscale);
|
|
|
Decimal dprice = price;//计费单价
|
|
|
for (int j = 0; j < idiv; j++)//循环求增值费率
|
|
|
{
|
|
|
//--- BEGIN --- 如果是月则计算开始和结束日期之间的天数
|
|
|
DateTime dtSTARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
|
|
|
DateTime dtENDBILLINGDATE = dtSTARTBILLINGDATE.AddDays(nowscale - 1);
|
|
|
int dtDays = sjMonth;// nowscale;
|
|
|
|
|
|
string FEEUNIT2 = FEEUNIT;
|
|
|
if (FEEUNIT.IndexOf("月") > -1)
|
|
|
{
|
|
|
dtENDBILLINGDATE = dtSTARTBILLINGDATE.AddMonths(nowscale).AddDays(-1);
|
|
|
if (dtENDBILLINGDATE > DateTime.Parse(ENDBILLINGDATE))//strOLDCUSTFEEDATE
|
|
|
{
|
|
|
if ((i + 1) == dsrate.Tables[0].Rows.Count && dtENDBILLINGDATE > DateTime.Parse(strOLDCUSTFEEDATE))//即最后一条时,以后的时间都按最后一条取值
|
|
|
{
|
|
|
dtENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
dtENDBILLINGDATE = DateTime.Parse(ENDBILLINGDATE);//strOLDCUSTFEEDATE
|
|
|
}
|
|
|
}
|
|
|
FEEUNIT2 = FEEUNIT.Trim().Substring(0, 1) + "天";
|
|
|
dtDays = WmsOutDetailDA.GetDaysCount("day", dtSTARTBILLINGDATE.ToString().Trim(), dtENDBILLINGDATE.ToString().Trim());//按月的区间天数
|
|
|
}
|
|
|
//--- END ---
|
|
|
|
|
|
gradefee = outnums * dprice * dtDays;// nowscale;//出库量*计费单价*实际仓储月数
|
|
|
sumfee += gradefee;
|
|
|
prescale += dtDays;//nowscale;//累计天数
|
|
|
//
|
|
|
WmsRateDetailEntity model1 = new WmsRateDetailEntity();
|
|
|
model1.FEEPRICE = dprice;
|
|
|
model1.GOODSPFSL = outnums;
|
|
|
model1.FEESCALE = dtDays;// nowscale;
|
|
|
model1.OUTFEE = gradefee;
|
|
|
model1.FEEUNIT = FEEUNIT2;
|
|
|
model1.STARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
|
|
|
model1.ENDBILLINGDATE = dtENDBILLINGDATE;
|
|
|
//model1.ENDBILLINGDATE = model1.STARTBILLINGDATE.AddDays(nowscale - 1);
|
|
|
//if (FEEUNIT.IndexOf("月") > -1)
|
|
|
//{
|
|
|
// DateTime dt = model1.STARTBILLINGDATE.AddMonths(nowscale).AddDays(-1);
|
|
|
// model1.ENDBILLINGDATE = dt;
|
|
|
// if (dt > DateTime.Parse(strOLDCUSTFEEDATE))
|
|
|
// {
|
|
|
// model1.ENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
|
|
|
// }
|
|
|
//}
|
|
|
model1.FEEGRADE = nowgrade;
|
|
|
model1.REMARK = "";
|
|
|
model1.CREATEUSER = strUserID;
|
|
|
model1.MODIFIEDUSER = strUserID;
|
|
|
model1.ASSOCIATEDNO = strASSOCIATEDNO;
|
|
|
model1.CUSTOMERNAME = strCUSTOMERNAME;
|
|
|
model1.FEETYPE = strFEETYPE;
|
|
|
tempWmsRateDetailEntities.Add(model1);
|
|
|
//
|
|
|
nowgrade++;
|
|
|
if (CAPPRICE != 0)
|
|
|
{
|
|
|
if (dprice < CAPPRICE)
|
|
|
{
|
|
|
dprice += ADDPRICE;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
dprice = CAPPRICE;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
dprice += ADDPRICE;
|
|
|
}
|
|
|
strSTARTBILLINGDATE2 = (model1.ENDBILLINGDATE.AddDays(1)).ToString();//按区间计费的开始计费日期
|
|
|
}
|
|
|
//
|
|
|
if (imod > 0)//增值费率余数大于0,则实际仓储月份等于imod
|
|
|
{
|
|
|
//--- BEGIN --- 如果是月则计算开始和结束日期之间的天数
|
|
|
DateTime dtSTARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
|
|
|
DateTime dtENDBILLINGDATE = dtSTARTBILLINGDATE.AddDays(imod - 1);
|
|
|
int dtDays = imod;// nowscale;
|
|
|
|
|
|
string FEEUNIT2 = FEEUNIT;
|
|
|
if (FEEUNIT.IndexOf("月") > -1)
|
|
|
{
|
|
|
dtENDBILLINGDATE = dtSTARTBILLINGDATE.AddMonths(imod).AddDays(-1);
|
|
|
if (dtENDBILLINGDATE > DateTime.Parse(ENDBILLINGDATE))//strOLDCUSTFEEDATE
|
|
|
{
|
|
|
if ((i + 1) == dsrate.Tables[0].Rows.Count && dtENDBILLINGDATE > DateTime.Parse(strOLDCUSTFEEDATE))//即最后一条时,以后的时间都按最后一条取值
|
|
|
{
|
|
|
dtENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
dtENDBILLINGDATE = DateTime.Parse(ENDBILLINGDATE);//strOLDCUSTFEEDATE
|
|
|
}
|
|
|
}
|
|
|
FEEUNIT2 = FEEUNIT.Trim().Substring(0, 1) + "天";
|
|
|
dtDays = WmsOutDetailDA.GetDaysCount("day", dtSTARTBILLINGDATE.ToString().Trim(), dtENDBILLINGDATE.ToString().Trim());//按月的区间天数
|
|
|
}
|
|
|
//--- END ---
|
|
|
|
|
|
//dprice += ADDPRICE;
|
|
|
gradefee = outnums * dprice * dtDays;// imod;//出库量*计费单价*实际仓储月数
|
|
|
sumfee += gradefee;
|
|
|
prescale += dtDays;//imod;//累计天数
|
|
|
//
|
|
|
model.FEEPRICE = dprice;
|
|
|
model.GOODSPFSL = outnums;
|
|
|
model.FEESCALE = dtDays;//imod;
|
|
|
model.OUTFEE = gradefee;
|
|
|
model.FEEUNIT = FEEUNIT2;
|
|
|
model.STARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
|
|
|
model.ENDBILLINGDATE = dtENDBILLINGDATE;
|
|
|
//model.ENDBILLINGDATE = model.STARTBILLINGDATE.AddDays(imod - 1);
|
|
|
//if (FEEUNIT.IndexOf("月") > -1)
|
|
|
//{
|
|
|
// DateTime dt = model.STARTBILLINGDATE.AddMonths(imod).AddDays(-1);
|
|
|
// model.ENDBILLINGDATE = dt;
|
|
|
// if (dt > DateTime.Parse(strOLDCUSTFEEDATE))
|
|
|
// {
|
|
|
// model.ENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
|
|
|
// }
|
|
|
//}
|
|
|
model.FEEGRADE = nowgrade;
|
|
|
model.REMARK = "";
|
|
|
model.CREATEUSER = strUserID;
|
|
|
model.MODIFIEDUSER = strUserID;
|
|
|
model.ASSOCIATEDNO = strASSOCIATEDNO;
|
|
|
model.CUSTOMERNAME = strCUSTOMERNAME;
|
|
|
model.FEETYPE = strFEETYPE;
|
|
|
tempWmsRateDetailEntities.Add(model);
|
|
|
//
|
|
|
nowgrade++;
|
|
|
strSTARTBILLINGDATE2 = (model.ENDBILLINGDATE.AddDays(1)).ToString();//按区间计费的开始计费日期
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//--- BEGIN --- 如果是月则计算开始和结束日期之间的天数
|
|
|
DateTime dtSTARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
|
|
|
DateTime dtENDBILLINGDATE = DateTime.Parse(ENDBILLINGDATE);
|
|
|
int dtDays = sjMonth;// nowscale;
|
|
|
|
|
|
string FEEUNIT2 = FEEUNIT;
|
|
|
if (FEEUNIT.IndexOf("月") > -1)
|
|
|
{
|
|
|
FEEUNIT2 = FEEUNIT.Trim().Substring(0, 1) + "天";
|
|
|
dtDays = WmsOutDetailDA.GetDaysCount("day", dtSTARTBILLINGDATE.ToString().Trim(), dtENDBILLINGDATE.ToString().Trim());//按月的区间天数
|
|
|
}
|
|
|
//--- END ---
|
|
|
|
|
|
gradefee = outnums * price * dtDays;// sjMonth;//出库量*计费单价*实际仓储月数
|
|
|
sumfee += gradefee;
|
|
|
prescale += dtDays;//sjMonth;//累计天数
|
|
|
//
|
|
|
model.FEEPRICE = price;
|
|
|
model.GOODSPFSL = outnums;
|
|
|
model.FEESCALE = dtDays;//sjMonth;
|
|
|
model.OUTFEE = gradefee;
|
|
|
model.FEEUNIT = FEEUNIT2;
|
|
|
model.STARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
|
|
|
model.ENDBILLINGDATE = DateTime.Parse(ENDBILLINGDATE);
|
|
|
model.FEEGRADE = nowgrade;
|
|
|
model.REMARK = "";
|
|
|
model.CREATEUSER = strUserID;
|
|
|
model.MODIFIEDUSER = strUserID;
|
|
|
model.ASSOCIATEDNO = strASSOCIATEDNO;
|
|
|
model.CUSTOMERNAME = strCUSTOMERNAME;
|
|
|
model.FEETYPE = strFEETYPE;
|
|
|
tempWmsRateDetailEntities.Add(model);
|
|
|
//
|
|
|
nowgrade++;
|
|
|
strSTARTBILLINGDATE2 = (DateTime.Parse(ENDBILLINGDATE).AddDays(1)).ToString();//按区间计费的开始计费日期
|
|
|
}
|
|
|
#endregion
|
|
|
//结束费率区间的循环
|
|
|
if (feedays <= feeMonth)//总仓储月数 <= i区间仓储月数
|
|
|
{
|
|
|
break;//结束费率区间的循环
|
|
|
}
|
|
|
}
|
|
|
else//i区间仓储月数 <= 区间计费区间(仓储月数/天数)
|
|
|
{
|
|
|
int sjMonth = 0;//实际仓储月数
|
|
|
int sjMonth2 = 0;//实际仓储月数,如果是最后一条的判断数
|
|
|
if (feedays > feeMonth)//总仓储月数 > i区间仓储月数
|
|
|
{
|
|
|
sjMonth = feeMonth;//实际仓储月数
|
|
|
sjMonth2 = feeMonth;//实际仓储月数,如果是最后一条的判断数
|
|
|
if ((i + 1) == dsrate.Tables[0].Rows.Count)//即最后一条时,以后的时间都按最后一条取值
|
|
|
{
|
|
|
if (ADDPRICE <= 0)//增值价>0,则求增值费率
|
|
|
{
|
|
|
sjMonth = feedays;// (feedays - nowscale);//实际仓储月数
|
|
|
ENDBILLINGDATE = strOLDCUSTFEEDATE;
|
|
|
}
|
|
|
sjMonth2 = feedays;// (feedays - nowscale);//实际仓储月数,如果是最后一条的判断数
|
|
|
}
|
|
|
}
|
|
|
else//总仓储月数 <= i区间仓储月数
|
|
|
{
|
|
|
//sjMonth = feedays;//(feedays - nowscale);//实际仓储月数
|
|
|
sjMonth = nowscale;// feeMonth;// (feeMonth - nowscale);//实际仓储月数
|
|
|
sjMonth2 = feedays;//实际仓储月数,如果是最后一条的判断数
|
|
|
ENDBILLINGDATE = strOLDCUSTFEEDATE;
|
|
|
}
|
|
|
//
|
|
|
#region 增值价>0,则求增值费率
|
|
|
if (ADDPRICE > 0)//增值价>0,则求增值费率
|
|
|
{
|
|
|
//int idiv = (int)(sjMonth / nowscale);
|
|
|
//int imod = (int)(sjMonth % nowscale);
|
|
|
int idiv = (int)(sjMonth2 / nowscale);
|
|
|
int imod = (int)(sjMonth2 % nowscale);
|
|
|
Decimal dprice = price;//计费单价
|
|
|
for (int j = 0; j < idiv; j++)//循环求增值费率
|
|
|
{
|
|
|
//--- BEGIN --- 如果是月则计算开始和结束日期之间的天数
|
|
|
DateTime dtSTARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
|
|
|
DateTime dtENDBILLINGDATE = dtSTARTBILLINGDATE.AddDays(nowscale - 1);
|
|
|
int dtDays = sjMonth;// nowscale;
|
|
|
|
|
|
string FEEUNIT2 = FEEUNIT;
|
|
|
if (FEEUNIT.IndexOf("月") > -1)
|
|
|
{
|
|
|
dtENDBILLINGDATE = dtSTARTBILLINGDATE.AddMonths(nowscale).AddDays(-1);
|
|
|
if (dtENDBILLINGDATE > DateTime.Parse(strOLDCUSTFEEDATE))
|
|
|
{
|
|
|
dtENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
|
|
|
}
|
|
|
FEEUNIT2 = FEEUNIT.Trim().Substring(0, 1) + "天";
|
|
|
dtDays = WmsOutDetailDA.GetDaysCount("day", dtSTARTBILLINGDATE.ToString().Trim(), dtENDBILLINGDATE.ToString().Trim());//按月的区间天数
|
|
|
}
|
|
|
//--- END ---
|
|
|
|
|
|
gradefee = outnums * dprice * dtDays;// nowscale;//出库量*计费单价*实际仓储月数
|
|
|
sumfee += gradefee;
|
|
|
prescale += dtDays;//nowscale;//累计天数
|
|
|
//
|
|
|
WmsRateDetailEntity model1 = new WmsRateDetailEntity();
|
|
|
model1.FEEPRICE = dprice;
|
|
|
model1.GOODSPFSL = outnums;
|
|
|
model1.FEESCALE = dtDays;//nowscale;
|
|
|
model1.OUTFEE = gradefee;
|
|
|
model1.FEEUNIT = FEEUNIT2;
|
|
|
model1.STARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
|
|
|
model1.ENDBILLINGDATE = dtENDBILLINGDATE;
|
|
|
//model1.ENDBILLINGDATE = model1.STARTBILLINGDATE.AddDays(nowscale - 1);
|
|
|
//if (FEEUNIT.IndexOf("月") > -1)
|
|
|
//{
|
|
|
// DateTime dt = model1.STARTBILLINGDATE.AddMonths(nowscale).AddDays(-1);
|
|
|
// model1.ENDBILLINGDATE = dt;
|
|
|
// if (dt > DateTime.Parse(strOLDCUSTFEEDATE))
|
|
|
// {
|
|
|
// model1.ENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
|
|
|
// }
|
|
|
//}
|
|
|
model1.FEEGRADE = nowgrade;
|
|
|
model1.REMARK = "";
|
|
|
model1.CREATEUSER = strUserID;
|
|
|
model1.MODIFIEDUSER = strUserID;
|
|
|
model1.ASSOCIATEDNO = strASSOCIATEDNO;
|
|
|
model1.CUSTOMERNAME = strCUSTOMERNAME;
|
|
|
model1.FEETYPE = strFEETYPE;
|
|
|
tempWmsRateDetailEntities.Add(model1);
|
|
|
//
|
|
|
nowgrade++;
|
|
|
if (CAPPRICE != 0)
|
|
|
{
|
|
|
if (dprice < CAPPRICE)
|
|
|
{
|
|
|
dprice += ADDPRICE;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
dprice = CAPPRICE;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
dprice += ADDPRICE;
|
|
|
}
|
|
|
strSTARTBILLINGDATE2 = (model1.ENDBILLINGDATE.AddDays(1)).ToString();//按区间计费的开始计费日期
|
|
|
}
|
|
|
//
|
|
|
if (imod > 0)//增值费率余数大于0,则实际仓储月份等于imod
|
|
|
{
|
|
|
//--- BEGIN --- 如果是月则计算开始和结束日期之间的天数
|
|
|
DateTime dtSTARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
|
|
|
DateTime dtENDBILLINGDATE = dtSTARTBILLINGDATE.AddDays(imod - 1);
|
|
|
int dtDays = imod;// nowscale;
|
|
|
|
|
|
string FEEUNIT2 = FEEUNIT;
|
|
|
if (FEEUNIT.IndexOf("月") > -1)
|
|
|
{
|
|
|
dtENDBILLINGDATE = dtSTARTBILLINGDATE.AddMonths(imod).AddDays(-1);
|
|
|
if (dtENDBILLINGDATE > DateTime.Parse(strOLDCUSTFEEDATE))
|
|
|
{
|
|
|
dtENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
|
|
|
}
|
|
|
FEEUNIT2 = FEEUNIT.Trim().Substring(0, 1) + "天";
|
|
|
dtDays = WmsOutDetailDA.GetDaysCount("day", dtSTARTBILLINGDATE.ToString().Trim(), dtENDBILLINGDATE.ToString().Trim());//按月的区间天数
|
|
|
}
|
|
|
//--- END ---
|
|
|
|
|
|
//dprice += ADDPRICE;
|
|
|
gradefee = outnums * dprice * dtDays;// imod;//出库量*计费单价*实际仓储月数
|
|
|
sumfee += gradefee;
|
|
|
prescale += dtDays;//imod;//累计天数
|
|
|
//
|
|
|
model.FEEPRICE = dprice;
|
|
|
model.GOODSPFSL = outnums;
|
|
|
model.FEESCALE = dtDays;//imod;
|
|
|
model.OUTFEE = gradefee;
|
|
|
model.FEEUNIT = FEEUNIT2;
|
|
|
model.STARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
|
|
|
model.ENDBILLINGDATE = dtENDBILLINGDATE;
|
|
|
//model.ENDBILLINGDATE = model.STARTBILLINGDATE.AddDays(imod - 1);
|
|
|
//if (FEEUNIT.IndexOf("月") > -1)
|
|
|
//{
|
|
|
// DateTime dt = model.STARTBILLINGDATE.AddMonths(imod).AddDays(-1);
|
|
|
// model.ENDBILLINGDATE = dt;
|
|
|
// if (dt > DateTime.Parse(strOLDCUSTFEEDATE))
|
|
|
// {
|
|
|
// model.ENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
|
|
|
// }
|
|
|
//}
|
|
|
model.FEEGRADE = nowgrade;
|
|
|
model.REMARK = "";
|
|
|
model.CREATEUSER = strUserID;
|
|
|
model.MODIFIEDUSER = strUserID;
|
|
|
model.ASSOCIATEDNO = strASSOCIATEDNO;
|
|
|
model.CUSTOMERNAME = strCUSTOMERNAME;
|
|
|
model.FEETYPE = strFEETYPE;
|
|
|
tempWmsRateDetailEntities.Add(model);
|
|
|
//
|
|
|
nowgrade++;
|
|
|
strSTARTBILLINGDATE2 = (model.ENDBILLINGDATE.AddDays(1)).ToString();//按区间计费的开始计费日期
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//--- BEGIN --- 如果是月则计算开始和结束日期之间的天数
|
|
|
DateTime dtSTARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
|
|
|
DateTime dtENDBILLINGDATE = DateTime.Parse(ENDBILLINGDATE);
|
|
|
int dtDays = sjMonth;//nowscale;
|
|
|
|
|
|
string FEEUNIT2 = FEEUNIT;
|
|
|
if (FEEUNIT.IndexOf("月") > -1)
|
|
|
{
|
|
|
FEEUNIT2 = FEEUNIT.Trim().Substring(0, 1) + "天";
|
|
|
dtDays = WmsOutDetailDA.GetDaysCount("day", dtSTARTBILLINGDATE.ToString().Trim(), dtENDBILLINGDATE.ToString().Trim());//按月的区间天数
|
|
|
}
|
|
|
//--- END ---
|
|
|
|
|
|
gradefee = outnums * price * dtDays;//sjMonth;//出库量*计费单价*实际仓储月数
|
|
|
sumfee += gradefee;
|
|
|
prescale += dtDays;//sjMonth;//累计天数
|
|
|
//
|
|
|
model.FEEPRICE = price;
|
|
|
model.GOODSPFSL = outnums;
|
|
|
model.FEESCALE = dtDays;//sjMonth;
|
|
|
model.OUTFEE = gradefee;
|
|
|
model.FEEUNIT = FEEUNIT2;
|
|
|
model.STARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
|
|
|
model.ENDBILLINGDATE = DateTime.Parse(ENDBILLINGDATE);
|
|
|
model.FEEGRADE = nowgrade;
|
|
|
model.REMARK = "";
|
|
|
model.CREATEUSER = strUserID;
|
|
|
model.MODIFIEDUSER = strUserID;
|
|
|
model.ASSOCIATEDNO = strASSOCIATEDNO;
|
|
|
model.CUSTOMERNAME = strCUSTOMERNAME;
|
|
|
model.FEETYPE = strFEETYPE;
|
|
|
tempWmsRateDetailEntities.Add(model);
|
|
|
//
|
|
|
nowgrade++;
|
|
|
strSTARTBILLINGDATE2 = (DateTime.Parse(ENDBILLINGDATE).AddDays(1)).ToString();//按区间计费的开始计费日期
|
|
|
}
|
|
|
#endregion
|
|
|
//结束费率区间的循环
|
|
|
if (feedays <= feeMonth)//总仓储月数 <= i区间仓储月数
|
|
|
{
|
|
|
break;//结束费率区间的循环
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else//总仓储月数 <= 区间计费区间(仓储月数/天数)
|
|
|
{
|
|
|
//--- BEGIN --- 如果是月则计算开始和结束日期之间的天数
|
|
|
DateTime dtSTARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
|
|
|
DateTime dtENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
|
|
|
int dtDays = feedays;
|
|
|
|
|
|
string FEEUNIT2 = FEEUNIT;
|
|
|
if (FEEUNIT.IndexOf("月") > -1)
|
|
|
{
|
|
|
FEEUNIT2 = FEEUNIT.Trim().Substring(0, 1) + "天";
|
|
|
dtDays = WmsOutDetailDA.GetDaysCount("day", dtSTARTBILLINGDATE.ToString().Trim(), dtENDBILLINGDATE.ToString().Trim());//按月的区间天数
|
|
|
}
|
|
|
//--- END ---
|
|
|
|
|
|
gradefee = outnums * price * dtDays;//feedays;//出库量*计费单价*仓储区间(//仓储天数-上一个计费区间(0))
|
|
|
sumfee += gradefee;
|
|
|
prescale += dtDays;//feedays;//累计天数
|
|
|
//
|
|
|
model.FEEPRICE = price;
|
|
|
model.GOODSPFSL = outnums;
|
|
|
model.FEESCALE = dtDays;//feedays;
|
|
|
model.OUTFEE = gradefee;
|
|
|
model.FEEUNIT = FEEUNIT2;
|
|
|
model.STARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
|
|
|
model.ENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
|
|
|
model.FEEGRADE = nowgrade;
|
|
|
model.REMARK = "";
|
|
|
model.CREATEUSER = strUserID;
|
|
|
model.MODIFIEDUSER = strUserID;
|
|
|
model.ASSOCIATEDNO = strASSOCIATEDNO;
|
|
|
model.CUSTOMERNAME = strCUSTOMERNAME;
|
|
|
model.FEETYPE = strFEETYPE;
|
|
|
tempWmsRateDetailEntities.Add(model);
|
|
|
//
|
|
|
nowgrade++;
|
|
|
strSTARTBILLINGDATE2 = (DateTime.Parse(strOLDCUSTFEEDATE).AddDays(1)).ToString();//按区间计费的开始计费日期
|
|
|
break;//结束费率区间的循环
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//仓储费率没有设定
|
|
|
//sqlTran.Rollback();
|
|
|
//result = -2;
|
|
|
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>alert('仓储费率没有设置');</script>");
|
|
|
//Clearh();
|
|
|
//return result;
|
|
|
|
|
|
totalfeedays = 0;
|
|
|
feedays = 0;
|
|
|
sumfee = 0;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
totalfeedays = 0;
|
|
|
feedays = 0;
|
|
|
sumfee = 0;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
totalfeedays = 0;
|
|
|
feedays = 0;
|
|
|
sumfee = 0;
|
|
|
}
|
|
|
//
|
|
|
|
|
|
#region 按区间计算仓储费,插入费率出库明细表
|
|
|
if (tempWmsRateDetailEntities != null)//是否有要入库的仓储费
|
|
|
{
|
|
|
if (tempWmsRateDetailEntities.Count > 0)
|
|
|
{
|
|
|
foreach (WmsRateDetailEntity model2 in tempWmsRateDetailEntities)
|
|
|
{
|
|
|
Sqlstr = String.Format("insert into wms_rate_detail(GID,FEEPRICE,GOODSPFSL,OUTFEE,REMARK,CREATEUSER,CREATETIME,ASSOCIATEDNO,CUSTOMERNAME,FEETYPE,FEEGRADE,STARTBILLINGDATE,ENDBILLINGDATE,FEESCALE,FEEUNIT,MODIFIEDUSER)"
|
|
|
+ " values(newid(),'{0}','{1}','{2}','{3}','{4}',getdate(),'{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}')"
|
|
|
, model2.FEEPRICE, model2.GOODSPFSL, model2.OUTFEE, model2.REMARK, model2.CREATEUSER, model2.ASSOCIATEDNO, model2.CUSTOMERNAME, model2.FEETYPE, model2.FEEGRADE, model2.STARTBILLINGDATE, model2.ENDBILLINGDATE, model2.FEESCALE, model2.FEEUNIT, model2.MODIFIEDUSER);
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -1;
|
|
|
//Clearh();
|
|
|
return result.ToString();
|
|
|
}
|
|
|
//
|
|
|
string str0 = "insert into sys_log(NAME,LOGTYPE,LOGCONTENT,CREATEUSER) values('添加出库明细的费率明细信息','INSERT 插入操作','" + strShowName + " 添加 费率明细信息 出库单号:" + sBillno.Trim() + " ','" + model2.MODIFIEDUSER.ToString() + "')";
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, str0, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -1;
|
|
|
//Clearh();
|
|
|
return result.ToString();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
tempWmsRateDetailEntities = null;
|
|
|
totalfeedays = 0;
|
|
|
feedays = 0;
|
|
|
sumfee = 0;
|
|
|
}
|
|
|
#endregion
|
|
|
sR = sumfee.ToString() + "," + totalfeedays.ToString();
|
|
|
return sR;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#endregion Method
|
|
|
}
|
|
|
}
|