protected void btnInfoFromDocBatch_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); dt = GetTemplateColumn(dt); dt = FileLibrary.GetDataFromWordBatch(ConstantsManager.WEBSITE_VIRTUAL_ROOT_DIR + "/" + ConstantsManager.UPLOAD_DOC_DIR + "/" + "T_BM_KCXLXX", dt, true, true); T_BM_KCXLXXApplicationLogic instanceT_BM_KCXLXXApplicationLogic = (T_BM_KCXLXXApplicationLogic)CreateApplicationLogicInstance(typeof(T_BM_KCXLXXApplicationLogic)); foreach (DataRow dr in dt.Rows) { appData = new T_BM_KCXLXXApplicationData(); appData.KCXLBH = instanceT_BM_KCXLXXApplicationLogic.AutoGenerateKCXLBH(appData); int i = 0; appData = instanceT_BM_KCXLXXApplicationLogic.Add(appData); } }
protected void btnInfoFromDS_Click(object sender, EventArgs e) { int totalCount = 0; int importCount = 0; int updateCount = 0; try { var appDatas = T_BM_KCXLXXApplicationData.GetDataFromDataFile <T_BM_KCXLXXApplicationData>(InfoFromDoc.Text, true, true, recordStartLine: T_BM_KCXLXXContants.ImportDataSetStartLineNum); T_BM_KCXLXXApplicationLogic instanceT_BM_KCXLXXApplicationLogic = (T_BM_KCXLXXApplicationLogic)CreateApplicationLogicInstance(typeof(T_BM_KCXLXXApplicationLogic)); totalCount = appDatas.Count; foreach (var app in appDatas) { app.KCXLBH = instanceT_BM_KCXLXXApplicationLogic.AutoGenerateKCXLBH(app); if (!KCXLMC.Text.IsHtmlNullOrWiteSpace()) { app.KCXLMC = Convert.ToString(KCXLMC.Text); } string strKCXLSJBH = GetValue(new RICH.Common.BM.T_BM_KCXLXX.T_BM_KCXLXXApplicationLogicBase().GetValueByFixCondition("KCXLMC", app.KCXLSJBH, "KCXLBH")); if (!DataValidateManager.ValidateIsNull(strKCXLSJBH)) { app.KCXLSJBH = strKCXLSJBH; } if (!KCXLSJBH.SelectedValue.IsHtmlNullOrWiteSpace()) { app.KCXLSJBH = Convert.ToString(KCXLSJBH.SelectedValue); } if (!KCXLTP.Text.IsHtmlNullOrWiteSpace()) { app.KCXLTP = Convert.ToString(KCXLTP.Text); } if (!KCXLJJ.Text.IsHtmlNullOrWiteSpace()) { app.KCXLJJ = Convert.ToString(KCXLJJ.Text); } if (!NLD.Text.IsHtmlNullOrWiteSpace()) { app.NLD = Convert.ToString(NLD.Text); } if (!KSS.Text.IsHtmlNullOrWiteSpace()) { app.KSS = Convert.ToInt32(KSS.Text); } instanceT_BM_KCXLXXApplicationLogic.Add(app); if (app.ResultCode == RICH.Common.Base.ApplicationData.ApplicationDataBase.ResultState.Succeed) { importCount++; } else { app.OPCode = RICH.Common.Base.ApplicationData.ApplicationDataBase.OPType.PK; instanceT_BM_KCXLXXApplicationLogic.Modify(app); if (app.ResultCode == RICH.Common.Base.ApplicationData.ApplicationDataBase.ResultState.Succeed) { updateCount++; } } } MessageContent += @"<font color=""green"">共{0}条数据,导入数据{1}条,更新数据{2}条。</font>".FormatInvariantCulture(totalCount, importCount, updateCount); } catch (Exception ex) { MessageContent += @"<font color=""red"">导入数据过程出错:{0}<br/>共{1}条数据,已导入数据{2}条,已更新数据{3}条。</font>".FormatInvariantCulture(ex.Message, totalCount, importCount, updateCount); } }
//===================================================================== // FunctionName : GetAddInputParameter /// <summary> /// 得到添加用户输入参数操作 /// </summary> //===================================================================== protected override Boolean GetAddInputParameter() { Boolean boolReturn = true; ValidateData validateData = new ValidateData(); // 验证输入参数 validateData = ValidateKCXLMC(KCXLMC.Text, false, false); if (validateData.Result) { if (!validateData.IsNull) { appData.KCXLMC = Convert.ToString(validateData.Value.ToString()); } KCXLMC.BackColor = System.Drawing.Color.Empty; } else { KCXLMC.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = validateData.Result; } validateData = ValidateKCXLSJBH(KCXLSJBH.SelectedValue, true, false); if (validateData.Result) { if (!validateData.IsNull) { appData.KCXLSJBH = Convert.ToString(validateData.Value.ToString()); } KCXLSJBH.BackColor = System.Drawing.Color.Empty; } else { KCXLSJBH.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = validateData.Result; } if (KCXLTP.Upload()) { appData.KCXLTP = KCXLTP.Text; } else { MessageContent += @"<font color=""red"">" + KCXLTP.Message + "</font>"; boolReturn = false; } validateData = ValidateKCXLJJ(KCXLJJ.Text, false, false); if (validateData.Result) { if (!validateData.IsNull) { appData.KCXLJJ = Convert.ToString(validateData.Value.ToString()); } KCXLJJ.BackColor = System.Drawing.Color.Empty; } else { KCXLJJ.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = validateData.Result; } validateData = ValidateNLD(NLD.Text, false, false); if (validateData.Result) { if (!validateData.IsNull) { appData.NLD = Convert.ToString(validateData.Value.ToString()); } NLD.BackColor = System.Drawing.Color.Empty; } else { NLD.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = validateData.Result; } validateData = ValidateKSS(KSS.Text, false, false); if (validateData.Result) { if (!validateData.IsNull) { appData.KSS = Convert.ToInt32(validateData.Value.ToString()); } KSS.BackColor = System.Drawing.Color.Empty; } else { KSS.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = validateData.Result; } // 自动生成编号 T_BM_KCXLXXApplicationLogic instanceT_BM_KCXLXXApplicationLogic = (T_BM_KCXLXXApplicationLogic)CreateApplicationLogicInstance(typeof(T_BM_KCXLXXApplicationLogic)); appData.KCXLBH = instanceT_BM_KCXLXXApplicationLogic.AutoGenerateKCXLBH(appData); return(boolReturn); }