private List<BillVisaPerson> BindPerson(bool AddNew) { List<BillVisaPerson> lis = new List<BillVisaPerson>(); List<string> OwnerList = new List<string>(); BillVisaPerson person; TextBox txtVisaName, txtCountry, txtPassport, txtPostFee, txtServiceFee, txtBirthCert, txtHKPass; TextBox txtEntryDate, txtApplyDate, txtApproveDate, txtEmbassySerialNum, txtEmbassyFee, txtVisaCenterFee; DropDownList ddlVisaType, ddlUrgent; //保存现有的gridview 数据 for (int i = 0; i < gvData.Rows.Count; i++) { if (gvData.Rows[i].Visible == false) continue; txtVisaName = (TextBox)gvData.Rows[i].FindControl("txtVisaName"); OwnerList.Add(txtVisaName.Text); txtCountry = (TextBox)gvData.Rows[i].FindControl("txtCountry"); txtPassport = (TextBox)gvData.Rows[i].FindControl("txtPassport"); txtEntryDate = (TextBox)gvData.Rows[i].FindControl("txtEntryDate"); txtApplyDate = (TextBox)gvData.Rows[i].FindControl("txtApplyDate"); txtApproveDate = (TextBox)gvData.Rows[i].FindControl("txtApproveDate"); txtEmbassySerialNum = (TextBox)gvData.Rows[i].FindControl("txtEmbassySerialNum"); txtEmbassyFee = (TextBox)gvData.Rows[i].FindControl("txtEmbassyFee"); txtPostFee = (TextBox)gvData.Rows[i].FindControl("txtPostFee"); txtServiceFee = (TextBox)gvData.Rows[i].FindControl("txtServiceFee"); txtBirthCert = (TextBox)gvData.Rows[i].FindControl("txtBirthCert"); txtHKPass = (TextBox)gvData.Rows[i].FindControl("txtHKPass"); txtVisaCenterFee = (TextBox)gvData.Rows[i].FindControl("txtVisaCenterFee"); ddlVisaType = (DropDownList)gvData.Rows[i].FindControl("ddlVisaType"); ddlUrgent = (DropDownList)gvData.Rows[i].FindControl("ddlUrgent"); person = new BillVisaPerson(); person.VisaName = txtVisaName.Text.Trim(); person.Country = txtCountry.Text.Trim(); person.Passport = txtPassport.Text.Trim(); person.VisaType = ddlVisaType.Text; person.IsUrgent = bool.Parse(ddlUrgent.Text); if (!string.IsNullOrEmpty(txtEntryDate.Text)) person.EntryDate = DateTime.Parse(txtEntryDate.Text); if (!string.IsNullOrEmpty(txtApplyDate.Text)) person.ApplyDate = DateTime.Parse(txtApplyDate.Text); if (!string.IsNullOrEmpty(txtApproveDate.Text)) person.ApproveDate = DateTime.Parse(txtApproveDate.Text); person.EmbassySerialNum = txtEmbassySerialNum.Text.Trim(); person.EmbassyFee = decimal.Parse(txtEmbassyFee.Text); person.PostFee = decimal.Parse(txtPostFee.Text==""?"0":txtPostFee.Text); person.ServiceFee = decimal.Parse(txtServiceFee.Text); person.BirthCert = decimal.Parse(txtBirthCert.Text==""?"0":txtBirthCert.Text); person.HKPass = decimal.Parse(txtHKPass.Text == "" ? "0" : txtHKPass.Text); person.VisaCenterFee = decimal.Parse(txtVisaCenterFee.Text==""?"0": txtVisaCenterFee.Text); lis.Add(person); } //新增一行 if (AddNew) { person = new BillVisaPerson(); person.PostFee = 20; person.ServiceFee = 20; lis.Add(person); } return lis; }
private List <BillVisaPerson> BindPerson(bool AddNew) { List <BillVisaPerson> lis = new List <BillVisaPerson>(); List <string> OwnerList = new List <string>(); BillVisaPerson person; TextBox txtVisaName, txtCountry, txtPassport, txtPostFee, txtServiceFee, txtBirthCert, txtHKPass; TextBox txtEntryDate, txtApplyDate, txtApproveDate, txtEmbassySerialNum, txtEmbassyFee, txtVisaCenterFee; DropDownList ddlVisaType, ddlUrgent; //保存现有的gridview 数据 for (int i = 0; i < gvData.Rows.Count; i++) { if (gvData.Rows[i].Visible == false) { continue; } txtVisaName = (TextBox)gvData.Rows[i].FindControl("txtVisaName"); OwnerList.Add(txtVisaName.Text); txtCountry = (TextBox)gvData.Rows[i].FindControl("txtCountry"); txtPassport = (TextBox)gvData.Rows[i].FindControl("txtPassport"); txtEntryDate = (TextBox)gvData.Rows[i].FindControl("txtEntryDate"); txtApplyDate = (TextBox)gvData.Rows[i].FindControl("txtApplyDate"); txtApproveDate = (TextBox)gvData.Rows[i].FindControl("txtApproveDate"); txtEmbassySerialNum = (TextBox)gvData.Rows[i].FindControl("txtEmbassySerialNum"); txtEmbassyFee = (TextBox)gvData.Rows[i].FindControl("txtEmbassyFee"); txtPostFee = (TextBox)gvData.Rows[i].FindControl("txtPostFee"); txtServiceFee = (TextBox)gvData.Rows[i].FindControl("txtServiceFee"); txtBirthCert = (TextBox)gvData.Rows[i].FindControl("txtBirthCert"); txtHKPass = (TextBox)gvData.Rows[i].FindControl("txtHKPass"); txtVisaCenterFee = (TextBox)gvData.Rows[i].FindControl("txtVisaCenterFee"); ddlVisaType = (DropDownList)gvData.Rows[i].FindControl("ddlVisaType"); ddlUrgent = (DropDownList)gvData.Rows[i].FindControl("ddlUrgent"); person = new BillVisaPerson(); person.VisaName = txtVisaName.Text.Trim(); person.Country = txtCountry.Text.Trim(); person.Passport = txtPassport.Text.Trim(); person.VisaType = ddlVisaType.Text; person.IsUrgent = bool.Parse(ddlUrgent.Text); if (!string.IsNullOrEmpty(txtEntryDate.Text)) { person.EntryDate = DateTime.Parse(txtEntryDate.Text); } if (!string.IsNullOrEmpty(txtApplyDate.Text)) { person.ApplyDate = DateTime.Parse(txtApplyDate.Text); } if (!string.IsNullOrEmpty(txtApproveDate.Text)) { person.ApproveDate = DateTime.Parse(txtApproveDate.Text); } person.EmbassySerialNum = txtEmbassySerialNum.Text.Trim(); person.EmbassyFee = decimal.Parse(txtEmbassyFee.Text); person.PostFee = decimal.Parse(txtPostFee.Text == ""?"0":txtPostFee.Text); person.ServiceFee = decimal.Parse(txtServiceFee.Text); person.BirthCert = decimal.Parse(txtBirthCert.Text == ""?"0":txtBirthCert.Text); person.HKPass = decimal.Parse(txtHKPass.Text == "" ? "0" : txtHKPass.Text); person.VisaCenterFee = decimal.Parse(txtVisaCenterFee.Text == ""?"0": txtVisaCenterFee.Text); lis.Add(person); } //新增一行 if (AddNew) { person = new BillVisaPerson(); person.PostFee = 20; person.ServiceFee = 20; lis.Add(person); } return(lis); }