using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Data; using System.Data.SqlClient; using System.Reflection; using MESClassLibrary.BLL.Log; namespace MESClassLibrary.DAL.BasicInfo { public class PlasticDAL { public DataTable SearchInfo(string partNo,string stationID) { try { string sql = @"select * from [tb_Plastic] where [PartNo]=@partNo and StationID=@StationID"; SqlParameter[] param = new SqlParameter[2]; param[0] = new SqlParameter("@partNo", SqlDbType.VarChar); param[0].Value = partNo; param[1] = new SqlParameter("@StationID", SqlDbType.VarChar); param[1].Value = stationID; return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0]; } catch (Exception ex) { LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); return null; } } public DataTable SearchAllInfo(string stationID) { try { string sql = @"select * from [tb_Plastic] where StationID=@StationID"; SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@StationID", SqlDbType.VarChar); param[0].Value = stationID; return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0]; } catch (Exception ex) { LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); return null; } } public DataTable SearchPartByStation(string stationNo) { try { string sql = @"SELECT dbo.tb_Station.StationNo, dbo.tb_Product.ProductName, dbo.tb_Plastic.PartNo, dbo.tb_Product.StockNo FROM dbo.tb_Plastic INNER JOIN dbo.tb_Product ON dbo.tb_Plastic.PartNo = dbo.tb_Product.PartNo LEFT OUTER JOIN dbo.tb_Station ON dbo.tb_Plastic.StationID = dbo.tb_Station.StationID where dbo.tb_Station.StationNo=@StationNo ORDER BY SUBSTRING(ProductName,0,4)"; SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@StationNo", SqlDbType.VarChar); param[0].Value = stationNo; return SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, param).Tables[0]; } catch (Exception ex) { LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod()); return null; } } } }