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_KCBXX", dt, true, true); T_BM_KCBXXApplicationLogic instanceT_BM_KCBXXApplicationLogic = (T_BM_KCBXXApplicationLogic)CreateApplicationLogicInstance(typeof(T_BM_KCBXXApplicationLogic)); foreach (DataRow dr in dt.Rows) { appData = new T_BM_KCBXXApplicationData(); appData.KCBBH = instanceT_BM_KCBXXApplicationLogic.AutoGenerateKCBBH(appData); int i = 0; appData = instanceT_BM_KCBXXApplicationLogic.Add(appData); } }
protected void btnInfoFromDS_Click(object sender, EventArgs e) { int totalCount = 0; int importCount = 0; int updateCount = 0; try { var appDatas = T_BM_KCBXXApplicationData.GetDataFromDataFile <T_BM_KCBXXApplicationData>(InfoFromDoc.Text, true, true, recordStartLine: T_BM_KCBXXContants.ImportDataSetStartLineNum); T_BM_KCBXXApplicationLogic instanceT_BM_KCBXXApplicationLogic = (T_BM_KCBXXApplicationLogic)CreateApplicationLogicInstance(typeof(T_BM_KCBXXApplicationLogic)); totalCount = appDatas.Count; foreach (var app in appDatas) { app.KCBBH = instanceT_BM_KCBXXApplicationLogic.AutoGenerateKCBBH(app); string strKCXLBH = GetValue(new RICH.Common.BM.T_BM_KCXLXX.T_BM_KCXLXXApplicationLogicBase().GetValueByFixCondition("KCXLMC", app.KCXLBH, "KCXLBH")); if (!DataValidateManager.ValidateIsNull(strKCXLBH)) { app.KCXLBH = strKCXLBH; } if (!KCXLBH.SelectedValue.IsHtmlNullOrWiteSpace()) { app.KCXLBH = Convert.ToString(KCXLBH.SelectedValue); } string strKCBH = GetValue(new RICH.Common.BM.T_BM_KCXX.T_BM_KCXXApplicationLogicBase().GetValueByFixCondition("KCMC", app.KCBH, "KCBH")); if (!DataValidateManager.ValidateIsNull(strKCBH)) { app.KCBH = strKCBH; } if (!KCBH.SelectedValue.IsHtmlNullOrWiteSpace()) { app.KCBH = Convert.ToString(KCBH.SelectedValue); } if (!KCSJ.Text.IsHtmlNullOrWiteSpace()) { app.KCSJ = Convert.ToDateTime(KCSJ.Text); } if (!KSS.Text.IsHtmlNullOrWiteSpace()) { app.KSS = Convert.ToInt32(KSS.Text); } string strSKJS = GetValue(new RICH.Common.BM.T_PM_UserInfo.T_PM_UserInfoApplicationLogicBase().GetValueByFixCondition("UserNickName", app.SKJS, "UserID")); if (!DataValidateManager.ValidateIsNull(strSKJS)) { app.SKJS = strSKJS; } if (!SKJS.SelectedValue.IsHtmlNullOrWiteSpace()) { app.SKJS = Convert.ToString(SKJS.SelectedValue); } if (!SKFJ.Text.IsHtmlNullOrWiteSpace()) { app.SKFJ = Convert.ToString(SKFJ.Text); } instanceT_BM_KCBXXApplicationLogic.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_KCBXXApplicationLogic.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 = ValidateKCXLBH(KCXLBH.SelectedValue, false, false); if (validateData.Result) { if (!validateData.IsNull) { appData.KCXLBH = Convert.ToString(validateData.Value.ToString()); } KCXLBH.BackColor = System.Drawing.Color.Empty; } else { KCXLBH.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = validateData.Result; } validateData = ValidateKCBH(KCBH.SelectedValue, false, false); if (validateData.Result) { if (!validateData.IsNull) { appData.KCBH = Convert.ToString(validateData.Value.ToString()); } KCBH.BackColor = System.Drawing.Color.Empty; } else { KCBH.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = validateData.Result; } validateData = ValidateKCSJ(KCSJ.Text, false, false); if (validateData.Result) { if (!validateData.IsNull) { appData.KCSJ = Convert.ToDateTime(validateData.Value.ToString()); } KCSJ.BackColor = System.Drawing.Color.Empty; } else { KCSJ.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; } validateData = ValidateSKJS(SKJS.SelectedValue, false, false); if (validateData.Result) { if (!validateData.IsNull) { appData.SKJS = Convert.ToString(validateData.Value.ToString()); } SKJS.BackColor = System.Drawing.Color.Empty; } else { SKJS.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = validateData.Result; } validateData = ValidateSKFJ(SKFJ.Text, false, false); if (validateData.Result) { if (!validateData.IsNull) { appData.SKFJ = Convert.ToString(validateData.Value.ToString()); } SKFJ.BackColor = System.Drawing.Color.Empty; } else { SKFJ.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = validateData.Result; } // 自动生成编号 T_BM_KCBXXApplicationLogic instanceT_BM_KCBXXApplicationLogic = (T_BM_KCBXXApplicationLogic)CreateApplicationLogicInstance(typeof(T_BM_KCBXXApplicationLogic)); appData.KCBBH = instanceT_BM_KCBXXApplicationLogic.AutoGenerateKCBBH(appData); return(boolReturn); }