protected void btnSave_Click(object sender, EventArgs e) { FineOffice.Modules.CNS_CensusRegister model = new FineOffice.Modules.CNS_CensusRegister(); try { model.CensusTypeID = int.Parse(ddlCensusType.SelectedValue); model.Habitation = txtHabitation.Text.Trim(); model.HouseHolder = txtHouseHolder.Text.Trim(); model.RegisterNO = txtRegisterNO.Text.Trim(); model.IssuingAuthority = txtIssuingAuthority.Text.Trim(); model.IssuingDate = DateTime.Parse(dtpIssuingDate.Text); registerBll.Add(model); } catch (Exception ex) { Alert.Show(ex.Message); } PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference("register_close")); }
public void LoadData() { List <FineOffice.Modules.CNS_CensusType> list = typeBll.GetListAll(); foreach (FineOffice.Modules.CNS_CensusType type in list) { ddlCensusType.Items.Add(new FineUI.ListItem(type.CensusTypeName, type.ID.ToString())); } if (Request["ID"] != null) { int id = int.Parse(Request["ID"]); hiddenID.Text = Request["ID"]; FineOffice.Modules.CNS_CensusRegister model = registerBll.GetModel(d => d.ID == id); txtRegisterNO.Text = model.RegisterNO; txtHabitation.Text = model.Habitation; txtHouseHolder.Text = model.HouseHolder; txtIssuingAuthority.Text = model.IssuingAuthority; ddlCensusType.SelectedValue = model.CensusTypeID.ToString(); dtpIssuingDate.Text = string.Format("{0:yyyy-MM-dd}", model.IssuingDate); } }
/// <summary> /// 保存导入数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { FineOffice.Common.Excel.ExcelHelper toExcel = new FineOffice.Common.Excel.ExcelHelper(); FineOffice.Web.WebExcelHelper excelHelper = new FineOffice.Web.WebExcelHelper(); string serverPath = Server.MapPath("~/Config/Template/CNS_CensusMember.xml"); List <ExcelHeader> headerList = toExcel.GetHeaderList(serverPath); try { foreach (GridRow row in gridMember.Rows) { gridMember.SelectedRowIndex = row.RowIndex; Dictionary <string, object> valueMap = new Dictionary <string, object>(); foreach (GridColumn column in gridMember.Columns) { FineUI.BoundField field = column as FineUI.BoundField; string value = row.Values[column.ColumnIndex].ToString(); if (field != null) { valueMap.Add(field.DataField, value); } } FineOffice.Modules.CNS_CensusMember model = toExcel.Create <FineOffice.Modules.CNS_CensusMember>(headerList, valueMap); FineOffice.Modules.CNS_CensusRegister register = registerBll.GetModel(m => m.RegisterNO == model.RegisterNO); if (register == null) { register = new FineOffice.Modules.CNS_CensusRegister(); register.RegisterNO = model.RegisterNO; register.HouseHolder = model.HouseHolder; FineOffice.Modules.CNS_CensusType type = typeBll.GetModel(t => t.CensusTypeName == model.CensusTypeName); if (type == null) { type = new FineOffice.Modules.CNS_CensusType(); type.CensusTypeName = model.CensusTypeName; type = typeBll.Add(type); } register.CensusTypeID = type.ID; registerBll.Add(register); } if (model.Gender == "男") { model.Sex = 1; } else { model.Sex = 0; } FineOffice.Modules.CNS_PoliticalAffiliation political = politicalBll.GetModel(m => m.Political == model.Political); if (political == null) { political = new FineOffice.Modules.CNS_PoliticalAffiliation(); political.Political = model.Political; political = politicalBll.Add(political); } model.PoliticalID = political.ID; FineOffice.Modules.AM_Kind kind = kindBll.GetModel(m => m.Name == model.Education); if (kind != null) { model.EducationID = kind.ID; } memberBll.Add(model); } PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference("member_close")); } catch (Exception ex) { FineUI.Alert.ShowInParent(ex.Message); } }