using System;
using System.Data;
using System.Text;
using System.Collections.Generic;
using System.Data.SqlClient;
using ApServerProvider;
using DbCommon;
using System.Collections;
using Estsh.Web.Util;
/***************************************************************************************************
*
* 作者:王勇
*
* *************************************************************************************************/
namespace Estsh.Core.Repositories
{
///
/// 处理菜单模块的业务数据
///
public class SeedPartDefineDal : BaseApp
{
public SeedPartDefineDal(RemotingProxy remotingProxy)
: base(remotingProxy)
{
}
#region 成员方法
///
/// 根据传入条件获得菜单列表数据
///
public DataTable getList(string strWhere, string filedOrder)
{
lock (_remotingProxy)
{
StringBuilder strSql = new StringBuilder();
strSql.Append(" select * from dbo.sys_part_cust_order ");
if (strWhere != null && !strWhere.Trim().Equals(""))
{
strSql.Append(" where " + strWhere);
}
if (filedOrder != null && !filedOrder.Trim().Equals(""))
{
strSql.Append(" order by " + filedOrder);
}
return this._remotingProxy.GetDataTable(strSql.ToString());
}
}
///
/// 根据分页条件获取分页数据列表
///
public Hashtable getListByPage(RemotingProxy.RecordStatus status,int PageSize, int PageIndex, string strWhere, string OrderBy)
{
lock (_remotingProxy)
{
Hashtable result = new Hashtable();
List parameters = new List();
parameters.Add(new StoreProcedureParameter(DbType.Int32, ParameterDirection.Output, "@TotalCount", 100));
parameters.Add(new StoreProcedureParameter(DbType.Int32, ParameterDirection.Output, "@TotalPage", 100));
parameters.Add(new StoreProcedureParameter(DbType.String, ParameterDirection.Input, "@Table", " dbo.sys_part_subs a LEFT JOIN dbo.sys_part b ON a.part_id=b.part_id LEFT JOIN dbo.sys_part c ON a.sub_part_id=c.part_id "));
parameters.Add(new StoreProcedureParameter(DbType.String, ParameterDirection.Input, "@Column", " b.part_no, c.part_no AS sub_part_no,a.sub_part_type,a.guid "));
parameters.Add(new StoreProcedureParameter(DbType.String, ParameterDirection.Input, "@OrderColumn", OrderBy));
parameters.Add(new StoreProcedureParameter(DbType.String, ParameterDirection.Input, "@GroupColumn", ""));
parameters.Add(new StoreProcedureParameter(DbType.Int32, ParameterDirection.Input, "@PageSize", PageSize));
parameters.Add(new StoreProcedureParameter(DbType.Int32, ParameterDirection.Input, "@CurrentPage", PageIndex));
parameters.Add(new StoreProcedureParameter(DbType.Int32, ParameterDirection.Input, "@Group", 0));
parameters.Add(new StoreProcedureParameter(DbType.String, ParameterDirection.Input, "@Condition", strWhere));
Hashtable values = new Hashtable(2);
DataTable dt = new DataTable();
dt = _remotingProxy.ExecuteSotreProcedure("Com_Pagination", parameters, ref values);
ArrayList dataList = DataTypeConvert.NewObject.DataTableToArrayList(dt);
result.Add("dataList", dataList);
result.Add("totalCount", values["@TotalCount"].ToString());
return result;
}
}
/////
///// 获取下拉框菜单数据
/////
/////
//public DataTable getSelectSeedPartDefine()
//{
// StringBuilder strSql = new StringBuilder();
// strSql.Append("select SeedPartDefine_id as [value],name as [key] from dbo.sys_web_SeedPartDefine where parent_id = 0 AND enabled = 'Y' ");
// return _remotingProxy.GetDataTable(strSql.ToString());
//}
///
/// 插入菜单数据
///
///
///
public int saveSeedPartDefine(Hashtable htParams)
{
lock (_remotingProxy)
{
StringBuilder SqlStringBuilder = new StringBuilder(1024);
SqlStringBuilder.Append("INSERT INTO sys_part_subs (part_id ");
SqlStringBuilder.Append(" , sub_part_id ");
SqlStringBuilder.Append(" ,sub_part_type,create_ymd,create_hms) ");
SqlStringBuilder.Append(" VALUES(@part_id ");
SqlStringBuilder.Append(" , @sub_part_id ");
SqlStringBuilder.Append(" ,@sub_part_type)");
SqlStringBuilder.Append(" , CONVERT(VARCHAR(10),GETDATE(),23) ");
SqlStringBuilder.Append(" , CONVERT(VARCHAR(10),GETDATE(),108)) ");
return _remotingProxy.ExecuteNonQuery(SqlStringBuilder.ToString(), htParams);
}
}
///
///获取零件号信息
///
/// 零件号
///
public DataTable GetPartMessage(string aPartNo)
{
lock (_remotingProxy)
{
StringBuilder SqlStringBuilder = new StringBuilder(1024);
SqlStringBuilder.Append("SELECT * FROM sys_part WHERE part_no =@part_no and part_type = '1' ");
Hashtable values = new Hashtable();
values.Add("@part_no", aPartNo);
return _remotingProxy.GetDataTable(SqlStringBuilder.ToString(), values);
}
}
///
/// 验证零件号在子阶零件表中是否存在
///
/// 父零件ID
/// 子阶零件ID
/// true
public bool GetPartID(string aPartID, string aSubPartID)
{
lock (_remotingProxy)
{
StringBuilder SqlStringBuilder = new StringBuilder(1024);
SqlStringBuilder.Append("SELECT * FROM sys_part_subs WHERE part_id=@part_id and sub_part_id =@sub_part_id ");
Hashtable values = new Hashtable(1);
values.Add("@part_id", aPartID);
values.Add("@sub_part_id", aSubPartID);
return _remotingProxy.GetScalar(SqlStringBuilder.ToString(), values) != null;
}
}
///
/// 更新菜单数据
///
///
///
public int updateSeedPartDefine(Hashtable htParams)
{
lock (_remotingProxy)
{
StringBuilder SqlStringBuilder = new StringBuilder(1024);
SqlStringBuilder.Append("update sys_part_subs ");
SqlStringBuilder.Append("SET part_id=@part_id ");
SqlStringBuilder.Append(" , sub_part_id=@sub_part_id ,sub_part_type=@sub_part_type ");
SqlStringBuilder.Append("WHERE guid=@GUID ");
return _remotingProxy.ExecuteNonQuery(SqlStringBuilder.ToString(), htParams);
}
}
///
/// 删除菜单数据
///
///
///
public int deleteSeedPartDefine(String guid)
{
lock (_remotingProxy)
{
Hashtable htparams = new Hashtable();
htparams.Add("@guid", guid);
String delStr = "delete from sys_part_subs where part_id = @guid";
return _remotingProxy.ExecuteNonQuery(delStr, htparams);
}
}
///
/// 获取下拉框菜单数据
///
///
public DataTable getSelectSeedPartDefine()
{
lock (_remotingProxy)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select part_id as [value] ,part_no as [key] from sys_part where part_type = '1' ");
return _remotingProxy.GetDataTable(strSql.ToString());
}
}
///
/// 获取分页数据列表
///
/// 一页显示多少条数据
/// 当前第几页
/// 条件
/// 排序字段
///
public DataTable getTableListByPage(int PageSize, int PageIndex, string strWhere, string OrderBy)
{
lock (_remotingProxy)
{
Hashtable result = new Hashtable();
List parameters = new List();
parameters.Add(new StoreProcedureParameter(DbType.Int32, ParameterDirection.Output, "@TotalCount", 100));
parameters.Add(new StoreProcedureParameter(DbType.Int32, ParameterDirection.Output, "@TotalPage", 100));
parameters.Add(new StoreProcedureParameter(DbType.String, ParameterDirection.Input, "@Table", " dbo.sys_part_subs a LEFT JOIN dbo.sys_part b ON a.part_id=b.part_id LEFT JOIN dbo.sys_part c ON a.sub_part_id=c.part_id "));
parameters.Add(new StoreProcedureParameter(DbType.String, ParameterDirection.Input, "@Column", " b.part_no, c.part_no AS sub_part_no,a.sub_part_type,a.guid "));
parameters.Add(new StoreProcedureParameter(DbType.String, ParameterDirection.Input, "@OrderColumn", OrderBy));
parameters.Add(new StoreProcedureParameter(DbType.String, ParameterDirection.Input, "@GroupColumn", ""));
parameters.Add(new StoreProcedureParameter(DbType.Int32, ParameterDirection.Input, "@PageSize", PageSize));
parameters.Add(new StoreProcedureParameter(DbType.Int32, ParameterDirection.Input, "@CurrentPage", PageIndex));
parameters.Add(new StoreProcedureParameter(DbType.Int32, ParameterDirection.Input, "@Group", 0));
parameters.Add(new StoreProcedureParameter(DbType.String, ParameterDirection.Input, "@Condition", strWhere));
Hashtable values = new Hashtable(2);
DataTable dt = new DataTable();
dt = _remotingProxy.ExecuteSotreProcedure("Com_Pagination", parameters, ref values);
return dt;
}
}
#endregion 成员方法
}
}