public void QueryRecordTest() { // string ConnectionString = string.Empty; // TODO: 初始化为适当的值 DBLendingInfo target = new DBLendingInfo(connstr); // TODO: 初始化为适当的值 GoodsQueryParam GoodsQueryParamact = null; // TODO: 初始化为适当的值 //定义参数 GoodsQueryParamact = new GoodsQueryParam(); GoodsQueryParamact.nLendingNumber = -1; GoodsQueryParamact.nLendingType = 0; GoodsQueryParamact.nReturnState = 0; GoodsQueryParamact.strTrainmanName = "张勇"; GoodsQueryParamact.strTrainmanNumber = "2300679"; GoodsQueryParamact.strWorkShopGUID = "3b50bf66-dabb-48c0-8b6d-05db80591090"; GoodsQueryParamact.dtBeginTime = DateTime.Today.AddDays(-30); GoodsQueryParamact.dtEndTime = DateTime.Today; List <LendingInfo> expected = null; // TODO: 初始化为适当的值 List <LendingInfo> actual; actual = target.QueryRecord(GoodsQueryParamact); Assert.IsNotNull(actual); //Assert.AreEqual(expected, actual); // Assert.Inconclusive("验证此测试方法的正确性。"); }
public List <LendingInfo> QueryRecord(GoodsQueryParam GoodsQueryParam) { string strSqlWhere = " where 1=1 "; if (GoodsQueryParam.dtBeginTime != null && GoodsQueryParam.dtEndTime != null) { strSqlWhere += " and dtBorrowTime>='" + GoodsQueryParam.dtBeginTime + "' and dtBorrowTime<='" + GoodsQueryParam.dtEndTime + "'"; } if (GoodsQueryParam.nReturnState > -1) { strSqlWhere += " and (nReturnState = " + GoodsQueryParam.nReturnState + ") "; } if (GoodsQueryParam.nLendingType > -1) { strSqlWhere += " and (" + GoodsQueryParam.nLendingType + " in (select nLendingType from TAB_LendingDetail where strLendingInfoGUID = View_LendingInfo.strGUID) )"; } if (GoodsQueryParam.strTrainmanNumber != null && GoodsQueryParam.strTrainmanNumber.ToString() != "") { strSqlWhere += " and (strBorrowTrainmanNumber = '" + GoodsQueryParam.strTrainmanNumber + "') "; } if (GoodsQueryParam.strTrainmanName != null && GoodsQueryParam.strTrainmanName.ToString() != "") { strSqlWhere += " and (strBorrowTrainmanName = '" + GoodsQueryParam.strTrainmanName + "') "; } if (GoodsQueryParam.strWorkShopGUID != null && GoodsQueryParam.strWorkShopGUID.ToString() != "") { strSqlWhere += " and (strWorkShopGUID = '" + GoodsQueryParam.strWorkShopGUID + "') "; } if (GoodsQueryParam.nLendingNumber > -1) { strSqlWhere += " and (strGUID in (select strLendingInfoGUID from TAB_LendingDetail where strLendingExInfo = " + GoodsQueryParam.nLendingNumber + ") ) "; } string strSql = "Select * from View_LendingInfo " + strSqlWhere + " order by dtBorrowTime desc"; return(QueryRecord_DTToList(SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, strSql.ToString()).Tables[0])); }