|
|
using System;
|
|
|
using System.Data;
|
|
|
using System.Text;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data.SqlClient;
|
|
|
using ApServerProvider;
|
|
|
using DbCommon;
|
|
|
using System.Collections;
|
|
|
|
|
|
namespace Estsh.Core.Repositories
|
|
|
{
|
|
|
|
|
|
/**
|
|
|
* 关键数据管理
|
|
|
*
|
|
|
* NOAH
|
|
|
*
|
|
|
*/
|
|
|
public class PrintVendorDefineDal : BaseApp
|
|
|
{
|
|
|
public PrintVendorDefineDal(RemotingProxy remotingProxy)
|
|
|
: base(remotingProxy)
|
|
|
{
|
|
|
}
|
|
|
#region 成员方法
|
|
|
/// <summary>
|
|
|
/// 获得菜单列表数据
|
|
|
/// </summary>
|
|
|
public DataTable getList(string strWhere,string filedOrder)
|
|
|
{
|
|
|
lock (_remotingProxy)
|
|
|
{
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append("select * from g_workorder_print_vendor ");
|
|
|
if (!strWhere.Trim().Equals(""))
|
|
|
{
|
|
|
strSql.Append(" where " + strWhere);
|
|
|
}
|
|
|
if (filedOrder != null && !filedOrder.Trim().Equals(""))
|
|
|
{
|
|
|
strSql.Append(" order by " + filedOrder);
|
|
|
}
|
|
|
return this._remotingProxy.GetDataTable(strSql.ToString());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取分页数据列表
|
|
|
/// </summary>
|
|
|
public DataTable getListByPage(int PageSize, int PageIndex, string strWhere, string OrderBy)
|
|
|
{
|
|
|
lock (_remotingProxy)
|
|
|
{
|
|
|
if (strWhere.Trim() != "")
|
|
|
{
|
|
|
strWhere = strWhere.Remove(0, 6);//因为存储过程中已经有where,这里需要把之前加入的where去掉,这里截除前六个字符
|
|
|
}
|
|
|
if (OrderBy.Trim() != "")
|
|
|
{
|
|
|
OrderBy = " a.group_id"; //排序
|
|
|
}
|
|
|
Hashtable Params = new Hashtable(6);
|
|
|
|
|
|
Params.Add("@TotalCount", 100);
|
|
|
Params.Add("@TotalPage", 100);
|
|
|
Params.Add("@GroupColumn", "");
|
|
|
Params.Add("@Table", " dbo.g_workorder_print_vendor a LEFT JOIN dbo.sys_part b ON b.part_no = a.part_no LEFT JOIN dbo.sys_emp d ON a.update_userid = d.emp_id");
|
|
|
Params.Add("@Column", " a.ruid,a.part_no , b.part_spec , a.group_id ,a.vendor_id, CASE a.vendor_id WHEN '106044' THEN '古汉' WHEN '111847' THEN '金远东' WHEN '112808' THEN '丰海' WHEN '113664' THEN '宏原' WHEN '113732' THEN '天龙' WHEN '113738' THEN '航嘉' ELSE '' END AS vendor_name , a.enabled ,d.emp_name , a.update_ymd ,a.update_hms ,a.create_ymd ,a.create_hms");
|
|
|
Params.Add("@PageSize", PageSize);
|
|
|
Params.Add("@CurrentPage", PageIndex);
|
|
|
Params.Add("@Condition", strWhere);
|
|
|
Params.Add("@OrderColumn", OrderBy);
|
|
|
Params.Add("@Group", 0);
|
|
|
|
|
|
String strProcedure = "EXEC Com_Pagination @TotalCount, @TotalPage, @Table, @Column,@OrderColumn,@GroupColumn,@PageSize, @CurrentPage,@Group,@Condition";
|
|
|
return _remotingProxy.GetDataTable(strProcedure, Params);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取分页记录总数
|
|
|
/// </summary>
|
|
|
public int getCountWhere(string strWhere)
|
|
|
{
|
|
|
lock (_remotingProxy)
|
|
|
{
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
strSql.Append(" SELECT COUNT(*) as Total FROM ( select a.ruid,a.part_no , b.part_spec , a.group_id , CASE a.vendor_id WHEN '106044' THEN '古汉' WHEN '111847' THEN '金远东' WHEN '112808' THEN '丰海' WHEN '113664' THEN '宏原' WHEN '113732' THEN '天龙' WHEN '113738' THEN '航嘉' ELSE '' END AS vendor_name , a.enabled ,d.emp_name , a.update_ymd ,a.update_hms ,a.create_ymd ,a.create_hms as Total FROM dbo.g_workorder_print_vendor a LEFT JOIN dbo.sys_part b ON b.part_no = a.part_no LEFT JOIN dbo.sys_emp d ON a.update_userid = d.emp_id ");
|
|
|
|
|
|
|
|
|
if (strWhere.Trim() != "")
|
|
|
{
|
|
|
strSql.Append(" " + strWhere);
|
|
|
}
|
|
|
|
|
|
strSql.Append(" ) AS abc ");
|
|
|
int i = 0;
|
|
|
DataTable dt = _remotingProxy.GetDataTable(strSql.ToString());
|
|
|
if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
if (dt.Rows[0]["Total"].ToString() != "")
|
|
|
{
|
|
|
i = int.Parse(dt.Rows[0]["Total"].ToString());
|
|
|
}
|
|
|
}
|
|
|
return i;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 插入菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int savePrintVendor(Hashtable htParams)
|
|
|
{
|
|
|
lock (_remotingProxy)
|
|
|
{
|
|
|
StringBuilder SqlStringBuilder = new StringBuilder(1024);
|
|
|
SqlStringBuilder.Append("INSERT INTO dbo.g_workorder_print_vendor( vendor_id ,group_id ,part_no ,enabled ,create_userid ,create_ymd ,create_hms ) ");
|
|
|
SqlStringBuilder.Append(" VALUES ( @vendor_id , @group_id , @part_no , @enable , @create_userid ,dbo.get_ymd() ,dbo.get_hms() ) ");
|
|
|
|
|
|
return _remotingProxy.ExecuteNonQuery(SqlStringBuilder.ToString(), htParams);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int updatePrintVendor(Hashtable htParams)
|
|
|
{
|
|
|
lock (_remotingProxy)
|
|
|
{
|
|
|
StringBuilder SqlStringBuilder = new StringBuilder(1024);
|
|
|
SqlStringBuilder.Append(" UPDATE g_workorder_print_vendor SET ");
|
|
|
SqlStringBuilder.Append(" part_no = @part_no ,vendor_id =@vendor_id ,group_id = @group_id ,enabled = @enable ,update_userid = @update_userid ,update_ymd = dbo.get_ymd() ,update_hms = dbo.get_hms() ");
|
|
|
SqlStringBuilder.Append(" WHERE ruid = @ruid ");
|
|
|
|
|
|
return _remotingProxy.ExecuteNonQuery(SqlStringBuilder.ToString(), htParams);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="keydata_id"></param>
|
|
|
/// <returns></returns>
|
|
|
public int deletePrintVendor(String ruid)
|
|
|
{
|
|
|
lock (_remotingProxy)
|
|
|
{
|
|
|
String delStr = "DELETE FROM g_workorder_print_vendor WHERE ruid = @ruid";
|
|
|
Hashtable htparams = new Hashtable();
|
|
|
htparams.Add("@ruid", ruid);
|
|
|
return _remotingProxy.ExecuteNonQuery(delStr, htparams);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endregion 成员方法
|
|
|
|
|
|
/// <summary>
|
|
|
/// 判断用户输入的零件号是否存在
|
|
|
/// BY NOAH
|
|
|
/// </summary>
|
|
|
/// <param name="part_no"></param>
|
|
|
/// <returns></returns>
|
|
|
public bool isExsitPart_no(String part_no)
|
|
|
{
|
|
|
lock (_remotingProxy)
|
|
|
{
|
|
|
|
|
|
string SqlString = "select top 1 part_id from sys_part where enabled='Y' and part_no=@part_no";
|
|
|
Hashtable Params = new Hashtable(1);
|
|
|
Params.Add("@part_no", part_no);
|
|
|
DataTable dt = _remotingProxy.GetDataTable(SqlString, Params);
|
|
|
if (dt.Rows.Count >= 1)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查询是否已存在该零件号对应关系
|
|
|
/// </summary>
|
|
|
/// <param name="part_no"></param>
|
|
|
/// <returns></returns>
|
|
|
public bool isExsitVendor(String part_no)
|
|
|
{
|
|
|
lock (_remotingProxy)
|
|
|
{
|
|
|
|
|
|
string SqlString = "select top 1 part_no from g_workorder_print_vendor where part_no=@part_no";
|
|
|
Hashtable Params = new Hashtable(1);
|
|
|
Params.Add("@part_no", part_no);
|
|
|
DataTable dt = _remotingProxy.GetDataTable(SqlString, Params);
|
|
|
if (dt.Rows.Count >= 1)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 导入数据方法
|
|
|
/// </summary>
|
|
|
/// <param name="dt">需要导入的数据表</param>
|
|
|
/// <returns>true or false</returns>
|
|
|
public bool InsertData(DataTable dt)
|
|
|
{
|
|
|
lock (_remotingProxy)
|
|
|
{
|
|
|
List<String> SqlStrings = new List<string>(dt.Rows.Count);
|
|
|
|
|
|
List<String> VendorCache = new List<string>(dt.Rows.Count);
|
|
|
|
|
|
List<Hashtable> hs = new List<Hashtable>(dt.Rows.Count);
|
|
|
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
{
|
|
|
string VendorCacheName = dt.Rows[i][0].ToString();
|
|
|
|
|
|
// 跳过空行
|
|
|
if (string.IsNullOrEmpty(VendorCacheName.Trim()))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
// 跳过重复的行
|
|
|
if (VendorCache.Contains(VendorCacheName))
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
VendorCache.Add(dt.Rows[i][1].ToString());
|
|
|
}
|
|
|
|
|
|
StringBuilder SqlStringBuilder = new StringBuilder(1024);
|
|
|
|
|
|
|
|
|
SqlStringBuilder.Append("insert into g_workorder_print_vendor(vendor_id,group_id,part_no,enabled,create_userid,create_ymd,create_hms");
|
|
|
SqlStringBuilder.Append(" ) values( ");
|
|
|
SqlStringBuilder.Append("@vendor_id,@group_id,@part_no, ");
|
|
|
SqlStringBuilder.Append("@enabled,@create_userid,dbo.get_ymd(),dbo.get_hms() )");
|
|
|
|
|
|
|
|
|
Hashtable values = new Hashtable(5);
|
|
|
|
|
|
values.Add("@create_userid", _remotingProxy.UserID);
|
|
|
values.Add("@part_no", dt.Rows[i][0].ToString());
|
|
|
values.Add("@vendor_id", dt.Rows[i][1].ToString());
|
|
|
values.Add("@group_id", dt.Rows[i][2].ToString());
|
|
|
values.Add("@enabled", dt.Rows[i][3].ToString());
|
|
|
|
|
|
|
|
|
SqlStrings.Add(SqlStringBuilder.ToString());
|
|
|
|
|
|
hs.Add(values);
|
|
|
}
|
|
|
|
|
|
return _remotingProxy.ExecuteSqlTransaction(SqlStrings, hs);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|