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.

124 lines
5.0 KiB
C#

10 months ago
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.Areas.Import.Models.CargoName;
using HcUtility.Comm;
using Microsoft.Practices.EnterpriseLibrary.Data;
namespace DSWeb.Areas.Import.DAL.CargoName
{
public partial class CargoNameDAL
{
#region 厂号
static public List<Import_FactoryNo> GetFactoryNoList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("GID,CLIENTGID,FactoryNo,Remark");
strSql.Append(" from Import_FactoryNo ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
return SetFactoryNo(strSql);
}
private static List<Import_FactoryNo> SetFactoryNo(StringBuilder strSql)
{
var headList = new List<Import_FactoryNo>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
Import_FactoryNo data = new Import_FactoryNo();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.CLIENTGID = Convert.ToString(reader["CLIENTGID"]);
data.FACTORYNO = Convert.ToString(reader["FACTORYNO"]);
data.REMARK = Convert.ToString(reader["REMARK"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 商品名称
static public List<Import_CargoName> GetCargoNameList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("GID,CLIENTGID,ENNAME,CNNAME,HS_ID,CIQ_ID,MODIFIEDUSER,MODIFIEDTIME");
strSql.Append(",(select code+'_'+name from import_cargoinfo where id=HS_ID)HSREF");
strSql.Append(",(select ciqcode+'_'+ciqname from import_cargoCIQ where id=CIQ_ID)CIQREF,SBYS,CARGOTYPE,CODENAME,AREA,TAGPICURL ");
strSql.Append(" from Import_CargoName ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
return SetCargoName(strSql);
}
private static List<Import_CargoName> SetCargoName(StringBuilder strSql)
{
var headList = new List<Import_CargoName>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
Import_CargoName data = new Import_CargoName();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.CLIENTGID = Convert.ToString(reader["CLIENTGID"]);
data.ENNAME = Convert.ToString(reader["ENNAME"]);
data.CNNAME = Convert.ToString(reader["CNNAME"]);
data.HS_ID = Convert.ToString(reader["HS_ID"]);
data.CIQ_ID = Convert.ToString(reader["CIQ_ID"]);
data.MODIFIEDUSER = Convert.ToString(reader["MODIFIEDUSER"]);
data.MODIFIEDTIME = Convert.ToString(reader["MODIFIEDTIME"]);
data.HSREF = Convert.ToString(reader["HSREF"]);
data.CIQREF = Convert.ToString(reader["CIQREF"]);
data.SBYS = Convert.ToString(reader["SBYS"]);
data.CARGOTYPE = Convert.ToString(reader["CARGOTYPE"]);
data.CODENAME = Convert.ToString(reader["CODENAME"]);
data.AREA = Convert.ToString(reader["AREA"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 获取商品名称
static public int GetGoodCode ( string CLIENTGID,string USERID )
{
var strSql = new StringBuilder();
strSql.Append(" insert into Import_Cargoname (GID,CLIENTGID,AREA,CODENAME,ENNAME,CNNAME,MODIFIEDUSER,MODIFIEDTIME) ");
strSql.Append(" select newid(),'" + CLIENTGID + "','国内',GOODCODE ");
strSql.Append(" ,case descrip when '' then goodcode else descrip end ");
strSql.Append(" ,goodname,'" + USERID + "',getdate() ");
strSql.Append(" from code_goods ");
var _count = 0;
Database db = DatabaseFactory.CreateDatabase();
_count = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
return _count;
}
#endregion
}
}