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.
383 lines
18 KiB
C#
383 lines
18 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Text;
|
|
using System.Configuration;
|
|
using System.Web;
|
|
using System.Web.Security;
|
|
using System.Web.UI;
|
|
using System.Web.UI.HtmlControls;
|
|
using System.Web.UI.WebControls;
|
|
using System.Web.UI.WebControls.WebParts;
|
|
using DSWeb.Models;
|
|
using System.Data.SqlClient;
|
|
using System.Collections.Generic;
|
|
using System.Collections;
|
|
using WebSqlHelper;
|
|
using System.Linq;
|
|
using System.Xml.Linq;
|
|
|
|
namespace DSWeb.EntityDA
|
|
{
|
|
public class WmsRateDetailDA
|
|
{
|
|
public WmsRateDetailDA()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取记录总数
|
|
/// </summary>
|
|
public int GetRecordCount(string strWhere)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select count(1) FROM wms_rate_detail ");
|
|
if (strWhere.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + strWhere);
|
|
}
|
|
object obj = SqlHelper.GetSingle(SqlHelper.ConnectionStringLocalTransaction, strSql.ToString());
|
|
if (obj == null)
|
|
{
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
return Convert.ToInt32(obj);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 增加一条数据
|
|
/// </summary>
|
|
public int Add(WmsRateDetailEntity model, string strShowName, string txt_outbsno)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("insert into wms_rate_detail(");
|
|
strSql.Append("GID,FEEPRICE,GOODSPFSL,OUTFEE,REMARK,CREATEUSER,CREATETIME,ASSOCIATEDNO,CUSTOMERNAME,FEETYPE,FEEGRADE,STARTBILLINGDATE,ENDBILLINGDATE,FEESCALE,FEEUNIT,MODIFIEDUSER,MODIFIEDTIME");
|
|
strSql.Append(") values (");
|
|
strSql.Append("@GID,@FEEPRICE,@GOODSPFSL,@OUTFEE,@REMARK,@CREATEUSER,getdate(),@ASSOCIATEDNO,@CUSTOMERNAME,@FEETYPE,@FEEGRADE,@STARTBILLINGDATE,@ENDBILLINGDATE,@FEESCALE,@FEEUNIT,@MODIFIEDUSER,getdate()");
|
|
strSql.Append(") ");
|
|
|
|
SqlParameter[] parameters = {
|
|
new SqlParameter("@GID", SqlDbType.VarChar,36) ,
|
|
new SqlParameter("@FEEPRICE", SqlDbType.Decimal,9) ,
|
|
new SqlParameter("@GOODSPFSL", SqlDbType.Decimal,9) ,
|
|
new SqlParameter("@OUTFEE", SqlDbType.Decimal,9) ,
|
|
new SqlParameter("@REMARK", SqlDbType.VarChar,100) ,
|
|
new SqlParameter("@CREATEUSER", SqlDbType.VarChar,36) ,
|
|
new SqlParameter("@ASSOCIATEDNO", SqlDbType.VarChar,100) ,
|
|
new SqlParameter("@CUSTOMERNAME", SqlDbType.VarChar,20) ,
|
|
new SqlParameter("@FEETYPE", SqlDbType.Int,4) ,
|
|
new SqlParameter("@FEEGRADE", SqlDbType.Int,4) ,
|
|
new SqlParameter("@STARTBILLINGDATE", SqlDbType.DateTime) ,
|
|
new SqlParameter("@ENDBILLINGDATE", SqlDbType.DateTime) ,
|
|
new SqlParameter("@FEESCALE", SqlDbType.VarChar,50) ,
|
|
new SqlParameter("@FEEUNIT", SqlDbType.VarChar,50),
|
|
new SqlParameter("@MODIFIEDUSER", SqlDbType.VarChar,36)
|
|
|
|
};
|
|
|
|
parameters[0].Value = model.GID;
|
|
parameters[1].Value = model.FEEPRICE;
|
|
parameters[2].Value = model.GOODSPFSL;
|
|
parameters[3].Value = model.OUTFEE;
|
|
parameters[4].Value = model.REMARK;
|
|
parameters[5].Value = model.CREATEUSER;
|
|
parameters[6].Value = model.ASSOCIATEDNO;
|
|
parameters[7].Value = model.CUSTOMERNAME;
|
|
parameters[8].Value = model.FEETYPE;
|
|
parameters[9].Value = model.FEEGRADE;
|
|
parameters[10].Value = model.STARTBILLINGDATE;
|
|
parameters[11].Value = model.ENDBILLINGDATE;
|
|
parameters[12].Value = model.FEESCALE;
|
|
parameters[13].Value = model.FEEUNIT;
|
|
parameters[14].Value = model.MODIFIEDUSER;
|
|
//
|
|
int iResult = 0;
|
|
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
|
|
{
|
|
int existVal = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters);
|
|
if (existVal > 0)
|
|
{
|
|
iResult = 1;
|
|
//
|
|
string str0 = "insert into sys_log(NAME,LOGTYPE,LOGCONTENT,CREATEUSER) values('添加出库明细的费率明细信息','INSERT 插入操作','" + strShowName + " 添加 费率明细信息 出库单号:" + txt_outbsno + " ','" + model.MODIFIEDUSER.ToString() + "')";
|
|
bool bl0 = SqlHelper.ExecuteSqlCommand(SqlHelper.ConnectionStringLocalTransaction, str0);
|
|
}
|
|
else
|
|
{
|
|
iResult = -1;//执行异常
|
|
}
|
|
}
|
|
return iResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新一条数据
|
|
/// </summary>
|
|
public int Update(WmsRateDetailEntity model, string strShowName, string txt_outbsno)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("update wms_rate_detail set ");
|
|
strSql.Append(" GID = @GID , ");
|
|
strSql.Append(" FEEPRICE = @FEEPRICE , ");
|
|
strSql.Append(" GOODSPFSL = @GOODSPFSL , ");
|
|
strSql.Append(" OUTFEE = @OUTFEE , ");
|
|
strSql.Append(" REMARK = @REMARK , ");
|
|
strSql.Append(" MODIFIEDUSER = @MODIFIEDUSER , ");
|
|
strSql.Append(" MODIFIEDTIME = getdate() , ");
|
|
strSql.Append(" ASSOCIATEDNO = @ASSOCIATEDNO , ");
|
|
strSql.Append(" CUSTOMERNAME = @CUSTOMERNAME , ");
|
|
strSql.Append(" FEETYPE = @FEETYPE , ");
|
|
strSql.Append(" FEEGRADE = @FEEGRADE , ");
|
|
strSql.Append(" STARTBILLINGDATE = @STARTBILLINGDATE , ");
|
|
strSql.Append(" ENDBILLINGDATE = @ENDBILLINGDATE , ");
|
|
strSql.Append(" FEESCALE = @FEESCALE , ");
|
|
strSql.Append(" FEEUNIT = @FEEUNIT ");
|
|
strSql.Append(" where GID=@GID ");
|
|
|
|
SqlParameter[] parameters = {
|
|
new SqlParameter("@GID", SqlDbType.VarChar,36) ,
|
|
new SqlParameter("@FEEPRICE", SqlDbType.Decimal,9) ,
|
|
new SqlParameter("@GOODSPFSL", SqlDbType.Decimal,9) ,
|
|
new SqlParameter("@OUTFEE", SqlDbType.Decimal,9) ,
|
|
new SqlParameter("@REMARK", SqlDbType.VarChar,100) ,
|
|
new SqlParameter("@MODIFIEDUSER", SqlDbType.VarChar,36) ,
|
|
new SqlParameter("@ASSOCIATEDNO", SqlDbType.VarChar,100) ,
|
|
new SqlParameter("@CUSTOMERNAME", SqlDbType.VarChar,20) ,
|
|
new SqlParameter("@FEETYPE", SqlDbType.Int,4) ,
|
|
new SqlParameter("@FEEGRADE", SqlDbType.Int,4) ,
|
|
new SqlParameter("@STARTBILLINGDATE", SqlDbType.DateTime) ,
|
|
new SqlParameter("@ENDBILLINGDATE", SqlDbType.DateTime) ,
|
|
new SqlParameter("@FEESCALE", SqlDbType.VarChar,50) ,
|
|
new SqlParameter("@FEEUNIT", SqlDbType.VarChar,50)
|
|
|
|
};
|
|
|
|
parameters[0].Value = model.GID;
|
|
parameters[1].Value = model.FEEPRICE;
|
|
parameters[2].Value = model.GOODSPFSL;
|
|
parameters[3].Value = model.OUTFEE;
|
|
parameters[4].Value = model.REMARK;
|
|
parameters[5].Value = model.MODIFIEDUSER;
|
|
parameters[6].Value = model.ASSOCIATEDNO;
|
|
parameters[7].Value = model.CUSTOMERNAME;
|
|
parameters[8].Value = model.FEETYPE;
|
|
parameters[9].Value = model.FEEGRADE;
|
|
parameters[10].Value = model.STARTBILLINGDATE;
|
|
parameters[11].Value = model.ENDBILLINGDATE;
|
|
parameters[12].Value = model.FEESCALE;
|
|
parameters[13].Value = model.FEEUNIT;
|
|
//
|
|
int iResult = 0;
|
|
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
|
|
{
|
|
int existVal = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters);
|
|
if (existVal > 0)
|
|
{
|
|
iResult = 1;
|
|
//
|
|
string str0 = "insert into sys_log(NAME,LOGTYPE,LOGCONTENT,CREATEUSER) values('更新出库明细的费率明细信息','UPDATE 更新操作','" + strShowName + " 更新 费率明细信息 出库单号:" + txt_outbsno + " ','" + model.MODIFIEDUSER.ToString() + "')";
|
|
bool bl0 = SqlHelper.ExecuteSqlCommand(SqlHelper.ConnectionStringLocalTransaction, str0);
|
|
}
|
|
else
|
|
{
|
|
iResult = -1;//执行异常
|
|
}
|
|
}
|
|
return iResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除一条数据
|
|
/// </summary>
|
|
public int Delete(string GID, string strUserID, string strShowName, string txt_outbsno)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("delete from wms_rate_detail ");
|
|
strSql.Append(" where GID=@GID ");
|
|
SqlParameter[] parameters = {
|
|
new SqlParameter("@GID", SqlDbType.VarChar,36) };
|
|
parameters[0].Value = GID;
|
|
|
|
//
|
|
int iResult = 0;
|
|
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
{
|
|
try
|
|
{
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString(), parameters);
|
|
iResult = 1;//状态为1表示删除成功
|
|
//
|
|
string str0 = "insert into sys_log(NAME,LOGTYPE,LOGCONTENT,CREATEUSER) values('删除出库明细的费率明细信息','DELETE 删除操作','" + strShowName + " 删除 费率明细信息 出库单号:" + txt_outbsno + " ','" + strUserID + "')";
|
|
SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, str0, null);
|
|
//
|
|
sqlTran.Commit();
|
|
}
|
|
catch (Exception execError)
|
|
{
|
|
iResult = -1;//有异常,删除失败
|
|
sqlTran.Rollback();
|
|
iResult = -2;//插入异常,事务已回滚成功
|
|
throw execError;
|
|
}
|
|
finally
|
|
{
|
|
SqlHelper.CloseConnection();
|
|
}
|
|
}
|
|
return iResult;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 批量删除数据
|
|
/// </summary>
|
|
public bool DeleteList(string GIDlist, string strUserID, string strShowName, string txt_outbsno)
|
|
{
|
|
using (SqlConnection conn = new SqlConnection(SqlHelper.ConnectionStringLocalTransaction))
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("delete from wms_rate_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)
|
|
{
|
|
string str0 = "insert into sys_log(NAME,LOGTYPE,LOGCONTENT,CREATEUSER) values('删除出库明细的费率明细信息','DELETE 删除操作','" + strShowName + " 删除 费率明细信息 出库单号:" + txt_outbsno + " ','" + strUserID + "')";
|
|
bool bl0 = SqlHelper.ExecuteSqlCommand(SqlHelper.ConnectionStringLocalTransaction, str0);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 得到一个对象实体
|
|
/// </summary>
|
|
public WmsRateDetailEntity GetModel(string GID)
|
|
{
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select GID, FEEPRICE, GOODSPFSL, OUTFEE, REMARK, CREATEUSER, CREATETIME, ASSOCIATEDNO, CUSTOMERNAME, FEETYPE, FEEGRADE, STARTBILLINGDATE, ENDBILLINGDATE, FEESCALE, FEEUNIT, MODIFIEDUSER, MODIFIEDTIME ");
|
|
strSql.Append(" from wms_rate_detail ");
|
|
strSql.Append(" where GID=@GID ");
|
|
SqlParameter[] parameters = {
|
|
new SqlParameter("@GID", SqlDbType.VarChar,36) };
|
|
parameters[0].Value = GID;
|
|
|
|
|
|
WmsRateDetailEntity model = new WmsRateDetailEntity();
|
|
DataSet ds = SqlHelper.Query(strSql.ToString(), parameters);
|
|
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
model.GID = ds.Tables[0].Rows[0]["GID"].ToString();
|
|
if (ds.Tables[0].Rows[0]["FEEPRICE"].ToString() != "")
|
|
{
|
|
model.FEEPRICE = decimal.Parse(ds.Tables[0].Rows[0]["FEEPRICE"].ToString());
|
|
}
|
|
if (ds.Tables[0].Rows[0]["GOODSPFSL"].ToString() != "")
|
|
{
|
|
model.GOODSPFSL = decimal.Parse(ds.Tables[0].Rows[0]["GOODSPFSL"].ToString());
|
|
}
|
|
if (ds.Tables[0].Rows[0]["OUTFEE"].ToString() != "")
|
|
{
|
|
model.OUTFEE = decimal.Parse(ds.Tables[0].Rows[0]["OUTFEE"].ToString());
|
|
}
|
|
model.REMARK = ds.Tables[0].Rows[0]["REMARK"].ToString();
|
|
model.CREATEUSER = ds.Tables[0].Rows[0]["CREATEUSER"].ToString();
|
|
if (ds.Tables[0].Rows[0]["CREATETIME"].ToString() != "")
|
|
{
|
|
model.CREATETIME = DateTime.Parse(ds.Tables[0].Rows[0]["CREATETIME"].ToString());
|
|
}
|
|
model.ASSOCIATEDNO = ds.Tables[0].Rows[0]["ASSOCIATEDNO"].ToString();
|
|
model.CUSTOMERNAME = ds.Tables[0].Rows[0]["CUSTOMERNAME"].ToString();
|
|
if (ds.Tables[0].Rows[0]["FEETYPE"].ToString() != "")
|
|
{
|
|
model.FEETYPE = int.Parse(ds.Tables[0].Rows[0]["FEETYPE"].ToString());
|
|
}
|
|
if (ds.Tables[0].Rows[0]["FEEGRADE"].ToString() != "")
|
|
{
|
|
model.FEEGRADE = int.Parse(ds.Tables[0].Rows[0]["FEEGRADE"].ToString());
|
|
}
|
|
if (ds.Tables[0].Rows[0]["STARTBILLINGDATE"].ToString() != "")
|
|
{
|
|
model.STARTBILLINGDATE = DateTime.Parse(ds.Tables[0].Rows[0]["STARTBILLINGDATE"].ToString());
|
|
}
|
|
if (ds.Tables[0].Rows[0]["ENDBILLINGDATE"].ToString() != "")
|
|
{
|
|
model.ENDBILLINGDATE = DateTime.Parse(ds.Tables[0].Rows[0]["ENDBILLINGDATE"].ToString());
|
|
}
|
|
model.FEESCALE = int.Parse(ds.Tables[0].Rows[0]["FEESCALE"].ToString());
|
|
model.FEEUNIT = ds.Tables[0].Rows[0]["FEEUNIT"].ToString();
|
|
model.GID = ds.Tables[0].Rows[0]["GID"].ToString();
|
|
model.MODIFIEDUSER = ds.Tables[0].Rows[0]["MODIFIEDUSER"].ToString();
|
|
if (ds.Tables[0].Rows[0]["MODIFIEDTIME"].ToString() != "")
|
|
{
|
|
model.MODIFIEDTIME = DateTime.Parse(ds.Tables[0].Rows[0]["MODIFIEDTIME"].ToString());
|
|
}
|
|
return model;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获得数据列表
|
|
/// </summary>
|
|
public DataSet GetList(string strWhere)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select * ");
|
|
strSql.Append(" FROM wms_rate_detail ");
|
|
if (strWhere.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + strWhere);
|
|
}
|
|
return SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString());
|
|
}
|
|
|
|
/// <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(" * ");
|
|
strSql.Append(" FROM wms_rate_detail ");
|
|
if (strWhere.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + strWhere);
|
|
}
|
|
strSql.Append(" order by " + filedOrder);
|
|
return SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql.ToString());
|
|
}
|
|
|
|
#region 根据SQL语句查询数据集
|
|
/// <summary>
|
|
/// 根据SQL语句查询数据集
|
|
/// </summary>
|
|
/// <param name="strSql"></param>
|
|
/// <returns></returns>
|
|
public DataSet GetExcuteSql(string strSql)
|
|
{
|
|
DataSet userSet = new DataSet();
|
|
|
|
userSet = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql);
|
|
return userSet;
|
|
}
|
|
#endregion
|
|
//
|
|
}
|
|
}
|