|
|
using Dapper;
|
|
|
using Estsh.Core.Dapper;
|
|
|
using Estsh.Core.IRepositories;
|
|
|
using Estsh.Core.Model.Result;
|
|
|
using Estsh.Core.Models;
|
|
|
using Estsh.Core.Repository.IRepositories;
|
|
|
using Estsh.Core.Util;
|
|
|
using System.Collections;
|
|
|
using System.Data;
|
|
|
using System.Text;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 更新人:sitong.dong
|
|
|
* 描述:包规定义
|
|
|
* 修改时间:2022.06.22
|
|
|
* 修改日志:系统迭代升级
|
|
|
*
|
|
|
**************************************************************************************************/
|
|
|
namespace Estsh.Core.Repositories
|
|
|
{
|
|
|
public class PackSpecDefineRepository : BaseRepository<SysPackSpec>, IPackSpecDefineRepository
|
|
|
{
|
|
|
public PackSpecDefineRepository(DapperDbContext _dapperDbContext) : base(_dapperDbContext)
|
|
|
{
|
|
|
}
|
|
|
#region 成员方法
|
|
|
/// <summary>
|
|
|
/// 获得菜单列表数据
|
|
|
/// </summary>
|
|
|
public List<SysPackSpec> getList(string strWhere,string filedOrder)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("SELECT * FROM sys_pack_spec ");
|
|
|
if (!strWhere.Trim().Equals(""))
|
|
|
{
|
|
|
strSql.Append(" where " + strWhere);
|
|
|
}
|
|
|
if (filedOrder != null && !filedOrder.Trim().Equals(""))
|
|
|
{
|
|
|
strSql.Append(" order by " + filedOrder);
|
|
|
}
|
|
|
List<SysPackSpec> result = dbConn.Query<SysPackSpec>(strSql.ToString()).ToList();
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取分页数据列表
|
|
|
/// </summary>
|
|
|
public Hashtable getListByPage(int PageSize, int PageIndex, string strWhere, string OrderBy)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
Hashtable result = new Hashtable();
|
|
|
DynamicParameters Params = new DynamicParameters();
|
|
|
Params.Add("@TotalCount", 0, DbType.Int32, ParameterDirection.Output);
|
|
|
Params.Add("@TotalPage", 0, DbType.Int32, ParameterDirection.Output);
|
|
|
Params.Add("@GroupColumn", "");
|
|
|
Params.Add("@Table", "sys_pack_spec");
|
|
|
Params.Add("@Column", "*");
|
|
|
Params.Add("@PageSize", PageSize);
|
|
|
Params.Add("@CurrentPage", PageIndex);
|
|
|
Params.Add("@Condition", strWhere);
|
|
|
Params.Add("@OrderColumn", OrderBy);
|
|
|
Params.Add("@Group", 0);
|
|
|
List<SysPackSpec> dataList = dbConn.Query<SysPackSpec>("Com_Pagination", Params, commandType: CommandType.StoredProcedure).ToList();
|
|
|
result.Add("dataList", dataList);
|
|
|
result.Add("totalCount", Params.Get<int>("@TotalCount"));
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 插入菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int savePackSpec(SysPackSpec htParams)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
StringBuilder SqlStringBuilder = new StringBuilder(1024);
|
|
|
SqlStringBuilder.Append("INSERT INTO dbo.sys_pack_spec(spec_name ,pallet_qty,carton_qty,box_qty ,enabled,create_userid,create_time )VALUES ");
|
|
|
SqlStringBuilder.Append("(@specName,@palletQty,@cartonQty,@boxQty,@enabled,@createUserid,CONVERT(varchar(50), GETDATE(), 21)) ");
|
|
|
int result = dbConn.Execute(SqlStringBuilder.ToString(), htParams);
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int updatePackSpec(SysPackSpec htParams)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
StringBuilder SqlStringBuilder = new StringBuilder(1024);
|
|
|
SqlStringBuilder.Append("UPDATE sys_pack_spec SET ");
|
|
|
SqlStringBuilder.Append("spec_name=@specName,pallet_qty=@palletQty,carton_qty=@cartonQty,box_qty=@boxQty,enabled=@enabled,update_userid=@updateUserid,update_time=CONVERT(varchar(50), GETDATE(), 21) ");
|
|
|
SqlStringBuilder.Append("WHERE spec_id=@specId ");
|
|
|
int result = dbConn.Execute(SqlStringBuilder.ToString(), htParams);
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public int deletePackSpec(String spec_id )
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
String delStr = "update sys_pack_spec set Enabled='N' WHERE spec_id = @spec_id";
|
|
|
DynamicParameters htparams = new DynamicParameters();
|
|
|
htparams.Add("@spec_id", spec_id);
|
|
|
int result = dbConn.Execute(delStr, htparams);
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
//启用
|
|
|
public int EnableData(String ids)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
String delStr = "update sys_pack_spec set Enabled='Y' WHERE spec_id in (" + ids + ")";
|
|
|
int result = dbConn.Execute(delStr);
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//禁用
|
|
|
public int DisableData(String ids)
|
|
|
{
|
|
|
using (IDbConnection dbConn = dapperDbContext.GetDbConnection())
|
|
|
{
|
|
|
dbConn.Open();
|
|
|
String delStr = "update sys_pack_spec set Enabled='N' WHERE spec_id in (" + ids + ")";
|
|
|
int result = dbConn.Execute(delStr);
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
#endregion 成员方法
|
|
|
}
|
|
|
}
|