添加项目文件。
This commit is contained in:
131
Epost.DAL/StoreDAL.cs
Normal file
131
Epost.DAL/StoreDAL.cs
Normal file
@ -0,0 +1,131 @@
|
||||
using Epost.Common;
|
||||
using Epost.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Epost.DAL
|
||||
{
|
||||
public class StoreDAL
|
||||
{
|
||||
DataBaseOpration.OprationSqlDAL db = DB_DLL.GetInstance();
|
||||
|
||||
|
||||
#region 分页获取用户表列表
|
||||
|
||||
public List<StoreModel> GetStoreListByPageByMySql(string strWhere, string orderby, int startIndex, int endIndex, out int recordCount)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
StringBuilder strSql = new StringBuilder();
|
||||
strSql.Append("SELECT * from store WHERE 1 = 1 ");
|
||||
|
||||
if (!string.IsNullOrEmpty(strWhere.Trim()))
|
||||
{
|
||||
|
||||
strSql.Append(strWhere);
|
||||
}
|
||||
|
||||
|
||||
if (!string.IsNullOrEmpty(orderby.Trim()))
|
||||
{
|
||||
|
||||
strSql.Append(" order by " + orderby);
|
||||
}
|
||||
else
|
||||
{
|
||||
strSql.Append(" order by location asc");
|
||||
}
|
||||
|
||||
strSql.AppendFormat(" limit {0},{1}", startIndex, endIndex);
|
||||
DataTable dt = db.GetsqlForDT(strSql.ToString());
|
||||
List<StoreModel> list = ModelConvertHelper<StoreModel>.ConvertToList(dt);
|
||||
|
||||
strSql.Remove(0, strSql.Length);
|
||||
strSql.Append("SELECT COUNT(*) FROM store AS T ");
|
||||
if (!string.IsNullOrEmpty(strWhere.Trim()))
|
||||
{
|
||||
strSql.AppendFormat(" WHERE 1=1 {0}", strWhere);
|
||||
}
|
||||
|
||||
object obj = db.GetsqlForDT(strSql.ToString()).Rows[0][0];
|
||||
if (obj != null)
|
||||
recordCount = Convert.ToInt32(obj);
|
||||
else
|
||||
recordCount = 0;
|
||||
|
||||
return list;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLog(GetType(), ex.Message);
|
||||
recordCount = 0;
|
||||
return new List<Model.StoreModel>();
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region add
|
||||
|
||||
public bool AddStore(StoreModel model)
|
||||
{
|
||||
|
||||
string sql = "insert into store(shopid,name,location,orderway,matchid,prino,batchno,fleet) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')";
|
||||
sql = string.Format(sql, model.shopid,model.name,model.location,model.orderway,model.matchid,model.prino,model.batchno,model.fleet);
|
||||
int x = db.InsertSql(sql);
|
||||
if (x > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool AddStore(DataTable ds,Dictionary<string,string> diclist)
|
||||
{
|
||||
|
||||
bool bo= db.UpdateData( ds,"store", diclist);
|
||||
if (bo)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogInfo("导入失败");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region del
|
||||
|
||||
public bool deleteStore()
|
||||
{
|
||||
|
||||
string sql = "delete from store";
|
||||
|
||||
long x = db.DeleteSql(sql);
|
||||
if (x > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user