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.
296 lines
13 KiB
C#
296 lines
13 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using DSWeb.MvcShipping.Models.OpFenDetail;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
namespace DSWeb.MvcShipping.DAL.MsOpFenDetail
|
|
{
|
|
public class MsOpFenDetailDAL
|
|
{
|
|
static Database db = DatabaseFactory.CreateDatabase();
|
|
/// <summary>
|
|
/// 分页获取数据列表
|
|
/// </summary>
|
|
static public List<OpFenDetail> 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);
|
|
}
|
|
else
|
|
{
|
|
strSql.Append("order by T.GID desc");
|
|
}
|
|
strSql.Append(")AS Row, T.* from op_ctn_fendetail T ");
|
|
if (!string.IsNullOrEmpty(strWhere.Trim()))
|
|
{
|
|
strSql.Append(" WHERE " + strWhere);
|
|
}
|
|
strSql.Append(" ) TT");
|
|
strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
|
|
//公共代码
|
|
return SetData(strSql);
|
|
}
|
|
/// <summary>
|
|
/// 根据id获取实例
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
static public OpFenDetail GetData(string GID)
|
|
{
|
|
//动软代码
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select top 1 GID,COILNO,SIZE,COLOUR,NWKGS,GWKGS,NLENGTH,TGKGS,FXNO,XMODEL,LIKGS,FXMARK,IOMARK,FXCOLNO,OPERUSER,OPERTIME from op_ctn_fendetail ");
|
|
strSql.Append(" where GID=@GID ");
|
|
SqlParameter[] parameters = {
|
|
new SqlParameter("@GID", SqlDbType.VarChar,50) };
|
|
parameters[0].Value = GID;
|
|
//公共代码
|
|
return SetData(strSql).FirstOrDefault();
|
|
}
|
|
/// <summary>
|
|
/// 获取记录总数
|
|
/// </summary>
|
|
static public int GetRecordCount(string strWhere)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("select count(1) FROM op_ctn_fendetail ");//只改表名
|
|
if (strWhere.Trim() != "")
|
|
{
|
|
strSql.Append(" where " + strWhere);
|
|
}
|
|
return Convert.ToInt32(db.ExecuteScalar(CommandType.Text, strSql.ToString()));
|
|
}
|
|
/// <summary>
|
|
/// 执行sql
|
|
/// </summary>
|
|
/// <param name="strSql"></param>
|
|
/// <returns></returns>
|
|
private static List<OpFenDetail> SetData(StringBuilder strSql)
|
|
{
|
|
#region 公共代码
|
|
var headList = new List<OpFenDetail>();
|
|
using (IDataReader row = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (row.Read())
|
|
{
|
|
OpFenDetail model = new OpFenDetail();
|
|
#region 动软代码
|
|
if (row["GID"] != null)
|
|
{
|
|
model.GID = row["GID"].ToString();
|
|
}
|
|
if (row["COILNO"] != null)
|
|
{
|
|
model.COILNO = row["COILNO"].ToString();
|
|
}
|
|
if (row["SIZE"] != null)
|
|
{
|
|
model.SIZE = row["SIZE"].ToString();
|
|
}
|
|
if (row["COLOUR"] != null)
|
|
{
|
|
model.COLOUR = row["COLOUR"].ToString();
|
|
}
|
|
if (row["NWKGS"] != null && row["NWKGS"].ToString() != "")
|
|
{
|
|
model.NWKGS = decimal.Parse(row["NWKGS"].ToString());
|
|
}
|
|
if (row["GWKGS"] != null && row["GWKGS"].ToString() != "")
|
|
{
|
|
model.GWKGS = decimal.Parse(row["GWKGS"].ToString());
|
|
}
|
|
if (row["NLENGTH"] != null && row["NLENGTH"].ToString() != "")
|
|
{
|
|
model.NLENGTH = int.Parse(row["NLENGTH"].ToString());
|
|
}
|
|
if (row["TGKGS"] != null && row["TGKGS"].ToString() != "")
|
|
{
|
|
model.TGKGS = decimal.Parse(row["TGKGS"].ToString());
|
|
}
|
|
if (row["FXNO"] != null)
|
|
{
|
|
model.FXNO = row["FXNO"].ToString();
|
|
}
|
|
if (row["XMODEL"] != null)
|
|
{
|
|
model.XMODEL = row["XMODEL"].ToString();
|
|
}
|
|
if (row["LIKGS"] != null && row["LIKGS"].ToString() != "")
|
|
{
|
|
model.LIKGS = decimal.Parse(row["LIKGS"].ToString());
|
|
}
|
|
if (row["FXMARK"] != null && row["FXMARK"].ToString() != "")
|
|
{
|
|
model.FXMARK = int.Parse(row["FXMARK"].ToString());
|
|
}
|
|
if (row["IOMARK"] != null && row["IOMARK"].ToString() != "")
|
|
{
|
|
model.IOMARK = int.Parse(row["IOMARK"].ToString());
|
|
}
|
|
if (row["FXCOLNO"] != null)
|
|
{
|
|
model.FXCOLNO = row["FXCOLNO"].ToString();
|
|
}
|
|
if (row["OPERUSER"] != null)
|
|
{
|
|
model.OPERUSER = row["OPERUSER"].ToString();
|
|
}
|
|
if (row["OPERTIME"] != null)
|
|
{
|
|
model.OPERTIME = Convert.ToDateTime(row["OPERTIME"].ToString());
|
|
}
|
|
#endregion
|
|
headList.Add(model);
|
|
}
|
|
row.Close();
|
|
}
|
|
return headList;
|
|
#endregion
|
|
}
|
|
/// <summary>
|
|
/// 增加一条数据
|
|
/// </summary>
|
|
static public int Add(OpFenDetail model)
|
|
{
|
|
//动软代码
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("insert into op_ctn_fendetail(");
|
|
strSql.Append("GID,COILNO,SIZE,COLOUR,NWKGS,GWKGS,NLENGTH,TGKGS,FXNO,XMODEL,LIKGS,FXMARK,IOMARK,FXCOLNO,OPERUSER,OPERTIME)");
|
|
strSql.Append(" values (");
|
|
strSql.Append("@GID,@COILNO,@SIZE,@COLOUR,@NWKGS,@GWKGS,@NLENGTH,@TGKGS,@FXNO,@XMODEL,@LIKGS,@FXMARK,@IOMARK,@FXCOLNO,@OPERUSER,@OPERTIME)");
|
|
SqlParameter[] parameters = {
|
|
new SqlParameter("@GID", SqlDbType.VarChar,50),
|
|
new SqlParameter("@COILNO", SqlDbType.VarChar,10),
|
|
new SqlParameter("@SIZE", SqlDbType.VarChar,50),
|
|
new SqlParameter("@COLOUR", SqlDbType.VarChar,50),
|
|
new SqlParameter("@NWKGS", SqlDbType.Decimal,9),
|
|
new SqlParameter("@GWKGS", SqlDbType.Decimal,9),
|
|
new SqlParameter("@NLENGTH", SqlDbType.Int,4),
|
|
new SqlParameter("@TGKGS", SqlDbType.Decimal,9),
|
|
new SqlParameter("@FXNO", SqlDbType.VarChar,50),
|
|
new SqlParameter("@XMODEL", SqlDbType.VarChar,50),
|
|
new SqlParameter("@LIKGS", SqlDbType.Decimal,9),
|
|
new SqlParameter("@FXMARK", SqlDbType.Int,4),
|
|
new SqlParameter("@IOMARK", SqlDbType.Int,4),
|
|
new SqlParameter("@FXCOLNO", SqlDbType.VarChar,50),
|
|
new SqlParameter("@OPERUSER", SqlDbType.VarChar,50),
|
|
new SqlParameter("@OPERTIME", SqlDbType.DateTime)
|
|
|
|
};
|
|
parameters[0].Value = model.GID;
|
|
parameters[1].Value = model.COILNO;
|
|
parameters[2].Value = model.SIZE;
|
|
parameters[3].Value = model.COLOUR;
|
|
parameters[4].Value = model.NWKGS;
|
|
parameters[5].Value = model.GWKGS;
|
|
parameters[6].Value = model.NLENGTH;
|
|
parameters[7].Value = model.TGKGS;
|
|
parameters[8].Value = model.FXNO;
|
|
parameters[9].Value = model.XMODEL;
|
|
parameters[10].Value = model.LIKGS;
|
|
parameters[11].Value = model.FXMARK;
|
|
parameters[12].Value = model.IOMARK;
|
|
parameters[13].Value = model.FXCOLNO;
|
|
parameters[14].Value = model.OPERUSER;
|
|
parameters[15].Value = model.OPERTIME;
|
|
//公共代码
|
|
SqlCommand com = new SqlCommand();
|
|
com.CommandText = strSql.ToString();
|
|
com.Parameters.AddRange(parameters);
|
|
return db.ExecuteNonQuery(com);
|
|
}
|
|
/// <summary>
|
|
/// 更新一条数据
|
|
/// </summary>
|
|
static public int Update(OpFenDetail model)
|
|
{
|
|
//动软代码
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("update op_ctn_fendetail set ");
|
|
strSql.Append("COILNO=@COILNO,");
|
|
strSql.Append("SIZE=@SIZE,");
|
|
strSql.Append("COLOUR=@COLOUR,");
|
|
strSql.Append("NWKGS=@NWKGS,");
|
|
strSql.Append("GWKGS=@GWKGS,");
|
|
strSql.Append("NLENGTH=@NLENGTH,");
|
|
strSql.Append("TGKGS=@TGKGS,");
|
|
strSql.Append("FXNO=@FXNO,");
|
|
strSql.Append("XMODEL=@XMODEL,");
|
|
strSql.Append("LIKGS=@LIKGS,");
|
|
strSql.Append("FXMARK=@FXMARK,");
|
|
strSql.Append("IOMARK=@IOMARK,");
|
|
strSql.Append("FXCOLNO=@FXCOLNO,");
|
|
strSql.Append("OPERUSER=@OPERUSER,");
|
|
strSql.Append("OPERTIME=@OPERTIME");
|
|
strSql.Append(" where GID=@GID ");
|
|
SqlParameter[] parameters = {
|
|
new SqlParameter("@COILNO", SqlDbType.VarChar,10),
|
|
new SqlParameter("@SIZE", SqlDbType.VarChar,50),
|
|
new SqlParameter("@COLOUR", SqlDbType.VarChar,50),
|
|
new SqlParameter("@NWKGS", SqlDbType.Decimal,9),
|
|
new SqlParameter("@GWKGS", SqlDbType.Decimal,9),
|
|
new SqlParameter("@NLENGTH", SqlDbType.Int,4),
|
|
new SqlParameter("@TGKGS", SqlDbType.Decimal,9),
|
|
new SqlParameter("@FXNO", SqlDbType.VarChar,50),
|
|
new SqlParameter("@XMODEL", SqlDbType.VarChar,50),
|
|
new SqlParameter("@LIKGS", SqlDbType.Decimal,9),
|
|
new SqlParameter("@FXMARK", SqlDbType.Int,4),
|
|
new SqlParameter("@IOMARK", SqlDbType.Int,4),
|
|
new SqlParameter("@FXCOLNO", SqlDbType.VarChar,50),
|
|
new SqlParameter("@OPERUSER", SqlDbType.VarChar,50),
|
|
new SqlParameter("@OPERTIME", SqlDbType.DateTime),
|
|
new SqlParameter("@GID", SqlDbType.VarChar,50)};
|
|
parameters[0].Value = model.COILNO;
|
|
parameters[1].Value = model.SIZE;
|
|
parameters[2].Value = model.COLOUR;
|
|
parameters[3].Value = model.NWKGS;
|
|
parameters[4].Value = model.GWKGS;
|
|
parameters[5].Value = model.NLENGTH;
|
|
parameters[6].Value = model.TGKGS;
|
|
parameters[7].Value = model.FXNO;
|
|
parameters[8].Value = model.XMODEL;
|
|
parameters[9].Value = model.LIKGS;
|
|
parameters[10].Value = model.FXMARK;
|
|
parameters[11].Value = model.IOMARK;
|
|
parameters[12].Value = model.FXCOLNO;
|
|
parameters[13].Value = model.OPERUSER;
|
|
parameters[14].Value = model.OPERTIME;
|
|
parameters[15].Value = model.GID;
|
|
//公共代码
|
|
SqlCommand com = new SqlCommand();
|
|
com.CommandText = strSql.ToString();
|
|
com.Parameters.AddRange(parameters);
|
|
return db.ExecuteNonQuery(com);
|
|
}
|
|
#region 扩展方法
|
|
/// <summary>
|
|
/// 根据业务编号跟新导出标记
|
|
/// </summary>
|
|
/// <param name="where"></param>
|
|
/// <returns></returns>
|
|
static public int UpdatebyBsno(string fxcolno)
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("update op_ctn_fendetail set IOMARK = 1");
|
|
strSql.Append(" where FXCOLNO=@FXCOLNO ");
|
|
SqlParameter[] parameters = {new SqlParameter("@FXCOLNO", SqlDbType.VarChar,50) };
|
|
parameters[0].Value = fxcolno;
|
|
//公共代码
|
|
SqlCommand com = new SqlCommand();
|
|
com.CommandText = strSql.ToString();
|
|
com.Parameters.AddRange(parameters);
|
|
return db.ExecuteNonQuery(com);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|