protected void btnAddCycle_Click(object sender, EventArgs e) { int index = CycleDal.CycleIDCounts(); string sID = PageControl.GetGuid(); CycleEntity ote = new CycleEntity(); ote.CycleID = sID; ote.CycleName = "TX"; ote.CycleDesc = "10分钟"; ote.CycleValue = 10; ote.CycleNote = "分钟计算周期"; ote.CycleCreateTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); ote.CycleModifyTime = ote.CycleCreateTime; if (CycleDal.Insert(ote)) { //MessageBox.popupClientMessage(this.Page, "添加成功!", "call();"); } else { MessageBox.popupClientMessage(this.Page, "添加错误!", "call();"); } gvCycle.EditIndex = index; BindGrid(); }
void BindGrid() { DataTable dt = CycleDal.GetSearchList(); gvCycle.DataSource = dt; gvCycle.DataBind(); }
protected void gvCycle_RowCommand(object sender, GridViewCommandEventArgs e) { string Cycleid = e.CommandArgument.ToString(); if (e.CommandName == "dataDelete") { if (CycleDal.DeleteCycle(Cycleid)) { MessageBox.popupClientMessage(this.Page, "删除成功!", "call();"); BindGrid(); } else { MessageBox.popupClientMessage(this.Page, "删除错误!", "call();"); } } }
////////////////////////////////////////////////////////////////////////////// #region Define Functions /// <summary> /// /// </summary> /// <returns></returns> public bool KPIInitialVar() { try { //是否取服务器时间 bTimeMode = KPI_SystemDal.GetKPITimeMode() == 1 ? true : false; //偏置时间 nOffset = KPI_SystemDal.GetKPIOffset(); //初始所有List<> ltUnits = KPI_UnitDal.GetValidEntity(); ltSeqs = KPI_SeqDal.GetValidEntity(); ltKpis = KpiDal.GetValidEntity(); //实时、手录、曲线指标 ltReals = KPI_RealTagDal.GetAllEntity(); ltInputs = KPI_InputTagDal.GetAllEntity(); ltCurves = CurveTagDal.GetAllEntity(); //计算周期 List <CycleEntity> ltCYs = CycleDal.GetAllEntity(); dicCYs = new Dictionary <string, CycleEntity>(); foreach (CycleEntity cye in ltCYs) { dicCYs[cye.CycleID] = cye; } //经济指标 ltECs = ECTagDal.GetValidEntity(); ltXLines = ECTagDal.GetAllXLineEntity(); ltScores = ECTagDal.GetAllScoreEntity(); ///////////////////////////////////////////////////////////////// //安全指标 dicUnitStatus = new Dictionary <string, bool>(); dicUnitPEs = new Dictionary <string, double>(); dicTags = new Dictionary <string, double>(); dicRealTag = new Dictionary <string, RealTag>(); } catch (Exception ex) { LogUtil.LogMessage(ex.ToString()); return(false); } return(true); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { btnApply.Attributes.Add("onclick", "setDivPos('Lay1');Lay1.style.visibility='';progress_update();"); //机组信息 DataTable dt = KPI_UnitDal.GetUnits(""); foreach (DataRow dr in dt.Rows) { ddl_UnitID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString())); } //设备信息 dt = KPI_SeqDal.GetSeqs(); foreach (DataRow dr in dt.Rows) { ddl_SeqID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString())); } //指标信息 dt = KpiDal.GetKpis(); foreach (DataRow dr in dt.Rows) { ddl_KpiID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString())); } //单位信息 dt = EngunitDal.GetEngunits(); foreach (DataRow dr in dt.Rows) { ddl_EngunitID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString())); } //周期信息 dt = CycleDal.GetCycles(); foreach (DataRow dr in dt.Rows) { ddl_CycleID.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString())); } //网页集信息 //信息在KPI_Constant表中 dt = KPI_ConstantDal.GetECWebs(); foreach (DataRow dr in dt.Rows) { ddl_ECWeb.Items.Add(new ListItem(dr["Name"].ToString(), dr["Value"].ToString())); } //判断是否新建或编辑 if (Request.QueryString["ecid"] != null) { ViewState["ecid"] = Request.QueryString["ecid"].ToString(); BindValues(); } else { //添加 ViewState["ecid"] = ""; // ddl_ECIsValid.Value = "1"; ddl_ECIsCalc.Value = "1"; ddl_ECIsDisplay.Value = "1"; ddl_ECIsTotal.Value = "1"; SetECCodeAndName(); txt_ECIndex.Value = "100"; txt_ECWeight.Value = "1"; txt_ECDenom.Value = "1"; txt_ECCalcClass.Value = "1"; } btnApply.Visible = true; } }
protected void gvCycle_RowUpdating(object sender, GridViewUpdateEventArgs e) { string keyid = ((HtmlInputHidden)(gvCycle.Rows[e.RowIndex].Cells[0].FindControl("Cycleid"))).Value; string eName = ((TextBox)(gvCycle.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim().ToUpper(); string eDesc = ((TextBox)(gvCycle.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim(); string eValue = ((TextBox)(gvCycle.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim(); string eNote = ((TextBox)(gvCycle.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim(); string msg = ""; if (eName == "") { msg += "名称不能为空!\r\n"; } if (!Regex.IsMatch(eValue, "^[0-9]+$")) { msg += "周期只能为数字!\r\n"; } if ((int.Parse(eValue) <= 60 && 60 % int.Parse(eValue) != 0) || (int.Parse(eValue) > 60 && int.Parse(eValue) % 60 != 0)) { msg += "周期只能为分钟的倍数!\r\n"; } if ((eName != "TN" || eName != "TD") && double.Parse(eValue) == 0) { msg += "除TN,TD外,计算周期不能为0"; } if (msg != "") { MessageBox.popupClientMessage(this.Page, msg); return; } if (CycleDal.CycleNameExists(eName, keyid)) { MessageBox.popupClientMessage(this.Page, "该周期已存在!", "call();"); return; } CycleEntity mEntity = new CycleEntity(); mEntity.CycleID = keyid; mEntity.CycleName = eName; mEntity.CycleDesc = eDesc; mEntity.CycleValue = int.Parse(eValue); mEntity.CycleNote = eNote; //mEntity.CycleCreateTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); mEntity.CycleModifyTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); if (!CycleDal.Update(mEntity)) { MessageBox.popupClientMessage(this.Page, "编辑错误!", "call();"); } else { MessageBox.popupClientMessage(this.Page, "编辑成功!", "call();"); gvCycle.EditIndex = -1; BindGrid(); } }
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); } }