194 lines
6.8 KiB
C#
194 lines
6.8 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Text;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace Mtxfw.DAL
|
|
{
|
|
/// <summary>
|
|
/// 数据访问类:freighttemplate
|
|
/// </summary>
|
|
public partial class freighttemplate : Mtxfw.Utility.Myabstract
|
|
{
|
|
public freighttemplate()
|
|
: base("freighttemplate")
|
|
{ }
|
|
|
|
/// <summary>
|
|
/// 增加一条数据
|
|
/// </summary>
|
|
public int Add(Mtxfw.Model.freighttemplate model)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("insert into freighttemplate(");
|
|
strSql.Append("tname,ttype,tcharge,iffreeshipping,gtype)");
|
|
strSql.Append(" values (");
|
|
strSql.Append("@tname,@ttype,@tcharge,@iffreeshipping,@gtype)");
|
|
strSql.Append(";select SCOPE_IDENTITY()");
|
|
SqlParameter[] parameters = {
|
|
new SqlParameter("@tname", SqlDbType.VarChar,50),
|
|
new SqlParameter("@ttype", SqlDbType.Int),
|
|
new SqlParameter("@tcharge", SqlDbType.Int),
|
|
new SqlParameter("@iffreeshipping", SqlDbType.Int),
|
|
new SqlParameter("@gtype", SqlDbType.Int)};
|
|
parameters[0].Value = model.tname;
|
|
parameters[1].Value = model.ttype;
|
|
parameters[2].Value = model.tcharge;
|
|
parameters[3].Value = model.iffreeshipping;
|
|
parameters[4].Value = model.gtype;
|
|
string obj = Mtxfw.Utility.SqlDbHelper_U.GetObject(strSql.ToString(), parameters).ToString();
|
|
if (obj == "")
|
|
{
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
return Convert.ToInt32(obj);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 更新一条数据
|
|
/// </summary>
|
|
public bool Update(Mtxfw.Model.freighttemplate model)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("update freighttemplate set ");
|
|
strSql.Append("tname=@tname,");
|
|
strSql.Append("ttype=@ttype,");
|
|
strSql.Append("tcharge=@tcharge,");
|
|
strSql.Append("iffreeshipping=@iffreeshipping");
|
|
strSql.Append(" where ID=@ID");
|
|
SqlParameter[] parameters = {
|
|
new SqlParameter("@tname", SqlDbType.VarChar,50),
|
|
new SqlParameter("@ttype", SqlDbType.Int),
|
|
new SqlParameter("@tcharge", SqlDbType.Int),
|
|
new SqlParameter("@iffreeshipping", SqlDbType.Int),
|
|
new SqlParameter("@ID", SqlDbType.Int)};
|
|
parameters[0].Value = model.tname;
|
|
parameters[1].Value = model.ttype;
|
|
parameters[2].Value = model.tcharge;
|
|
parameters[3].Value = model.iffreeshipping;
|
|
parameters[4].Value = model.Id;
|
|
int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
|
|
if (rows > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// GoodsZT或者GoodsOrders
|
|
/// </summary>
|
|
public int UpdateSeef(string Sel, int SelValue, Int64 Id)
|
|
{
|
|
String sql = "update freighttemplate set " + Sel + "=@SelValue where Id=@Id";
|
|
SqlParameter[] para = { new SqlParameter("@SelValue", SqlDbType.Int),
|
|
new SqlParameter("@Id", SqlDbType.Int, 4) };
|
|
para[0].Value = SelValue;
|
|
para[1].Value = Id;
|
|
return Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(sql, para);
|
|
}
|
|
/// <summary>
|
|
/// 删除一条数据
|
|
/// </summary>
|
|
public bool Delete(int Id)
|
|
{
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("delete from freighttemplate ");
|
|
strSql.Append(" where Id=@Id");
|
|
SqlParameter[] parameters = {
|
|
new SqlParameter("@Id", SqlDbType.Int,4)
|
|
};
|
|
parameters[0].Value = Id;
|
|
|
|
int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
|
|
if (rows > 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 得到一个对象实体
|
|
/// </summary>
|
|
public Mtxfw.Model.freighttemplate GetModel(int Id)
|
|
{
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select top 1 * from freighttemplate ");
|
|
strSql.Append(" where Id=@Id");
|
|
SqlParameter[] parameters = {
|
|
new SqlParameter("@Id", SqlDbType.Int,4)
|
|
};
|
|
parameters[0].Value = Id;
|
|
|
|
Mtxfw.Model.freighttemplate model = new Mtxfw.Model.freighttemplate();
|
|
DataSet ds = Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString(), parameters);
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
model.Id = Convert.ToInt32(ds.Tables[0].Rows[0]["Id"].ToString());
|
|
model.tname = ds.Tables[0].Rows[0]["tname"].ToString();
|
|
model.ttype = Convert.ToInt32(ds.Tables[0].Rows[0]["ttype"].ToString());
|
|
model.tcharge = Convert.ToInt32(ds.Tables[0].Rows[0]["tcharge"].ToString());
|
|
model.iffreeshipping = Convert.ToInt32(ds.Tables[0].Rows[0]["iffreeshipping"].ToString());
|
|
model.gtype = Convert.ToInt32(ds.Tables[0].Rows[0]["gtype"].ToString());
|
|
return model;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获得数据列表
|
|
/// </summary>
|
|
public DataSet GetList(string strWhere)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select * ");
|
|
strSql.Append(" FROM freighttemplate ");
|
|
if (strWhere.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + strWhere);
|
|
}
|
|
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(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 freighttemplate ");
|
|
if (strWhere.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + strWhere);
|
|
}
|
|
strSql.Append(" order by " + filedOrder);
|
|
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|