/// <summary> /// 计算年龄 /// </summary> private void CountAgeByBirthday() { //分页统计当数据行数超过200时不计算 try { for (int i = 0; i < 200; i++) { //string age = ds.Tables[0].Rows[i]["年龄"].ToString(); string birthday = ds.Tables[0].Rows[i]["birthday"].ToString(); //生日 string in_time = ds.Tables[0].Rows[i]["住院日期"].ToString(); //生日 int year, month, day; DataInit.GetAgeByBirthday(Convert.ToDateTime(birthday), Convert.ToDateTime(in_time), out year, out month, out day); string strTemp = ""; if (year > 0) { strTemp = year.ToString() + "岁"; } else if (month > 0) { strTemp = month.ToString() + "月"; } else { strTemp = day.ToString() + "天"; } ucGridviewX1.fg["年龄", i + 1].Value = strTemp; } } catch (Exception ex) { } }
/// <summary> /// 计算年龄 /// </summary> private void CountAgeByBirthday() { //分页统计当数据行数超过200时不计算 try { for (int i = 0; i < 200; i++) { //if (dsPatientInfo.Tables[0].Rows[i]["id"].ToString() == "7524") //{ // App.Msg(""); //} string birthday = dsPatientInfo.Tables[0].Rows[i]["birthday"].ToString(); //生日 string in_time = dsPatientInfo.Tables[0].Rows[i]["住院日期"].ToString(); // int year, month, day; DataInit.GetAgeByBirthday(Convert.ToDateTime(birthday), Convert.ToDateTime(in_time), out year, out month, out day); string strTemp = ""; if (year > 0) { strTemp = year.ToString() + "岁"; } else if (month > 0) { strTemp = month.ToString() + "月"; } else { strTemp = day.ToString() + "天"; } flgView.fg.Cols["年龄"][i + 1] = strTemp; } } catch (Exception ex) { } }
/// <summary> /// 根据时间的变化从而得到病人的年龄 /// </summary> private void stamp() { try { int year = 0; int mont = 0; int day = 0; DataInit.GetAgeByBirthday(dtpBirthday.Value, App.GetSystemTime(), out year, out mont, out day); if (year > 0) { txtAge.Text = year.ToString(); } } catch { } }