89 lines
2.6 KiB
C#
89 lines
2.6 KiB
C#
using System.Data;
|
||
using WX.CRM.Common;
|
||
using WX.CRM.Model.Enum;
|
||
|
||
namespace WX.CRM.WebHelper.ExcelImport.QH
|
||
{
|
||
public class Qh_TransactionDetailUploadTool : ComUploadTool
|
||
{
|
||
#region method
|
||
public override EnumExcelDataType ExcelDataType { get { return EnumExcelDataType.Qh_TransactionDetail; } }
|
||
#endregion
|
||
|
||
#region 继承函数
|
||
|
||
/// <summary>
|
||
/// 获取错误的datable数据(续子类重写)
|
||
/// </summary>
|
||
/// <param name="tab">错误数据的Datatable,如果没有(Datatable.Count=0 和message="" 和 errMsg.Count==0)=>数据验证通过</param>
|
||
/// <param name="message">自定义的提示信息</param>
|
||
/// <param name="errMsg">报错信息</param>
|
||
/// <returns></returns>
|
||
protected override DataTable CheckErroDataTable(DataTable tab, out string message, ref ValidationErrors errMsg)
|
||
{
|
||
DataTable errTab = tab.Clone();
|
||
message = string.Empty;
|
||
//营业部样本验证
|
||
if (!DeptTradeCodeCheck(ref message, tab))
|
||
{
|
||
return null;
|
||
}
|
||
|
||
// 行验证
|
||
foreach (DataRow row in tab.Rows)
|
||
{
|
||
if (!CheckCellData(ref errMsg, row))
|
||
{
|
||
errTab.ImportRow(row);
|
||
}
|
||
}
|
||
return errTab;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 其他处理函数
|
||
|
||
/// <summary>
|
||
/// 验证 这条数据是否符合条件
|
||
/// </summary>
|
||
/// <param name="errMsg">错误信息</param>
|
||
/// <param name="row">行数据</param>
|
||
/// <returns></returns>
|
||
protected bool CheckCellData(ref ValidationErrors errMsg, DataRow row)
|
||
{
|
||
bool result = true;
|
||
//if (row["TRADECODE"].ToString() == "")
|
||
//{
|
||
// result = false;
|
||
//}
|
||
return result;
|
||
}
|
||
/// <summary>
|
||
/// 获取交易商代码
|
||
/// </summary>
|
||
/// <param name="tracode">交易商代码</param>
|
||
/// <returns></returns>
|
||
private string GetTradcode(string tracode)
|
||
{
|
||
string obj = "";
|
||
string temp = tracode;
|
||
if (temp.Length < 8 || temp.Length > 9)
|
||
obj = "";
|
||
else if (temp.Length == 9)
|
||
{
|
||
obj = temp;
|
||
}
|
||
else if (temp.Length == 8)
|
||
{
|
||
if (temp.IndexOf("45") == 0)
|
||
obj = "0" + temp;
|
||
else
|
||
obj = "";
|
||
}
|
||
return obj;
|
||
}
|
||
#endregion
|
||
}
|
||
}
|