SVN r349
SVN-Revision: r349
This commit is contained in:
@@ -68,6 +68,15 @@ namespace Lskj.PubSpecialImport
|
||||
InitGridColumns();
|
||||
InitMulitControl();
|
||||
InitDataSource();
|
||||
if (Model.ShowType.Equals("1") && !ERPInfo.Instance.UserName.Equals("管理员"))
|
||||
{
|
||||
pl_cond.Visible = false;
|
||||
pl_purview.Visible = false;
|
||||
tips.Visible = false;
|
||||
splitMainContainer.PanelVisibility = DevExpress.XtraEditors.SplitPanelVisibility.Panel2;
|
||||
btnOk.Visible = false;
|
||||
btnCancel.Visible = false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -181,6 +190,18 @@ namespace Lskj.PubSpecialImport
|
||||
DataTable sourceTable = this.gcMain.GridControl.DataSource as DataTable;
|
||||
if (dataTable != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Model.ReadTableCond))
|
||||
{
|
||||
DataView view = new DataView(dataTable);
|
||||
view.RowFilter = Model.ReadTableCond;
|
||||
dataTable = view.ToTable();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
this.gc_Right.SetGridViewDataSource(dataTable);
|
||||
}
|
||||
if (sourceTable != null && sourceTable.Rows.Count > 0)
|
||||
@@ -458,6 +479,14 @@ namespace Lskj.PubSpecialImport
|
||||
DataTable sourceTable = GetSourceTable(unionColumnList);
|
||||
this.gcMain.GridControl.DataSource = sourceTable;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ERPInfo.Instance.UserName.Equals("管理员"))
|
||||
{
|
||||
MessageUtil.Show("未获取到配置数据\r\n请联系管理员配置数据");
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -584,11 +613,11 @@ namespace Lskj.PubSpecialImport
|
||||
string fieldName = "";
|
||||
if (!isBandTitle || bandRow == null)
|
||||
{
|
||||
fieldName = titleCell.StringCellValue;
|
||||
fieldName = GetCellValue(titleCell);
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldName = $"{titleCell.StringCellValue}|{bandCell.StringCellValue}";
|
||||
fieldName = $"{GetCellValue(titleCell)}|{GetCellValue(bandCell)}";
|
||||
}
|
||||
if (string.IsNullOrEmpty(fieldName) && titleCell.IsMergedCell)
|
||||
{
|
||||
@@ -613,7 +642,7 @@ namespace Lskj.PubSpecialImport
|
||||
{
|
||||
if (row.GetCell(j) != null) //同理,没有数据的单元格都默认是null
|
||||
{
|
||||
dataRow[j - firstRow.FirstCellNum] = row.GetCell(j).ToString();
|
||||
dataRow[j - firstRow.FirstCellNum] = GetCellValue(row.GetCell(j));
|
||||
}
|
||||
}
|
||||
data.Rows.Add(dataRow);
|
||||
@@ -663,7 +692,7 @@ namespace Lskj.PubSpecialImport
|
||||
if (sheet != null)
|
||||
{
|
||||
IRow firstRow = sheet.GetRow(rowIndex);
|
||||
value = firstRow.GetCell(colIndex).ToString();
|
||||
value = GetCellValue(firstRow.GetCell(colIndex));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -817,7 +846,7 @@ namespace Lskj.PubSpecialImport
|
||||
startRow = mergrRange.LastRow + 1;
|
||||
if (mergrRange != null)
|
||||
{
|
||||
if (mergrRange.FirstColumn < mergrRange.LastColumn)
|
||||
if (mergrRange.FirstColumn < mergrRange.LastColumn && !Model.CustomerServiceApp)
|
||||
{
|
||||
isBandTitle = true;
|
||||
bandRow = sheet.GetRow(mergrRange.LastRow + 1);
|
||||
@@ -833,16 +862,20 @@ namespace Lskj.PubSpecialImport
|
||||
startRow = mergrRange.LastRow + 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
startRow = mergrRange.LastRow + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
string headerName = "";
|
||||
if (!isBandTitle || bandRow == null)
|
||||
{
|
||||
headerName = titleCell.StringCellValue;
|
||||
headerName = GetCellValue(titleCell);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(bandCell.StringCellValue))
|
||||
else if (!string.IsNullOrEmpty(GetCellValue(bandCell)))
|
||||
{
|
||||
headerName = $"{titleCell.StringCellValue}|{bandCell.StringCellValue}";
|
||||
headerName = $"{GetCellValue(titleCell)}|{GetCellValue(bandCell)}";
|
||||
}
|
||||
if (string.IsNullOrEmpty(headerName))
|
||||
{
|
||||
@@ -901,7 +934,7 @@ namespace Lskj.PubSpecialImport
|
||||
startRow = mergrRange.LastRow + 1;
|
||||
if (mergrRange != null)
|
||||
{
|
||||
if (mergrRange.FirstColumn < mergrRange.LastColumn)
|
||||
if (mergrRange.FirstColumn < mergrRange.LastColumn && !Model.CustomerServiceApp)
|
||||
{
|
||||
isBandTitle = true;
|
||||
bandRow = sheet.GetRow(mergrRange.LastRow + 1);
|
||||
@@ -917,15 +950,19 @@ namespace Lskj.PubSpecialImport
|
||||
startRow = mergrRange.LastRow + 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
startRow = mergrRange.LastRow + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isBandTitle || bandRow == null)
|
||||
{
|
||||
columnName = titleCell.StringCellValue;
|
||||
columnName = GetCellValue(titleCell);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(bandCell.StringCellValue))
|
||||
else if (!string.IsNullOrEmpty(GetCellValue(bandCell)))
|
||||
{
|
||||
columnName = $"{titleCell.StringCellValue}|{bandCell.StringCellValue}";
|
||||
columnName = $"{GetCellValue(titleCell)}|{GetCellValue(bandCell)}";
|
||||
}
|
||||
if (string.IsNullOrEmpty(columnName))
|
||||
{
|
||||
@@ -1018,9 +1055,9 @@ namespace Lskj.PubSpecialImport
|
||||
bool isEmpty = model.CanNull;
|
||||
string fieldValue = GetValueByImportText(dataRow, col.FieldName, cell + "", isBillImport);
|
||||
if ((model.FieldType == ControlType.LabMultiSelectValue ||
|
||||
model.FieldType == ControlType.LabMultiSelectValueParam) && cell.ToString().Contains(","))
|
||||
model.FieldType == ControlType.LabMultiSelectValueParam) && GetCellValue(cell).Contains(","))
|
||||
{
|
||||
string[] cellText = cell.ToString().Split(',');
|
||||
string[] cellText = GetCellValue(cell).Split(',');
|
||||
foreach (string cellValue in cellText)
|
||||
{
|
||||
fieldValue += GetValueByImportText(dataRow, col.FieldName, cellValue, isBillImport) + ',';
|
||||
@@ -1104,7 +1141,7 @@ namespace Lskj.PubSpecialImport
|
||||
}
|
||||
cell.SetCellValue(cellValue);
|
||||
}
|
||||
dataRow[col.FieldName] = cell.ToString();
|
||||
dataRow[col.FieldName] = GetCellValue(cell);
|
||||
if (AutoImportCal)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(model.UnionFields))
|
||||
@@ -1462,4 +1499,62 @@ namespace Lskj.PubSpecialImport
|
||||
}
|
||||
else
|
||||
{
|
||||
result = Repl
|
||||
result = ReplaceHelper.ReplaceRowParamCond(dataRow, cond);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取合并区域
|
||||
/// </summary>
|
||||
/// <param name="sheet"></param>
|
||||
/// <param name="rowIndex"></param>
|
||||
/// <param name="columnIndex"></param>
|
||||
/// <returns></returns>
|
||||
private CellRangeAddress FindMergedRegion(ISheet sheet, int rowIndex, int columnIndex)
|
||||
{
|
||||
int mergedRegionsCount = sheet.NumMergedRegions;
|
||||
|
||||
for (int i = 0; i < mergedRegionsCount; i++)
|
||||
{
|
||||
CellRangeAddress mergedRegion = sheet.GetMergedRegion(i);
|
||||
if (mergedRegion.IsInRange(rowIndex, columnIndex))
|
||||
{
|
||||
return mergedRegion; // 返回合并区域
|
||||
}
|
||||
}
|
||||
return null; // 未找到合并区域
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取单元格值
|
||||
/// </summary>
|
||||
/// <param name="cell"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetCellValue(ICell cell)
|
||||
{
|
||||
string cellValue = "";
|
||||
try
|
||||
{
|
||||
if (cell != null)
|
||||
{
|
||||
// 根据单元格类型获取值
|
||||
switch (cell.CellType)
|
||||
{
|
||||
case CellType.String:
|
||||
cellValue = cell.StringCellValue;
|
||||
break;
|
||||
case CellType.Numeric:
|
||||
cellValue = cell.NumericCellValue.ToString();
|
||||
break;
|
||||
case CellType.Boolean:
|
||||
cellValue = cell.BooleanCellValue.ToString();
|
||||
break;
|
||||
case CellType.Formula://单元格中带有公式,根据类型继续判断
|
||||
switch (cell.CachedFormulaResultType)
|
||||
{
|
||||
case CellType.String:
|
||||
cellValue = cell.StringCellValue;
|
||||
|
||||
Reference in New Issue
Block a user