void txtAge_TextChanged(object sender, EventArgs e) { this.birth.ValueChanged -= new EventHandler(birth_TextChanged); //if (sender.Equals(txtYear) == false) this.txtYear.TextChanged -= new EventHandler(txtAge_TextChanged); //if (sender.Equals(txtMonth) == false) this.txtMonth.TextChanged -= new EventHandler(txtAge_TextChanged); //if (sender.Equals(txtDay) == false) this.txtDay.TextChanged -= new EventHandler(txtAge_TextChanged); //if (sender.Equals(txtHour) == false) this.txtHour.TextChanged -= new EventHandler(txtAge_TextChanged); if (sender.Equals(txtYear)) { this.txtMonth.Text = "0"; this.txtDay.Text = "0"; this.txtHour.Text = "0"; } if (sender.Equals(txtMonth)) { this.txtYear.Text = "0"; this.txtDay.Text = "0"; this.txtHour.Text = "0"; } if (sender.Equals(txtDay)) { this.txtMonth.Text = "0"; this.txtYear.Text = "0"; this.txtHour.Text = "0"; } if (sender.Equals(txtHour)) { this.txtMonth.Text = "0"; this.txtDay.Text = "0"; this.txtYear.Text = "0"; } AgeValue value = new AgeValue(); value.Y_num = ConvertDataExtend.ToInt32(txtYear.Text, 0); value.M_num = ConvertDataExtend.ToInt32(txtMonth.Text, 0); value.D_num = ConvertDataExtend.ToInt32(txtDay.Text, 0); value.H_num = ConvertDataExtend.ToInt32(txtHour.Text, 0); //this.birth.Text = AgeExtend.GetDateTime(value).ToString("yyyyMMddHHmm"); this.birth.Value = AgeExtend.GetDateTime(value); //if (sender.Equals(txtYear)==false) this.txtYear.TextChanged += new EventHandler(txtAge_TextChanged); //if (sender.Equals(txtMonth) == false) this.txtMonth.TextChanged += new EventHandler(txtAge_TextChanged); //if (sender.Equals(txtDay) == false) this.txtDay.TextChanged += new EventHandler(txtAge_TextChanged); //if (sender.Equals(txtHour) == false) this.txtHour.TextChanged += new EventHandler(txtAge_TextChanged); this.birth.ValueChanged += new EventHandler(birth_TextChanged); }
private void birth_TextChanged(object sender, EventArgs e) { //this.birth.TextChanged -= new EventHandler(birth_TextChanged); this.txtYear.TextChanged -= new EventHandler(txtAge_TextChanged); this.txtMonth.TextChanged -= new EventHandler(txtAge_TextChanged); this.txtDay.TextChanged -= new EventHandler(txtAge_TextChanged); this.txtHour.TextChanged -= new EventHandler(txtAge_TextChanged); AgeValue value = AgeExtend.GetAgeValue(AgeBirthday); txtYear.Text = value.Y_num.ToString(); txtMonth.Text = value.M_num.ToString(); txtDay.Text = value.D_num.ToString(); txtHour.Text = value.H_num.ToString(); this.txtYear.TextChanged += new EventHandler(txtAge_TextChanged); this.txtMonth.TextChanged += new EventHandler(txtAge_TextChanged); this.txtDay.TextChanged += new EventHandler(txtAge_TextChanged); this.txtHour.TextChanged += new EventHandler(txtAge_TextChanged); //this.birth.TextChanged += new EventHandler(birth_TextChanged); }