protected void Button2_Click(object sender, EventArgs e) { modelRel.relativeID = int.Parse(Session["relid"].ToString()); modelRel = RB.getRelative(modelRel); modelRel.relativeName = this.TextBox1.Text; modelRel.relativeIDcard = this.TextBox3.Text; modelRel.relativeMobile = this.TextBox4.Text; if (this.RadioButton1.Checked) { modelRel.relativeGender = "男"; } else if (this.RadioButton2.Checked) { modelRel.relativeGender = "女"; } if (this.RadioButton3.Checked) { modelRel.relativeMarriageStatus = "未婚"; } else if (this.RadioButton4.Checked) { modelRel.relativeMarriageStatus = "已婚"; } if (this.RadioButton14.Checked) { modelRel.relativeRelationship = "配偶"; } else if (this.RadioButton15.Checked) { modelRel.relativeRelationship = "子女"; } else if (this.RadioButton16.Checked) { modelRel.relativeRelationship = "父母"; } else if (this.RadioButton17.Checked) { modelRel.relativeRelationship = "其他"; } modelRel.relativeDOB = DateTime.Parse(DropDownListYear.SelectedValue + "-" + DropDownListMonth.SelectedValue + "-" + DropDownListDay.SelectedValue); RB.update(modelRel); this.Button3_Click(sender, e); this.GridView1.DataBind(); Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "message", " <script>alert('更新家属信息成功!');</script>"); }
void initrel() { string i = Request.QueryString["Cid"]; Session["relid"] = i; modelRel.relativeID = int.Parse(i); modelRel = RB.getRelative(modelRel); this.TextBox1.Text = modelRel.relativeName; this.TextBox3.Text = modelRel.relativeIDcard; this.TextBox4.Text = modelRel.relativeMobile; if (modelRel.relativeGender == "男") { this.RadioButton1.Checked = true; classmale = "selected"; } else if (modelRel.relativeGender == "女") { this.RadioButton2.Checked = true; classfemale = "selected"; } if (modelRel.relativeMarriageStatus == "未婚") { this.RadioButton3.Checked = true; classunmarried = "selected"; } else if (modelRel.relativeMarriageStatus == "已婚") { this.RadioButton4.Checked = true; classmarried = "selected"; } if (modelRel.relativeRelationship == "配偶") { this.RadioButton14.Checked = true; } else if (modelRel.relativeRelationship == "子女") { this.RadioButton15.Checked = true; } else if (modelRel.relativeRelationship == "父母") { this.RadioButton16.Checked = true; } else if (modelRel.relativeRelationship == "其他") { this.RadioButton17.Checked = true; } }
protected void Button1_Click(object sender, EventArgs e) { DataTable dt = RB.RelativeSelect("SELECT relativeName,relativeID,relativeIDcard FROM tab_relatives WHERE relativeCustomer=" + Session["id"].ToString()); if (dt.Rows.Count >= 6) { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "message", " <script>alert('您至多可以添加6个家属!');</script>"); return; } else if (dt.Rows[0]["relativeName"].ToString() != this.TextBox1.Text && dt.Rows[0]["relativeIDcard"].ToString() != this.TextBox3.Text) { Model.tab_relatives relative = new Model.tab_relatives(); relative.relativeCustomer = int.Parse(Session["id"].ToString()); relative.relativeName = this.TextBox1.Text; relative.relativeIDcard = this.TextBox3.Text; relative.relativeMobile = this.TextBox4.Text; if (this.RadioButton1.Checked) { relative.relativeGender = "男"; } else if (this.RadioButton2.Checked) { relative.relativeGender = "女"; } if (this.RadioButton3.Checked) { relative.relativeMarriageStatus = "未婚"; } else if (this.RadioButton4.Checked) { relative.relativeMarriageStatus = "已婚"; } if (this.RadioButton14.Checked) { relative.relativeRelationship = "配偶"; } else if (this.RadioButton15.Checked) { relative.relativeRelationship = "子女"; } else if (this.RadioButton16.Checked) { relative.relativeRelationship = "父母"; } else if (this.RadioButton17.Checked) { relative.relativeRelationship = "其他"; } relative.relativeDOB = DateTime.Parse(DropDownListYear.SelectedValue + "-" + DropDownListMonth.SelectedValue + "-" + DropDownListDay.SelectedValue); RB.RelativeAdd(relative); clearcontent(); this.GridView1.DataBind(); Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "message", " <script>alert('新增家属成功,可以继续添加!');</script>"); } else { Response.Write("<script>alert('提交失败!')</script>"); } }