Files
g.hnyhua.cn/Mtxfw.DAL/freighttemplate_free.cs
2026-02-07 15:48:27 +08:00

192 lines
6.7 KiB
C#

using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
namespace Mtxfw.DAL
{
/// <summary>
/// 数据访问类:freighttemplate_free
/// </summary>
public partial class freighttemplate_free : Mtxfw.Utility.Myabstract
{
public freighttemplate_free()
: base("freighttemplate_free")
{ }
/// <summary>
/// 增加一条数据
/// </summary>
public int Add(Mtxfw.Model.freighttemplate_free model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into freighttemplate_free(");
strSql.Append("regions,freetype,fullpiece,fullyuan,fid)");
strSql.Append(" values (");
strSql.Append("@regions,@freetype,@fullpiece,@fullyuan,@fid)");
strSql.Append(";select SCOPE_IDENTITY()");
SqlParameter[] parameters = {
new SqlParameter("@regions", SqlDbType.NText),
new SqlParameter("@freetype", SqlDbType.Int),
new SqlParameter("@fullpiece", SqlDbType.Money),
new SqlParameter("@fullyuan", SqlDbType.Money),
new SqlParameter("@fid", SqlDbType.Int)};
parameters[0].Value = model.regions;
parameters[1].Value = model.freetype;
parameters[2].Value = model.fullpiece;
parameters[3].Value = model.fullyuan;
parameters[4].Value = model.fid;
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_free model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update freighttemplate_free set ");
strSql.Append("regions=@regions,");
strSql.Append("freetype=@freetype,");
strSql.Append("fullpiece=@fullpiece,");
strSql.Append("fullyuan=@fullyuan");
strSql.Append(" where ID=@ID");
SqlParameter[] parameters = {
new SqlParameter("@regions", SqlDbType.NText),
new SqlParameter("@freetype", SqlDbType.Int),
new SqlParameter("@fullpiece", SqlDbType.Money),
new SqlParameter("@fullyuan", SqlDbType.Money),
new SqlParameter("@ID", SqlDbType.Int)};
parameters[0].Value = model.regions;
parameters[1].Value = model.freetype;
parameters[2].Value = model.fullpiece;
parameters[3].Value = model.fullyuan;
parameters[4].Value = model.Id;
int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// fid
/// </summary>
public int Updatefid(int fid)
{
String sql = "update freighttemplate_freight set fid=@fid where fid=0";
SqlParameter[] para = { new SqlParameter("@fid", SqlDbType.Int, 4) };
para[0].Value = fid;
return Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(sql, para);
}
/// <summary>
/// 删除一条数据
/// </summary>
public bool Delete(int Id)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete from freighttemplate_free ");
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_free GetModel(int Id)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select top 1 * from freighttemplate_free ");
strSql.Append(" where Id=@Id");
SqlParameter[] parameters = {
new SqlParameter("@Id", SqlDbType.Int,4)
};
parameters[0].Value = Id;
Mtxfw.Model.freighttemplate_free model = new Mtxfw.Model.freighttemplate_free();
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.regions = ds.Tables[0].Rows[0]["regions"].ToString();
model.freetype = Convert.ToInt32(ds.Tables[0].Rows[0]["freetype"].ToString());
model.fullpiece = Convert.ToDouble(ds.Tables[0].Rows[0]["fullpiece"].ToString());
model.fullyuan = Convert.ToDouble(ds.Tables[0].Rows[0]["fullyuan"].ToString());
model.fid = Convert.ToInt32(ds.Tables[0].Rows[0]["fid"].ToString());
return model;
}
else
{
return null;
}
}
/// <summary>
/// 获得数据列表
/// </summary>
public DataSet GetList(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select * ");
strSql.Append(" FROM freighttemplate_free ");
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_free ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
strSql.Append(" order by " + filedOrder);
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
}
}
}