如何为下面的代码实现if条件。
Hi Team,
我的代码正在运行。在我的代码中,如果条件可用,我想在条件退出时再实现一个If条件。我的条件如下:
我正在读取excel表中的值。在excel中有行数和列数。我有CellId,route,place,mobilenumber ..等等作为我的excel文件中的列名。
例如:在Cellid列中,值为123,其他列具有与某一行的特定记录相关的某些值
for第二行,在CellID列中,值为123,但其他列为null。所以在此senario中,我想检查记录是否存在相同数量的cellid exsist然后读取列中存在值的记录,而不是读取值中的值哪个cellid存在但其他列为null。我如何在if条件下实现这一点。请指导我。
Hi Team,
I have the code which is working.In my code there are if condition is available ,I want to implement one more If condition in exiting if condition.My Condition is as follows:
I am reading the values from excel sheet .In excel there are number of rows and columns.I have CellId,route ,place,mobilenumber ..and so on as a column name in my excel file.
for example: In Cellid column, value are 123 ,other columns are having some value related to particular record for one row
for second row,In CellID column,value are 123 but other column are null.So in this senario,I want to check the record if same number of cellid exsist then read the record in which value are present in columns not to read the value in which cellid is present but other columns are null. How can i implement this in if condition.Please guide me.
public IEntityCollectionBase GetZteBbhRecords(IEntityBase xmlConfiguration)
{
IDataReader dataReader = null;
ExcelDataAccess excelDataAccess = null;
IEntityCollectionBase zteBbhRecords = Kaizen2GEntityCreator.GetZteBbhEntityCollection();
try
{
IXmlConfiguration xmlConfig = xmlConfiguration as IXmlConfiguration;
Logger.Write("Inside ZteBbhDataManager.GetZteBbhRecords()", xmlConfig.LogTypeInfo);
excelDataAccess = CommonDataManager.GetDataAccess(xmlConfig);
dataReader = excelDataAccess.ExecuteReader();
IZteBbh zteBbhEntity = null;
while (dataReader.Read())
{
zteBbhEntity = Kaizen2GEntityCreator.GetZteBbhEntity();
zteBbhEntity = CommonDataManager.GetEntityFromExcelRow(dataReader, xmlConfig, zteBbhEntity) as IZteBbh;
if (zteBbhEntity != null)
{
if ((zteBbhEntity.CombinedMaster as ICombinedMaster).CellId > 0)
{
if ((zteBbhEntity.CombinedMaster as ICombinedMaster).Circle.Trim().ToUpper() == "ROTN")
{
(zteBbhEntity.CombinedMaster as ICombinedMaster).Circle = "ROTN-ZTE";
}
else if ((zteBbhEntity.CombinedMaster as ICombinedMaster).Circle.Trim().ToUpper() == "AP")
{
(zteBbhEntity.CombinedMaster as ICombinedMaster).Circle = "AP-ZTE";
}
zteBbhEntity.FileLogId = xmlConfig.FileLogId;
zteBbhEntity.HandOverSuccessRate = zteBbhEntity.HandOverSuccessRate * 100;
zteBbhEntity.HandOverFailureRate = zteBbhEntity.HandOverFailureRate * 100;
zteBbhEntity.RandomAccessSuccessRate = zteBbhEntity.RandomAccessSuccessRate * 100;
zteBbhEntity.TbfSuccessRateUl = zteBbhEntity.TbfSuccessRateUl * 100;
zteBbhEntity.TbfSuccessRateDl = zteBbhEntity.TbfSuccessRateDl * 100;
zteBbhRecords.Add(zteBbhEntity);
}
}
}
Logger.Write("Exiting ZteBbhDataManager.GetZteBbhRecords()", xmlConfig.LogTypeInfo);
}
catch (Exception exception)
{
throw exception;
}
finally
{
dataReader.CloseDataReader();
excelDataAccess.CloseConnection();
}
return zteBbhRecords;
}
缩小缩小
indenting reduced
我建议使用ADO.NET(OLEDB),它允许使用SQL查询来插入,更新和删除Excel数据。看看这里:从.NET应用程序访问Microsoft Office数据 [ ^ ]。
I'd suggest to use ADO.NET (OLEDB), which enables to use SQL queries to insert, update and delete Excel data. Have a look here: Accessing Microsoft Office Data from .NET Applications[^].
也许值得你先了解一下这种简单的布尔逻辑!
对不起......预期会有挫折!
问候,布鲁诺
Maybe it is worth that you first get some knowledge about such simple boolean logics!
Sorry for that.....Downvotes expected!
Regards, Bruno