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_BMXX", dt, true, true); T_BM_BMXXApplicationLogic instanceT_BM_BMXXApplicationLogic = (T_BM_BMXXApplicationLogic)CreateApplicationLogicInstance(typeof(T_BM_BMXXApplicationLogic)); foreach (DataRow dr in dt.Rows) { appData = new T_BM_BMXXApplicationData(); appData.BMBH = instanceT_BM_BMXXApplicationLogic.AutoGenerateBMBH(appData); int i = 0; appData = instanceT_BM_BMXXApplicationLogic.Add(appData); } }
protected void btnInfoFromDS_Click(object sender, EventArgs e) { int totalCount = 0; int importCount = 0; int updateCount = 0; try { var appDatas = T_BM_BMXXApplicationData.GetDataFromDataFile <T_BM_BMXXApplicationData>(InfoFromDoc.Text, true, true, recordStartLine: T_BM_BMXXContants.ImportDataSetStartLineNum); T_BM_BMXXApplicationLogic instanceT_BM_BMXXApplicationLogic = (T_BM_BMXXApplicationLogic)CreateApplicationLogicInstance(typeof(T_BM_BMXXApplicationLogic)); totalCount = appDatas.Count; foreach (var app in appDatas) { app.BMBH = instanceT_BM_BMXXApplicationLogic.AutoGenerateBMBH(app); string strHYBH = GetValue(new RICH.Common.BM.T_BM_HYXX.T_BM_HYXXApplicationLogicBase().GetValueByFixCondition("HYXM", app.HYBH, "HYBH")); if (!DataValidateManager.ValidateIsNull(strHYBH)) { app.HYBH = strHYBH; } if (!HYBH.SelectedValue.IsHtmlNullOrWiteSpace()) { app.HYBH = Convert.ToString(HYBH.SelectedValue); } if (!KCJG.Text.IsHtmlNullOrWiteSpace()) { app.KCJG = Convert.ToDouble(KCJG.Text); } if (!KSS.Text.IsHtmlNullOrWiteSpace()) { app.KSS = Convert.ToInt32(KSS.Text); } if (!KCZK.Text.IsHtmlNullOrWiteSpace()) { app.KCZK = Convert.ToDouble(KCZK.Text); } if (!SJJG.Text.IsHtmlNullOrWiteSpace()) { app.SJJG = Convert.ToDouble(SJJG.Text); } string strSKR = GetValue(new RICH.Common.BM.T_PM_UserInfo.T_PM_UserInfoApplicationLogicBase().GetValueByFixCondition("UserNickName", app.SKR, "UserID")); if (!DataValidateManager.ValidateIsNull(strSKR)) { app.SKR = strSKR; } if (!SKR.SelectedValue.IsHtmlNullOrWiteSpace()) { app.SKR = Convert.ToString(SKR.SelectedValue); } if (!BMSJ.Text.IsHtmlNullOrWiteSpace()) { app.BMSJ = Convert.ToDateTime(BMSJ.Text); } if (!BZ.Text.IsHtmlNullOrWiteSpace()) { app.BZ = Convert.ToString(BZ.Text); } app.LRR = CurrentUserInfo.UserID; string strLRR = GetValue(new RICH.Common.BM.T_PM_UserInfo.T_PM_UserInfoApplicationLogicBase().GetValueByFixCondition("UserNickName", app.LRR, "UserID")); if (!DataValidateManager.ValidateIsNull(strLRR)) { app.LRR = strLRR; } app.LRSJ = DateTime.Now; instanceT_BM_BMXXApplicationLogic.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_BMXXApplicationLogic.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 = ValidateHYBH(HYBH.SelectedValue, false, false); if (validateData.Result) { if (!validateData.IsNull) { appData.HYBH = Convert.ToString(validateData.Value.ToString()); } HYBH.BackColor = System.Drawing.Color.Empty; } else { HYBH.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = validateData.Result; } validateData = ValidateKCJG(KCJG.Text, false, false); if (validateData.Result) { if (!validateData.IsNull) { appData.KCJG = Convert.ToDouble(validateData.Value.ToString()); } KCJG.BackColor = System.Drawing.Color.Empty; } else { KCJG.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 = ValidateKCZK(KCZK.Text, false, false); if (validateData.Result) { if (!validateData.IsNull) { appData.KCZK = Convert.ToDouble(validateData.Value.ToString()); } KCZK.BackColor = System.Drawing.Color.Empty; } else { KCZK.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = validateData.Result; } validateData = ValidateSJJG(SJJG.Text, false, false); if (validateData.Result) { if (!validateData.IsNull) { appData.SJJG = Convert.ToDouble(validateData.Value.ToString()); } SJJG.BackColor = System.Drawing.Color.Empty; } else { SJJG.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = validateData.Result; } validateData = ValidateSKR(SKR.SelectedValue, false, false); if (validateData.Result) { if (!validateData.IsNull) { appData.SKR = Convert.ToString(validateData.Value.ToString()); } SKR.BackColor = System.Drawing.Color.Empty; } else { SKR.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = validateData.Result; } validateData = ValidateBMSJ(BMSJ.Text, false, false); if (validateData.Result) { if (!validateData.IsNull) { appData.BMSJ = Convert.ToDateTime(validateData.Value.ToString()); } BMSJ.BackColor = System.Drawing.Color.Empty; } else { BMSJ.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = validateData.Result; } validateData = ValidateBZ(BZ.Text, true, false); if (validateData.Result) { if (!validateData.IsNull) { appData.BZ = Convert.ToString(validateData.Value.ToString()); } BZ.BackColor = System.Drawing.Color.Empty; } else { BZ.BackColor = System.Drawing.Color.YellowGreen; MessageContent += @"<font color=""red"">" + validateData.Message + "</font>"; boolReturn = validateData.Result; } appData.LRR = CurrentUserInfo.UserID; appData.LRSJ = DateTime.Now; // 自动生成编号 T_BM_BMXXApplicationLogic instanceT_BM_BMXXApplicationLogic = (T_BM_BMXXApplicationLogic)CreateApplicationLogicInstance(typeof(T_BM_BMXXApplicationLogic)); appData.BMBH = instanceT_BM_BMXXApplicationLogic.AutoGenerateBMBH(appData); appData.LRR = CurrentUserInfo.UserID; appData.LRSJ = DateTime.Now; return(boolReturn); }