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.
DS7/DSWeb/Areas/MvcShipping/DAL/MsCompanysBX/MsCompanysBXDAL.cs

80 lines
3.3 KiB
C#

using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.MsCompanys;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
using System.Data.SqlClient;
using DSWeb.DataAccess;
using System.IO;
using HcUtility.Core;
namespace DSWeb.MvcShipping.DAL.MsCompanysDAL
{
public class MsCompanysBXDAL
{
#region 查询
static public CompanyBX GetData(string strPath, string strPhotoPath, string strCondition)
{
String strSql = "SELECT top 1 * FROM company_bx where 1=1 ";//and (ISDISABLE=0 or ISDISABLE is null)
if (!string.IsNullOrEmpty(strCondition))
{
strSql += " and " + strCondition;
}
var list = SetData(strPath, strPhotoPath, strSql);
if (list.Count > 0)
{
return list[0];
}
return new CompanyBX();
}
private static List<CompanyBX> SetData(string strPath,string strPhotoPath, String strSql)
{
var headList = new List<CompanyBX>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
CompanyBX data = new CompanyBX();
#region Set DB data to Object
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//GID
data.ComId = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//GID
data.YingYeZhiZhao = (reader["YingYeZhiZhao"] == null ? "" : Convert.ToString(reader["YingYeZhiZhao"]));//GID
data.LianXiRen = (reader["LianXiRen"] == null ? "" : Convert.ToString(reader["LianXiRen"]));//GID
data.ShouJi = (reader["ShouJi"] == null ? "" : Convert.ToString(reader["ShouJi"]));//GID
data.QQ = (reader["QQ"] == null ? "" : Convert.ToString(reader["QQ"]));//GID
data.EMAIL = (reader["EMAIL"] == null ? "" : Convert.ToString(reader["EMAIL"]));//GID
data.PINTTAISHIYONGXIEYI = (reader["PINTTAISHIYONGXIEYI"] == null ? "" : Convert.ToString(reader["PINTTAISHIYONGXIEYI"]));//GID
data.BAOXIANJINGJIWEITUOSHU = (reader["BAOXIANJINGJIWEITUOSHU"] == null ? "" : Convert.ToString(reader["BAOXIANJINGJIWEITUOSHU"]));//GID
data.BAOXIANJINGJIHEZUOXIEYI = (reader["BAOXIANJINGJIHEZUOXIEYI"] == null ? "" : Convert.ToString(reader["BAOXIANJINGJIHEZUOXIEYI"]));//GID
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 保存
public static DBResult Save(CompanyBX headData)
{
string Del = "delete from company_bx where comid = '"+headData.ComId+"'";
Database db = DatabaseFactory.CreateDatabase();
db.ExecuteNonQuery(CommandType.Text,Del);
var modb = new ModelObjectDB();
DBResult result = modb.Save(headData);
return result;
}
#endregion
}
}