protected bool ImportFromExcelToDelete(DataSet ds) { try { System.Data.DataTable dt = ds.Tables[0]; int nAll = dt.Rows.Count; int nDelete = 0; int nEmpty = 0; foreach (System.Data.DataRow dr in dt.Rows) { if (dr["SelectX"].ToString().ToLower() == "x") { string ECCode = dr["ECCode"].ToString().Trim(); //判断是否存在 if (!ECTagDal.CodeExist(ECCode, "")) { //MessageBox.popupClientMessage(this.Page, " 该机组的输出标签已存在!", "call();"); nEmpty += 1; continue; } else { //main tag ECTagEntity mEntity = new ECTagEntity(); mEntity.ECID = ECTagDal.GetECIDByCode(ECCode); ECTagDal.Delete(mEntity); nDelete += 1; } } } string strInfor = "标签点总数为:{0}个, 删除成功:{1}个,空标签点: {2}个。"; strInfor = string.Format(strInfor, nAll, nDelete, nEmpty); MessageBox.popupClientMessage(this.Page, strInfor, "call();"); return(true); } catch (Exception ee) { // MessageBox.popupClientMessage(this.Page, ee.Message, "call();"); return(false); } }
/// <summary> /// 页面信息检查 /// </summary> /// <param name="msg"></param> /// <returns></returns> bool CheckVal(out string msg) { bool flag = false; msg = ""; string sID = ViewState["ecid"].ToString(); txt_ECCode.Value = txt_ECCode.Value.Trim(); txt_ECName.Value = txt_ECName.Value.Trim(); txt_ECIndex.Value = txt_ECIndex.Value.Trim(); txt_ECMaxValue.Value = txt_ECMaxValue.Value.Trim(); txt_ECMinValue.Value = txt_ECMaxValue.Value.Trim(); txt_ECWeight.Value = txt_ECWeight.Value.Trim(); txt_ECDenom.Value = txt_ECDenom.Value.Trim(); txt_ECCalcClass.Value = txt_ECCalcClass.Value.Trim(); ///////////////////////////////////////////////////////////////////// // if (txt_ECCode.Value.Equals("")) { msg += "代码不能为空!\r\n"; flag = true; return(flag); } else { if (!Regex.IsMatch(txt_ECCode.Value, "[A-Za-z0-9_]*$")) { msg += "代码只能由数字、字母和下划线组成!\r\n"; flag = true; return(flag); } //在SQL表中是否存在 if (ECTagDal.CodeExist(txt_ECCode.Value, sID) || ALLDal.CodeExist(txt_ECCode.Value, sID)) { msg += "命名已存在,请检查!\r\n"; flag = true; return(flag); } } if (txt_ECName.Value.Equals("")) { msg += "名称不能为空!\r\n"; flag = true; return(flag); } if (txt_ECIndex.Value.Equals("")) { msg += "序号不能为空!\r\n"; flag = true; return(flag); } else { if (!Regex.IsMatch(txt_ECIndex.Value, "[0-9]*$")) { msg += "序号只能由数字组成!\r\n"; flag = true; return(flag); } } if (!txt_ECMaxValue.Value.Equals("")) { if (!Regex.IsMatch(txt_ECMaxValue.Value, @"^\d*[.]?\d*$")) { msg += "最值只能为数字组成!\r\n"; } } if (!txt_ECMinValue.Value.Equals("")) { if (!Regex.IsMatch(txt_ECMinValue.Value, @"^\d*[.]?\d*$")) { msg += "最值只能为数字组成!\r\n"; } } if (txt_ECWeight.Value.Equals("")) { msg += "权重不能为空!\r\n"; flag = true; return(flag); } else { if (!Regex.IsMatch(txt_ECWeight.Value, @"^\d*[.]?\d*$")) { msg += "权重只能为数字组成!\r\n"; } } if (txt_ECDenom.Value.Equals("")) { msg += "分母不能为空!\r\n"; flag = true; return(flag); } else { double dout = 0; if (!double.TryParse(txt_ECDenom.Value, out dout) || dout == 0) { msg += "分母格式不正确且不能为0!\r\n"; } } if (txt_ECCalcClass.Value.Equals("")) { msg += "计算等级不能为空!\r\n"; flag = true; return(flag); } else { if (!Regex.IsMatch(txt_ECCalcClass.Value, "[0-9]*$")) { msg += "计算等级只能由数字组成!\r\n"; flag = true; return(flag); } } return(flag); }
protected bool ImportFromExcelToModify(DataSet ds) { string strError = ""; try { System.Data.DataTable dt = ds.Tables[0]; int nAll = dt.Rows.Count; int nModify = 0; int nNoExist = 0; foreach (System.Data.DataRow dr in dt.Rows) { if (dr["SelectX"].ToString().ToLower() == "x") { string ECCode = dr["ECCode"].ToString().Trim(); strError = ECCode; //判断是否存在 if (!ECTagDal.CodeExist(ECCode, "")) { //MessageBox.popupClientMessage(this.Page, " 该机组的输出标签已存在!", "call();"); nNoExist += 1; continue; } //main tag string keyid = ECTagDal.GetECIDByCode(ECCode); ECTagEntity mEntity = new ECTagEntity(); mEntity.ECID = keyid; string UnitName = dr["UnitName"].ToString().Trim(); mEntity.UnitID = KPI_UnitDal.GetUnitID(UnitName); string SeqName = dr["SeqName"].ToString().Trim(); mEntity.SeqID = KPI_SeqDal.GetSeqID(SeqName); string KpiName = dr["KpiName"].ToString().Trim(); mEntity.KpiID = KpiDal.GetKpiID(KpiName); string EngunitName = dr["EngunitName"].ToString().Trim(); mEntity.EngunitID = EngunitDal.GetEngunitID(EngunitName); string CycleName = dr["CycleName"].ToString().Trim(); mEntity.CycleID = CycleDal.GetCycleID(CycleName); mEntity.ECCode = dr["ECCode"].ToString().Trim(); mEntity.ECName = dr["ECName"].ToString().Trim(); mEntity.ECDesc = dr["ECDesc"].ToString().Trim(); mEntity.ECIndex = int.Parse(dr["ECIndex"].ToString().Trim()); mEntity.ECWeb = dr["ECWeb"].ToString().Trim(); mEntity.ECIsValid = int.Parse(dr["ECIsValid"].ToString().Trim()); mEntity.ECIsCalc = int.Parse(dr["ECIsCalc"].ToString().Trim()); mEntity.ECIsAsses = int.Parse(dr["ECIsAsses"].ToString().Trim()); mEntity.ECIsZero = int.Parse(dr["ECIsZero"].ToString().Trim()); mEntity.ECIsDisplay = int.Parse(dr["ECIsDisplay"].ToString().Trim()); mEntity.ECIsTotal = int.Parse(dr["ECIsTotal"].ToString().Trim()); mEntity.ECDesign = dr["ECDesign"].ToString().Trim(); mEntity.ECOptimal = dr["ECOptimal"].ToString().Trim(); if (dr["ECMaxValue"].ToString().Trim() != "") { mEntity.ECMaxValue = decimal.Parse(dr["ECMaxValue"].ToString().Trim()); } if (dr["ECMinValue"].ToString().Trim() != "") { mEntity.ECMinValue = decimal.Parse(dr["ECMinValue"].ToString().Trim()); } mEntity.ECWeight = decimal.Parse(dr["ECWeight"].ToString().Trim()); mEntity.ECCalcClass = int.Parse(dr["ECCalcClass"].ToString().Trim()); mEntity.ECFilterExp = dr["ECFilterExp"].ToString().Trim(); mEntity.ECCalcExp = dr["ECCalcExp"].ToString().Trim(); mEntity.ECCalcDesc = dr["ECCalcDesc"].ToString().Trim(); mEntity.ECIsSnapshot = int.Parse(dr["ECIsSnapshot"].ToString().Trim()); mEntity.ECXLineType = int.Parse(dr["ECXLineType"].ToString().Trim()); mEntity.ECXLineGetType = int.Parse(dr["ECXLineGetType"].ToString().Trim()); mEntity.ECXLineXRealTag = dr["ECXLineXRealTag"].ToString().Trim(); mEntity.ECXLineYRealTag = dr["ECXLineYRealTag"].ToString().Trim(); mEntity.ECXLineZRealTag = dr["ECXLineZRealTag"].ToString().Trim(); mEntity.ECXLineXYZ = dr["ECXLineXYZ"].ToString().Trim(); mEntity.ECScoreExp = dr["ECScoreExp"].ToString().Trim(); mEntity.ECCurveGroup = dr["ECCurveGroup"].ToString().Trim(); mEntity.ECIsSort = int.Parse(dr["ECIsSort"].ToString().Trim()); mEntity.ECType = int.Parse(dr["ECType"].ToString().Trim()); mEntity.ECSort = int.Parse(dr["ECSort"].ToString().Trim()); mEntity.ECScore = dr["ECScore"].ToString().Trim(); mEntity.ECExExp = dr["ECExExp"].ToString().Trim(); mEntity.ECExScore = dr["ECExScore"].ToString().Trim(); mEntity.ECNote = dr["ECNote"].ToString().Trim(); mEntity.ECCreateTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); mEntity.ECModifyTime = mEntity.ECCreateTime; ECTagDal.Update(mEntity); nModify += 1; } } string strInfor = "标签点总数为:{0}个, 修改成功:{1}个,不存在标签点: {2}个。"; strInfor = string.Format(strInfor, nAll, nModify, nNoExist); MessageBox.popupClientMessage(this.Page, strInfor, "call();"); return(true); } catch (Exception ee) { // MessageBox.popupClientMessage(this.Page, strError + ": " + ee.Message, "call();"); return(false); } }