年龄处理
This commit is contained in:
parent
8c5c602487
commit
f132593c5b
|
|
@ -115,9 +115,9 @@
|
||||||
FieldType="String" HeaderText="姓名" HeaderTextAlign="Center"
|
FieldType="String" HeaderText="姓名" HeaderTextAlign="Center"
|
||||||
TextAlign="Center">
|
TextAlign="Center">
|
||||||
</f:RenderField>
|
</f:RenderField>
|
||||||
<f:TemplateField ColumnID="tfAge" Width="80px" HeaderText="年龄" HeaderTextAlign="Center" TextAlign="Left">
|
<f:TemplateField ColumnID="tfAge" Width="80px" HeaderText="年龄" HeaderTextAlign="Center" TextAlign="Center">
|
||||||
<ItemTemplate>
|
<ItemTemplate>
|
||||||
<asp:Label ID="lblAge" runat="server" Text='<%# ConvertAge(Eval("Birthday")) %>'></asp:Label>
|
<asp:Label ID="lblAge" runat="server" Text='<%# ConvertAge(Eval("IdentityCard")) %>'></asp:Label>
|
||||||
</ItemTemplate>
|
</ItemTemplate>
|
||||||
</f:TemplateField>
|
</f:TemplateField>
|
||||||
<%-- <f:RenderField HeaderText="卡号" ColumnID="CardNo" DataField="CardNo" SortField="CardNo"
|
<%-- <f:RenderField HeaderText="卡号" ColumnID="CardNo" DataField="CardNo" SortField="CardNo"
|
||||||
|
|
|
||||||
|
|
@ -303,11 +303,34 @@ namespace FineUIPro.Web.HSSE.SitePerson
|
||||||
{
|
{
|
||||||
string personId = Grid1.Rows[i].DataKeys[0].ToString();
|
string personId = Grid1.Rows[i].DataKeys[0].ToString();
|
||||||
var person = BLL.PersonService.GetPersonById(personId);
|
var person = BLL.PersonService.GetPersonById(personId);
|
||||||
|
var idCard = person.IdentityCard;
|
||||||
|
//根据身份证号码获取出生日期
|
||||||
|
if (!string.IsNullOrEmpty(idCard))
|
||||||
|
{
|
||||||
|
string birthDateStr = "";
|
||||||
|
if (idCard.Length == 18)
|
||||||
|
{
|
||||||
|
// 18位身份证号码,出生日期在第7位到第14位
|
||||||
|
birthDateStr = idCard.Substring(6, 8);
|
||||||
|
}
|
||||||
|
else if (idCard.Length == 15)
|
||||||
|
{
|
||||||
|
// 15位身份证号码,出生日期在第7位到第12位,需要加上"19"前缀
|
||||||
|
birthDateStr = "19" + idCard.Substring(6, 6);
|
||||||
|
}
|
||||||
|
|
||||||
if (person.IsUsedType=="2") //待审批
|
// 解析日期字符串为DateTime对象
|
||||||
|
var birthDate = DateTime.ParseExact(birthDateStr, "yyyyMMdd", null);
|
||||||
|
if (birthDate.AddYears(60) < DateTime.Now)
|
||||||
{
|
{
|
||||||
Grid1.Rows[i].RowCssClass = "Yellow";
|
Grid1.Rows[i].RowCssClass = "Yellow";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// if (person.IsUsedType=="2") //待审批
|
||||||
|
// {
|
||||||
|
// Grid1.Rows[i].RowCssClass = "Yellow";
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -792,10 +815,22 @@ namespace FineUIPro.Web.HSSE.SitePerson
|
||||||
string age = string.Empty;
|
string age = string.Empty;
|
||||||
if (rirthday != null)
|
if (rirthday != null)
|
||||||
{
|
{
|
||||||
DateTime? bDate = Funs.GetNewDateTime(rirthday.ToString());
|
var idCard = rirthday.ToString();
|
||||||
if (bDate.HasValue)
|
string birthDateStr = "";
|
||||||
|
if (idCard.Length == 18)
|
||||||
{
|
{
|
||||||
age = CommonService.CalculateAgeCorrect(bDate.Value).ToString();
|
// 18位身份证号码,出生日期在第7位到第14位
|
||||||
|
birthDateStr = idCard.Substring(6, 8);
|
||||||
|
}
|
||||||
|
else if (idCard.Length == 15)
|
||||||
|
{
|
||||||
|
// 15位身份证号码,出生日期在第7位到第12位,需要加上"19"前缀
|
||||||
|
birthDateStr = "19" + idCard.Substring(6, 6);
|
||||||
|
}
|
||||||
|
var birthDate = DateTime.ParseExact(birthDateStr, "yyyyMMdd", null);
|
||||||
|
if (birthDate != null)
|
||||||
|
{
|
||||||
|
age = CommonService.CalculateAgeCorrect(birthDate).ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return age;
|
return age;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue