//更新操作 private void MyInitForUpdate() { string Handness = ""; string Marriage = ""; string EducationLevel = ""; string FMH = ""; string Working = ""; string Role = ""; string RoleFunction = ""; int Valid = 1; using (SqlConnection conn = new DB().GetConnection()) { SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "select * from Department"; conn.Open(); SqlDataReader rd = cmd.ExecuteReader(); Department.DataSource = rd; Department.DataValueField = "ID"; Department.DataTextField = "Department"; Department.DataBind(); rd.Close(); Department.Items.Insert(0, new ListItem(" ", "-1")); cmd.CommandText = "select * from Patient where GUID=@GUID"; cmd.Parameters.AddWithValue("@GUID", GUIDLabel.Text); rd = cmd.ExecuteReader(); if (rd.Read()) { Patient.Text = rd["PatientName"].ToString(); Initials.Text = rd["Initials"].ToString(); // Sex.Text = rd["Sex"].ToString(); Birthday.Text = String.Format("{0:yyyy-MM-dd}", rd["Birthday"]); Num1.Text = rd["Num1"].ToString(); Num2.Text = rd["Num2"].ToString(); Phone1.Text = rd["Phone1"].ToString(); Phone2.Text = rd["Phone2"].ToString(); EducationYears.Text = rd["EducationYears"].ToString(); // Marriage.Text = rd["Marriage"].ToString(); CertificatesNum.Text = rd["CertificatesNum"].ToString(); Ethnicity.Text = rd["Ethnicity"].ToString(); Career.Text = rd["Career"].ToString(); AI.Text = rd["AI"].ToString(); AHI.Text = rd["AHI"].ToString(); GrowingPlace.Text = rd["GrowingPlace"].ToString(); Residence.Text = rd["Residence"].ToString(); string Department0 = rd["Department"].ToString().Trim(); if (Department.Items.FindByText(Department0) != null) { Department.ClearSelection(); Department.Items.FindByText(Department0).Selected = true; } string Certificates0 = rd["Certificates"].ToString().Trim(); if (DDLCertificates.Items.FindByText(Certificates0) != null) { DDLCertificates.ClearSelection(); DDLCertificates.Items.FindByText(Certificates0).Selected = true; } Handness = rd["Handedness"].ToString().Trim(); if (Handness == left.Text) { left.Checked = true; } if (Handness == right.Text) { right.Checked = true; } if (Handness == both.Text) { both.Checked = true; } Marriage = rd["Marriage"].ToString().Trim(); if (Marriage == marriage1.Text) { marriage1.Checked = true; } if (Marriage == marriage2.Text) { marriage2.Checked = true; } if (Marriage == marriage3.Text) { marriage3.Checked = true; } if (Marriage == marriage4.Text) { marriage4.Checked = true; } if (Marriage == marriage5.Text) { marriage5.Checked = true; } if (Marriage == marriage6.Text) { marriage6.Checked = true; } Role = rd["Role"].ToString().Trim(); if (Role == Role1.Text) { Role1.Checked = true; } if (Role == Role2.Text) { Role2.Checked = true; } if (Role == Role3.Text) { Role3.Checked = true; } if (Role == Role4.Text) { Role4.Checked = true; } RoleFunction = rd["RoleFunction"].ToString().Trim(); if (RoleFunction == RoleFunction1.Text) { RoleFunction1.Checked = true; } if (RoleFunction == RoleFunction2.Text) { RoleFunction2.Checked = true; } if (RoleFunction == RoleFunction3.Text) { RoleFunction3.Checked = true; } if (RoleFunction == RoleFunction4.Text) { RoleFunction4.Checked = true; } if (RoleFunction == RoleFunction5.Text) { RoleFunction5.Checked = true; } EducationLevel = rd["EducationLevel"].ToString().Trim(); if (EducationLevel == educationLevel1.Text) { educationLevel1.Checked = true; } if (EducationLevel == educationLevel2.Text) { educationLevel2.Checked = true; } if (EducationLevel == educationLevel3.Text) { educationLevel3.Checked = true; } if (EducationLevel == educationLevel4.Text) { educationLevel4.Checked = true; } if (EducationLevel == educationLevel5.Text) { educationLevel5.Checked = true; } FMH = rd["FMH"].ToString().Trim(); if (FMH == fmh1.Text) { fmh1.Checked = true; } if (FMH == fmh2.Text) { fmh2.Checked = true; } if (FMH == fmh3.Text) { fmh3.Checked = true; } Working = rd["Working"].ToString().Trim(); if (Working == working1.Text) { working1.Checked = true; } if (Working == working2.Text) { working2.Checked = true; } if (Working == working3.Text) { working3.Checked = true; } if (Working == working4.Text) { working4.Checked = true; } string sex0 = rd["Sex"].ToString().Trim(); if (sex1.Items.FindByText(sex0) != null) { sex1.ClearSelection(); sex1.Items.FindByText(sex0).Selected = true; } string GrowingPlace0 = rd["GrowingPlace"].ToString().Trim(); if (GrowingPlace.Items.FindByText(GrowingPlace0) != null) { GrowingPlace.ClearSelection(); GrowingPlace.Items.FindByText(GrowingPlace0).Selected = true; } string Residence0 = rd["Residence"].ToString().Trim(); if (Residence.Items.FindByText(Residence0) != null) { Residence.ClearSelection(); Residence.Items.FindByText(Residence0).Selected = true; } } if (Valid == 0) { Button1.Visible = false; Button2.Visible = false; } } }