zoukankan      html  css  js  c++  java
  • 判断属性的值是否为空

    private bool CheckCompanyDetail()
    {
    CompanyDetail companyDetail = CompanyDetailAdapter.Instance.LoadByCompanyArticleId(CurrentArticleId);
    Type type= companyDetail.GetType();
    PropertyInfo[] proes= type.GetProperties();
    foreach (var item in proes)
    {
    if (item.PropertyType.Name == "String")
    {
    object obj= item.GetValue(companyDetail,null);
    if (obj == null)
    {
    return false;
    }
    }
    if (item.PropertyType.Name == "Int32")
    {
    object obj = item.GetValue(companyDetail, null);
    if ((int)obj ==0 )
    {
    return false;
    }
    }
    if (item.PropertyType.Name == "Guid")
    {
    object obj = item.GetValue(companyDetail, null);
    if ((Guid)obj == Guid.Empty)
    {
    return false;
    }
    }
    if (item.PropertyType.Name == "Char")
    {
    object obj = item.GetValue(companyDetail, null);
    if ((char)obj == '')
    {
    return false;
    }
    }
    if (item.PropertyType.Name == "Decimal")
    {
    object obj = item.GetValue(companyDetail, null);
    if ((Decimal)obj == 0.00m)
    {
    return false;
    }
    }
    if (item.PropertyType.Name == "DateTime")
    {
    object obj = item.GetValue(companyDetail, null);
    if ((DateTime)obj == null)
    {
    return false;
    }
    }
    }
    return true;
    }

  • 相关阅读:
    javascript ext 闭包
    Hibernate HQL from superclass 问题
    sql查询按in顺序排序显示数据 oracle
    Hibernate createSQLquery()
    sql 分页
    javasript 闭包测试
    Excel 批量快速导入mySQL 解决方案~~
    C# 注册COM+组件步骤~
    QT错误集锦~
    QuartzNet Test~~
  • 原文地址:https://www.cnblogs.com/liushangxin/p/3604532.html
Copyright © 2011-2022 走看看