/// <summary> /// 主表按机身码查询 /// </summary> /// <param name="FuselageCode"></param> /// <param name="SQLCommand"></param> /// <returns></returns> public List <ProjectorInformation_MainTable_STR> selectProjectorInformation_MainTableDal(string FuselageCode, string ZhiDan, string OpticalCode, string MainBoardCode, string WiredMAC, string wirelessMAC, string SQLCommand) { StringBuilder sql = new StringBuilder(SQLhelp.GetSQLCommand(SQLCommand)); List <ProjectorInformation_MainTable_STR> list = new List <ProjectorInformation_MainTable_STR>(); List <SqlParameter> listsqlpar = new List <SqlParameter>(); List <string> wherelist = new List <string>(); if (FuselageCode.Length > 0) { wherelist.Add(" FuselageCode=@FuselageCode "); listsqlpar.Add(new SqlParameter("@FuselageCode", SqlDbType.VarChar, 80) { Value = FuselageCode }); } if (ZhiDan.Length > 0) { wherelist.Add(" ZhiDan=@ZhiDan "); listsqlpar.Add(new SqlParameter("@ZhiDan", SqlDbType.VarChar, 50) { Value = ZhiDan }); } if (OpticalCode.Length > 0) { wherelist.Add(" OpticalCode=@OpticalCode "); listsqlpar.Add(new SqlParameter("@OpticalCode", SqlDbType.VarChar, 80) { Value = OpticalCode }); } if (MainBoardCode.Length > 0) { wherelist.Add(" MainBoardCode=@MainBoardCode "); listsqlpar.Add(new SqlParameter("@MainBoardCode", SqlDbType.VarChar, 50) { Value = MainBoardCode }); } if (WiredMAC.Length > 0) { wherelist.Add(" WiredMAC=@WiredMAC "); listsqlpar.Add(new SqlParameter("@WiredMAC", SqlDbType.VarChar, 50) { Value = WiredMAC }); } if (wirelessMAC.Length > 0) { wherelist.Add(" wirelessMAC=@wirelessMAC "); listsqlpar.Add(new SqlParameter("@wirelessMAC", SqlDbType.VarChar, 50) { Value = wirelessMAC }); } if (wherelist.Count > 0) { sql.Append(" where "); sql.Append(string.Join(" and ", wherelist)); } try { if (listsqlpar.Count > 0) { using (SqlDataReader reader = SQLhelp.ExecuteReader(sql.ToString(), CommandType.Text, listsqlpar.ToArray())) { if (reader.HasRows) { while (reader.Read()) { list.Add(new ProjectorInformation_MainTable_STR() { FuselageCode = reader.GetString(0), OpticalCode = reader.IsDBNull(1) ? "" : reader.GetString(1), PolishingMachineTime = reader.IsDBNull(2) ? "" : reader.GetDateTime(2).ToString(), PreAgingTestTime = reader.IsDBNull(3) ? "" : reader.GetDateTime(3).ToString(), AgeingBeginTime = reader.IsDBNull(4) ? "" : reader.GetDateTime(4).ToString(), AgeingEndTime = reader.IsDBNull(5) ? "" : reader.GetDateTime(5).ToString(), PostAgingTestTime = reader.IsDBNull(6) ? "" : reader.GetDateTime(6).ToString(), PreAgingTestTime2 = reader.IsDBNull(7) ? "" : reader.GetDateTime(7).ToString(), PostAgingTestTime2 = reader.IsDBNull(8) ? "" : reader.GetDateTime(8).ToString(), IlluminationValue = reader.IsDBNull(9) ? "" : reader.GetString(9), WiredMAC = reader.IsDBNull(10) ? "" : reader.GetString(10), wirelessMAC = reader.IsDBNull(11) ? "" : reader.GetString(11), LuminanceTestTime = reader.IsDBNull(12) ? "" : reader.GetDateTime(12).ToString(), RepairText = reader.IsDBNull(13) ? "" : reader.GetString(13), RepairTime = reader.IsDBNull(14) ? "" : reader.GetDateTime(14).ToString(), PackingTime = reader.IsDBNull(15) ? "" : reader.GetDateTime(15).ToString(), MainBoardCode = reader.IsDBNull(16) ? "" : reader.GetString(16), MainBoardTime = reader.IsDBNull(17) ? "" : reader.GetDateTime(17).ToString(), ZhiDan = reader.IsDBNull(18) ? "" : reader.GetString(18), AfterMaintenanceOpticalCode = reader.IsDBNull(19)?"":reader.GetString(19), AfterMaintenanceMainBoardCode = reader.IsDBNull(20)?"":reader.GetString(20), LuminanceTestQTime = reader.IsDBNull(21) ? "" : reader.GetDateTime(21).ToString(), }); } } return(list); } } else { using (SqlDataReader reader = SQLhelp.ExecuteReader(sql.ToString(), CommandType.Text)) { if (reader.HasRows) { while (reader.Read()) { list.Add(new ProjectorInformation_MainTable_STR() { FuselageCode = reader.GetString(0), OpticalCode = reader.IsDBNull(1) ? "" : reader.GetString(1), PolishingMachineTime = reader.IsDBNull(2) ? "" : reader.GetDateTime(2).ToString(), PreAgingTestTime = reader.IsDBNull(3) ? "" : reader.GetDateTime(3).ToString(), AgeingBeginTime = reader.IsDBNull(4) ? "" : reader.GetDateTime(4).ToString(), AgeingEndTime = reader.IsDBNull(5) ? "" : reader.GetDateTime(5).ToString(), PostAgingTestTime = reader.IsDBNull(6) ? "" : reader.GetDateTime(6).ToString(), PreAgingTestTime2 = reader.IsDBNull(7) ? "" : reader.GetDateTime(7).ToString(), PostAgingTestTime2 = reader.IsDBNull(8) ? "" : reader.GetDateTime(8).ToString(), IlluminationValue = reader.IsDBNull(9) ? "" : reader.GetString(9), WiredMAC = reader.IsDBNull(10) ? "" : reader.GetString(10), wirelessMAC = reader.IsDBNull(11) ? "" : reader.GetString(11), LuminanceTestTime = reader.IsDBNull(12) ? "" : reader.GetDateTime(12).ToString(), RepairText = reader.IsDBNull(13) ? "" : reader.GetString(13), RepairTime = reader.IsDBNull(14) ? "" : reader.GetDateTime(14).ToString(), PackingTime = reader.IsDBNull(15) ? "" : reader.GetDateTime(15).ToString(), MainBoardCode = reader.IsDBNull(16) ? "" : reader.GetString(16), MainBoardTime = reader.IsDBNull(17) ? "" : reader.GetDateTime(17).ToString(), ZhiDan = reader.IsDBNull(18) ? "" : reader.GetString(18), AfterMaintenanceOpticalCode = reader.IsDBNull(19) ? "" : reader.GetString(19), AfterMaintenanceMainBoardCode = reader.IsDBNull(20) ? "" : reader.GetString(20), LuminanceTestQTime = reader.IsDBNull(21) ? "" : reader.GetDateTime(21).ToString(), }); } } return(list); } } } catch { throw; } }