2. Read and display of detailed data
The reading and display of the detailed data is one of the most code we have encountered. This code is divided into two phases: 1. Take the corresponding object, 2. Display data to the interface. When you display data, you should organize. For a plurality of class aggregate multiple classes, each class is divided into a function to process, each processing function must basically guarantee a statement to handle a Porperty, for the required attribute, use a function Conversion. The code example is as follows:
1. Take the corresponding object
Private CPERSON getPerson ()
{
Guid GuidPerson = New Guid (this.m_pguid.text);
CPERSON PERSON = CPERSON .LOAD (GUIDPERSON);
}
2. Display the corresponding object
Show Person
Private void showperson ()
{
CPERSON PERSON = getPerson ()
IF (persons == null) return;
THIS.TB_NAME.TEXT = Person.name;
/// Use a function when the task cannot be completed by a set value statement, or when conditional judgment is required.
Setgender (Person.gender);
THIS.TB_OLD.DATEVALUE = Person.Borndate; showcontactinfo; showapplyrecord (Person.ApplyRecord); this.tb_worktime.datevalue = person.startworkDate;}
Private void setgender (BOOL BGENDER) {if (bgender) this.rbmale.checked = true; else this.rbfemaale .checked = true;} /// Display Other objects, here Display contact information private void showcontactinfo (ccontactinfo info) {IF (info == null) return; this.tb_phone.Text = info.Phone; this.tbMobilePhone.Text = info.MobilePhoneNo; this.tbEmail.Text = info.EMail;} /// shown here educational experience private void ShowEducationHistory ( CEducationHistory history) {if (history == null) return; this.tb_school.Text = history.School; this.tb_time.Value = history.StartDate.ToShortDateString (); this.tb_study.Text = history.Speciality; this.ddlEducationalLevel }.Ddldegree.selectedValue = history.degree;} private void initApplyRecord (CAPPLYRECORD APPLY) {if (apply == null) Return;
this.tb_eng.SelectedValue = apply.EnglishLevel; this.tb_jan.SelectedValue = apply.JanpaneseLevel; this.tb_other.SelectedValue = apply.OtherLanguageName; this.tbOtherLanguageLevel.Text = apply.OtherLanguageLevel; this.tb_work1.Text = apply.ApplyJob1; THISTB_WORK2.TEXT = Apply.ApplyJob2; this.tb_work3.text = Apply.ApplyJob3; this.applydate.value = Apply.ApplyDate.toshortdateString ();
InInited TechnologyHistory;} Conclusion: Display data is clear and easy, clear responsibility, which function is responsible for the object, which function is responsible for displaying which object's data, display data to keep a statement to display a Porperty, do not do The usage function is used for processing.