public void Bind_Family(int NewIndex) { try { int size = this.gv_Periodical.PageSize; var ps = FamilyOfPeopleBusiness.GetFamilys(id, size); this.gv_Periodical.PageIndex = NewIndex; this.gv_Periodical.DataSource = new PagedCollection <Family>(ps, NewIndex); this.gv_Periodical.DataBind(); this.label_ResultCount.Text = ps.GetResultCount().ToString(); } catch (Exception ex) { text(ex.ToString()); ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "alert('数据加载错误!')", true); } }
protected void gv_Periodical_RowCommand1(object sender, GridViewCommandEventArgs e) { int idFamily = Convert.ToInt32(e.CommandArgument); if (e.CommandName.Equals("Del")) //删除家庭成员 { bool result = FamilyOfPeopleBusiness.deleteFamilyOfPeople(idFamily); if (!result) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "alert('删除失败,请重新再试!')", true); return; } Bind_Family(0); } else if (e.CommandName.Equals("Udp")) //修改家庭成员 { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "btn_Add_jlqk_Click('添加家庭成员','./CheckAffairList_cztb_jtcy_Add.aspx?idFamily=" + idFamily + "')", true); } }
protected void btn_Add_Click(object sender, EventArgs e) { string name = tb_PeriodicalName.Text; bool sex = !radio_1.SelectedValue.Equals("1"); DateTime birthday = new DateTime(1900, 1, 2); try { birthday = input_RegisterDate.Value.Equals("") ? birthday : Convert.ToDateTime(input_RegisterDate.Value); } catch (Exception ex) { text(ex.ToString()); Page.ClientScript.RegisterStartupScript(this.GetType(), "alter", "alert('时间输入格式不规范,请重新输入!')", true); return; } String relationship = tb_PublishCount.Text; String company = tb_EIC_Name.Text; String tip = tb_EO_Address.Text; bool result = false; if (familyId != 0) //修改 { result = FamilyOfPeopleBusiness.UpdateFamilyOfPeople(familyId, name, sex, birthday, relationship, company, tip); if (!result) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alter", "alert('修改失败,请重新再试!')", true); return; } Page.ClientScript.RegisterStartupScript(this.GetType(), "alter", "parent.layer.msg('修改成功', 2, -1);close();", true); } else //新增 { result = FamilyOfPeopleBusiness.AddFamilyOfPeople(peopleId, name, sex, birthday, relationship, company, tip); if (!result) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alter", "alert('新增失败,请重新再试!')", true); return; } Page.ClientScript.RegisterStartupScript(this.GetType(), "alter", "parent.layer.msg('新增成功', 2, -1);close();", true); } }