车辆资产管理系统:检查用户姓名是否在库
2017-09-29 10:57:10 访问(1385) 赞(0) 踩(0)
-
/// <summary>
///
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
protected string ToName(string str)
{
if (str == null)
return "";
return str.Trim().Replace(" ", "");
}
/// <summary>
///
/// </summary>
/// <returns></returns>
protected List<string> UserNameListBuild()
{
List<string> theResult= new List<string>();
string str = txt_Input.Text.Trim();
string[] sAO = str.Split('\n');
string strOne = null;
string strTmp = null;
foreach (string sOne in sAO)
{
if (sOne == null)
continue;
strOne = sOne.Trim();
if (strOne.Length == 0)
continue;
string[] sA = strOne.Split('、');
foreach (string s in sA)
{
if (s == null)
continue;
strTmp = ToName(s.Trim());
if (strTmp.Length == 0)
continue;
strTmp = strTmp.Trim();
if (strTmp.EndsWith(";"))
{
strTmp = strTmp.Substring(0, strTmp.Length - (";").Length);
}
strTmp = strTmp.Trim();
if (strTmp.Length == 0)
continue;
theResult.Add(strTmp);
}
}
return theResult;
}
/// <summary>
///
/// </summary>
/// <param name="xdbHelper"></param>
/// <returns></returns>
protected string CheckInput(DBHelper xdbHelper)
{
List<string> userNameList = UserNameListBuild();
if(userNameList==null||userNameList.Count ==0)
return "";
int hadCount = 0;
int noHadCount = 0;
StringBuilder hadSb = new StringBuilder();
StringBuilder noHadSb = new StringBuilder();
bool bIsCreate = true;
if (xdbHelper == null)
{
xdbHelper
=
SlowX.DAL.Helpers.DBHelper.CreateDBHelper
(
DEFAULT_CONN,
SlowX.DAL.Enums.DataBaseHelper.EmDataBaseHelper.Oracle,
1
);
}
else
{
// 没有打开链接 //
bIsCreate = xdbHelper.IsNotOpen();
}
try
{
if (bIsCreate)
xdbHelper.OpenDBHelper();
eKing.EkVehicleLib.Business.CommonModule.User.BPMS_USER
bll
=
eKing.EkVehicleLib.Business.CommonModule.User.BPMS_USER.instance;
eKing.EkVehicleLib.Entity.CommonModule.User.BPMS_USER
entity
=
new eKing.EkVehicleLib.Entity.CommonModule.User.BPMS_USER();
List<BaseModel> theList = bll.ListBaseModel(entity, xdbHelper);
bool isFind = false;
foreach (string s in userNameList)
{
isFind = false;
foreach (eKing.EkVehicleLib.Model
.CommonModule.User.BPMS_USER model in theList)
{
if (model.RealName == null)
continue;
if (model.RealName.Trim() == s)
{
isFind = true;
break;
}
}
if (isFind)
{
++hadCount;
hadSb.AppendLine(s);
}
else
{
++noHadCount;
noHadSb.AppendLine(s);
}
}
if (bIsCreate)
xdbHelper.EndDBHelper();
}
catch (Exception err)
{
if (bIsCreate)
xdbHelper.TranDBHelper();
throw err;
}
finally
{
if (bIsCreate)
xdbHelper.FinallyDBHelper();
}
StringBuilder sb = new StringBuilder();
sb.AppendLine("未添加:" + noHadCount.ToString());
sb.AppendLine(noHadSb.ToString());
sb.AppendLine();
sb.AppendLine("添加:" + hadCount.ToString());
sb.AppendLine(hadSb.ToString());
sb.AppendLine();
txt_Result.Text = sb.ToString();
return "";
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btn_OK_Click(object sender, EventArgs e)
{
try
{
string str = CheckInput(null);
Response.Write(str);
}
catch (Exception err)
{
Response.Write(err.Message);
}
}
-
郑洁方、张 丽;
王晓龙;
周仁辉、黎海川;
符于锋、杨来权、赵雪松、王 磊、邢志雄、方 亮、胡洪君、范刘军、杨文杰、梁孝天、周逢春;
杨 辉;
刘雪峰;
上一条:
下一条:
相关评论
发表评论