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

231 lines
8.4 KiB
C#

using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
namespace Mtxfw.DAL
{
/// <summary>
/// 数据访问类:order_product_info
/// </summary>
public partial class order_product_info : Mtxfw.Utility.Myabstract
{
public order_product_info()
: base("order_product_info")
{ }
/// <summary>
/// 增加一条数据
/// </summary>
public int Add(Mtxfw.Model.order_product_info model)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("insert into order_product_info(");
strSql.Append("pid,orderid,selcolor,guige,DJprice,Totalprice,Totalnum,SubmitTime,UserID,utype,gtype)");
strSql.Append(" values (");
strSql.Append("@pid,@orderid,@selcolor,@guige,@DJprice,@Totalprice,@Totalnum,@SubmitTime,@UserID,@utype,@gtype)");
strSql.Append(";select SCOPE_IDENTITY()");
SqlParameter[] parameters = {
new SqlParameter("@pid", SqlDbType.Int),
new SqlParameter("@orderid", SqlDbType.Int),
new SqlParameter("@selcolor", SqlDbType.VarChar,100),
new SqlParameter("@guige", SqlDbType.VarChar,100),
new SqlParameter("@DJprice", SqlDbType.Money),
new SqlParameter("@Totalprice", SqlDbType.Money),
new SqlParameter("@Totalnum", SqlDbType.Int),
new SqlParameter("@SubmitTime", SqlDbType.VarChar,50),
new SqlParameter("@UserID", SqlDbType.Int),
new SqlParameter("@utype", SqlDbType.VarChar,20),
new SqlParameter("@gtype", SqlDbType.Int)};
parameters[0].Value = model.pid;
parameters[1].Value = model.orderid;
parameters[2].Value = model.selcolor;
parameters[3].Value = model.guige;
parameters[4].Value = model.DJprice;
parameters[5].Value = model.Totalprice;
parameters[6].Value = model.Totalnum;
parameters[7].Value = model.SubmitTime;
parameters[8].Value = model.UserID;
parameters[9].Value = model.utype;
parameters[10].Value = model.gtype;
object obj = Mtxfw.Utility.SqlDbHelper_U.GetObject(strSql.ToString(), parameters);
if (obj.ToString() == "")
{
return 0;
}
else
{
return Convert.ToInt32(obj);
}
}
/// <summary>
/// 删除一条数据
/// </summary>
public bool Delete(int Id)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete from order_product_info ");
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 bool DeleteList(int orderid)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("delete from order_product_info ");
strSql.Append(" where orderid=@orderid");
SqlParameter[] parameters = {
new SqlParameter("@orderid", SqlDbType.Int,4)
};
parameters[0].Value = orderid;
int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters);
if (rows > 0)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 得到一个对象实体
/// </summary>
public Mtxfw.Model.order_product_info GetModel(int Id)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select top 1 * from order_product_info a");
strSql.Append(" where Id=@Id");
SqlParameter[] parameters = {
new SqlParameter("@Id", SqlDbType.Int,4)
};
parameters[0].Value = Id;
Mtxfw.Model.order_product_info model = new Mtxfw.Model.order_product_info();
DataSet ds = Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString(), parameters);
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["Id"].ToString() != "")
{
model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
}
if (ds.Tables[0].Rows[0]["pid"].ToString() != "")
{
model.pid = int.Parse(ds.Tables[0].Rows[0]["pid"].ToString());
}
if (ds.Tables[0].Rows[0]["orderid"].ToString() != "")
{
model.orderid = int.Parse(ds.Tables[0].Rows[0]["orderid"].ToString());
}
if (ds.Tables[0].Rows[0]["DJprice"].ToString() != "")
{
model.DJprice = Convert.ToDouble(ds.Tables[0].Rows[0]["DJprice"].ToString());
}
if (ds.Tables[0].Rows[0]["Totalprice"].ToString() != "")
{
model.Totalprice = Convert.ToDouble(ds.Tables[0].Rows[0]["Totalprice"].ToString());
}
if (ds.Tables[0].Rows[0]["Totalnum"].ToString() != "")
{
model.Totalnum = int.Parse(ds.Tables[0].Rows[0]["Totalnum"].ToString());
}
if (ds.Tables[0].Rows[0]["SubmitTime"].ToString() != "")
{
model.SubmitTime = DateTime.Parse(ds.Tables[0].Rows[0]["SubmitTime"].ToString());
}
if (ds.Tables[0].Rows[0]["UserID"].ToString() != "")
{
model.UserID = int.Parse(ds.Tables[0].Rows[0]["UserID"].ToString());
}
else
{
model.UserID = 0;
}
if (ds.Tables[0].Rows[0]["IFDelete"].ToString() != "")
{
model.IFDelete = int.Parse(ds.Tables[0].Rows[0]["IFDelete"].ToString());
}
model.guige = ds.Tables[0].Rows[0]["guige"].ToString();
model.utype = ds.Tables[0].Rows[0]["utype"].ToString();
return model;
}
else
{
return null;
}
}
/// <summary>
/// 获得数据列表
/// </summary>
public DataSet GetList(string strWhere)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select * FROM order_product_info a");
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(" * FROM order_product_info ");
if (strWhere.Trim() != "")
{
strSql.Append(" where " + strWhere);
}
strSql.Append(" order by " + filedOrder);
return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString());
}
/// <summary>
/// 假删除
/// </summary>
public int UpdateIFDelete(int IFDelete, string IFDeleteTime, int orderid)
{
String sql = "update [order_product_info] set IFDelete=@IFDelete,IFDeleteTime=@IFDeleteTime where orderid=@orderid";
SqlParameter[] para = { new SqlParameter("@IFDelete", SqlDbType.Int),
new SqlParameter("@IFDeleteTime", SqlDbType.VarChar,50),
new SqlParameter("@orderid", SqlDbType.Int) };
para[0].Value = IFDelete;
para[1].Value = IFDeleteTime;
para[2].Value = orderid;
return Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(sql, para);
}
}
}