using System;
using System.Text;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Data;
using DSWeb.SoftMng.DBUtility;
// ReSharper disable once CheckNamespace
namespace DSWeb.SoftMng.DAL
{
//DecFreeTx
public partial class DecFreeTxDAL
{
public bool Exists(string GID)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select count(1) from DecFreeTx");
strSql.Append(" where ");
strSql.Append(" GID = @GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,50) };
parameters[0].Value = GID;
return DbHelperSQL.Exists(strSql.ToString(),parameters);
}
///
/// 增加一条数据
///
public int Add(DSWeb.SoftMng.Model.DecFreeTx model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("insert into DecFreeTx(");
strSql.Append("GID,BonNo,CusFie,DecBpNo,DecNo,RelId,RelManNo,VoyNo,PID");
strSql.Append(") values (");
strSql.Append("@GID,@BonNo,@CusFie,@DecBpNo,@DecNo,@RelId,@RelManNo,@VoyNo,@PID");
strSql.Append(") ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,50) ,
new SqlParameter("@BonNo", SqlDbType.NVarChar,50) ,
new SqlParameter("@CusFie", SqlDbType.VarChar,50) ,
new SqlParameter("@DecBpNo", SqlDbType.VarChar,50) ,
new SqlParameter("@DecNo", SqlDbType.VarChar,50) ,
new SqlParameter("@RelId", SqlDbType.VarChar,50) ,
new SqlParameter("@RelManNo", SqlDbType.VarChar,50) ,
new SqlParameter("@VoyNo", SqlDbType.VarChar,50),
new SqlParameter("@PID", SqlDbType.VarChar,50)
};
parameters[0].Value = model.GID??(Object)DBNull.Value;
parameters[1].Value = model.BonNo??(Object)DBNull.Value;
parameters[2].Value = model.CusFie??(Object)DBNull.Value;
parameters[3].Value = model.DecBpNo??(Object)DBNull.Value;
parameters[4].Value = model.DecNo??(Object)DBNull.Value;
parameters[5].Value = model.RelId??(Object)DBNull.Value;
parameters[6].Value = model.RelManNo??(Object)DBNull.Value;
parameters[7].Value = model.VoyNo??(Object)DBNull.Value;
parameters[8].Value = model.PID ?? (Object)DBNull.Value;
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
///
/// 更新一条数据
///
public int Update(DSWeb.SoftMng.Model.DecFreeTx model)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("update DecFreeTx set ");
strSql.Append(" GID = @GID,");
strSql.Append(" BonNo = @BonNo,");
strSql.Append(" CusFie = @CusFie,");
strSql.Append(" DecBpNo = @DecBpNo,");
strSql.Append(" DecNo = @DecNo,");
strSql.Append(" RelId = @RelId,");
strSql.Append(" RelManNo = @RelManNo,");
strSql.Append(" VoyNo = @VoyNo,");
strSql.Append(" PID = @PID");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,50) ,
new SqlParameter("@BonNo", SqlDbType.NVarChar,50) ,
new SqlParameter("@CusFie", SqlDbType.VarChar,50) ,
new SqlParameter("@DecBpNo", SqlDbType.VarChar,50) ,
new SqlParameter("@DecNo", SqlDbType.VarChar,50) ,
new SqlParameter("@RelId", SqlDbType.VarChar,50) ,
new SqlParameter("@RelManNo", SqlDbType.VarChar,50) ,
new SqlParameter("@VoyNo", SqlDbType.VarChar,50),
new SqlParameter("@PID", SqlDbType.VarChar,50)
};
parameters[0].Value = model.GID??(Object)DBNull.Value;
parameters[1].Value = model.BonNo??(Object)DBNull.Value;
parameters[2].Value = model.CusFie??(Object)DBNull.Value;
parameters[3].Value = model.DecBpNo??(Object)DBNull.Value;
parameters[4].Value = model.DecNo??(Object)DBNull.Value;
parameters[5].Value = model.RelId??(Object)DBNull.Value;
parameters[6].Value = model.RelManNo??(Object)DBNull.Value;
parameters[7].Value = model.VoyNo??(Object)DBNull.Value;
parameters[8].Value = model.PID ?? (Object)DBNull.Value;
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
///
/// 删除一条数据
///
public int Delete(string GID)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete from DecFreeTx ");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,50) };
parameters[0].Value = GID;
return DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
}
///
/// 按条件批量删除
///
public int DeleteListWhere(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("delete from DecFreeTx ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
return DbHelperSQL.ExecuteSql(strSql.ToString());
}
///
/// 得到一个对象实体
///
public DataSet GetModel(string GID)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select GID, BonNo, CusFie, DecBpNo, DecNo, RelId, RelManNo, VoyNo,PID ");
strSql.Append(" from DecFreeTx ");
strSql.Append(" where GID=@GID ");
SqlParameter[] parameters = {
new SqlParameter("@GID", SqlDbType.VarChar,50) };
parameters[0].Value = GID;
DSWeb.SoftMng.Model.DecFreeTx model=new DSWeb.SoftMng.Model.DecFreeTx();
return DbHelperSQL.Query(strSql.ToString(),parameters);
}
///
/// 获得数据列表
///
public DataSet GetList(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select * ");
strSql.Append(" FROM DecFreeTx ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
return DbHelperSQL.Query(strSql.ToString());
}
///
/// 获得前几行数据
///
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 DecFreeTx ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
strSql.Append(" order by " + filedOrder);
return DbHelperSQL.Query(strSql.ToString());
}
///
/// 分页获取数据列表
///
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);
strSql.Append(")AS Row, T.* from DecFreeTx T ");
if (!string.IsNullOrEmpty(strWhere.Trim()))
{
strSql.Append(" WHERE " + strWhere);
}
strSql.Append(" ) TT");
strSql.AppendFormat(" WHERE TT.Row > {0} and TT.Row <= {1}", startIndex, endIndex);
//公共代码
return DbHelperSQL.Query(strSql.ToString());
}
///
/// 获取记录总数
///
public int GetRecordCount(string strWhere)
{
StringBuilder strSql=new StringBuilder();
strSql.Append("select count(1) FROM DecFreeTx ");
if(strWhere.Trim()!="")
{
strSql.Append(" where "+strWhere);
}
return DbHelperSQL.ExcuteScalarSQL(strSql.ToString());
}
}
}