Common Code Writing Specification (2) - Detailed Data Reading and Display December 8, 2004 2. Reading and Display Details of Details Details Details is one of the most code we have encountered, this code is divided into two Phase to complete: 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 display Person Private Void ShowPerson () {CPERSON PERSON = getPerson () if (person == null) return; this.tb_name.text = person.name; // When the task cannot be completed by a set value statement, or when conditional judgment is required, use Function 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 .SelectedValue = history.EducationalLevel; this.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.TherlanguageName; this.tbotherlangua Geevel.Text = Apply.TherlanguageEevel;
this.tb_work1.Text = apply.ApplyJob1; this.tb_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.