protected void btnApply_Click(object sender, EventArgs e) { if (gvTable.Rows.Count <= 0) { return; } for (int i = 0; i < gvTable.Rows.Count; i++) { KPI_RealTagEntity csE = new KPI_RealTagEntity(); csE.RealID = gvTable.Rows[i]["RealID"].ToString(); csE.RealDisplay = (10 + i).ToString(); KPI_RealTagDal.Update(csE); } MessageBox.popupClientMessage(this.Page, "排序成功!", "call();"); }
protected bool ImportFromExcelToModify(DataSet ds) { 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 RealCode = dr["RealCode"].ToString().Trim(); //判断是否存在 if (!KPI_RealTagDal.CodeExist(RealCode, "")) { //MessageBox.popupClientMessage(this.Page, " 该机组的输出标签已存在!", "call();"); nNoExist += 1; continue; } //main tag string keyid = KPI_RealTagDal.GetID(RealCode); KPI_RealTagEntity mEntity = new KPI_RealTagEntity(); mEntity.RealID = keyid; mEntity.UnitID = KPI_UnitDal.GetUnitID(dr["UnitName"].ToString().Trim()); mEntity.RealCode = RealCode; mEntity.RealDesc = dr["RealDesc"].ToString().Trim(); mEntity.RealEngunit = dr["RealEngunit"].ToString().Trim(); string sv = dr["RealMaxValue"].ToString().Trim(); if (sv != "") { mEntity.RealMaxValue = decimal.Parse(sv); } sv = dr["RealMinValue"].ToString().Trim(); if (sv != "") { mEntity.RealMinValue = decimal.Parse(sv); } mEntity.RealSnapshot = dr["RealSnapshot"].ToString().Trim(); mEntity.RealSort = dr["RealSort"].ToString().Trim(); mEntity.RealDisplay = dr["RealDisplay"].ToString().Trim(); mEntity.RealXYZ = dr["RealXYZ"].ToString().Trim(); mEntity.RealNote = dr["RealNote"].ToString().Trim(); KPI_RealTagDal.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, ee.Message, "call();"); return(false); } }
protected void gvReal_RowUpdating(object sender, GridViewUpdateEventArgs e) { HtmlInputHidden key = (HtmlInputHidden)gvReal.Rows[e.RowIndex].Cells[0].FindControl("realid"); string sID = key.Value; string sCode = ((TextBox)(gvReal.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim(); string sDesc = ((TextBox)(gvReal.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim(); string sEngunit = ((TextBox)(gvReal.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim(); string sMax = ((TextBox)(gvReal.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString().Trim(); string sMin = ((TextBox)(gvReal.Rows[e.RowIndex].Cells[6].Controls[0])).Text.ToString().Trim(); string sSnapshot = ((DropDownList)(gvReal.Rows[e.RowIndex].Cells[7].FindControl("ddlSnapshot"))).SelectedValue; string sSort = ((DropDownList)(gvReal.Rows[e.RowIndex].Cells[8].FindControl("ddlSort"))).SelectedValue; string sDisplay = ((DropDownList)(gvReal.Rows[e.RowIndex].Cells[9].FindControl("ddlDisplay"))).SelectedValue; string sXYZ = ((DropDownList)(gvReal.Rows[e.RowIndex].Cells[10].FindControl("ddlXYZ"))).SelectedValue; string sNote = ((TextBox)(gvReal.Rows[e.RowIndex].Cells[11].Controls[0])).Text.ToString().Trim(); string msg = ""; if (sCode == "") { msg += "名称不能为空!\r\n"; } //判断double格式 if (sMax != "" && !Regex.IsMatch(sMax, @"^\d*[.]?\d*$")) { msg += "最值只能为空或数字组成!\r\n"; } //判断double格式 if (sMin != "" && !Regex.IsMatch(sMin, @"^\d*[.]?\d*$")) { msg += "最值只能为空或数字组成!\r\n"; } if (msg != "") { MessageBox.popupClientMessage(this.Page, msg); return; } //代码是否重复 if (KPI_RealTagDal.CodeExist(sCode, sID) || ALLDal.CodeExist(sCode, sID)) { MessageBox.popupClientMessage(this.Page, "已存在相同的标签!"); return; } //更新 KPI_RealTagEntity ote = new KPI_RealTagEntity(); ote.RealID = sID; ote.RealCode = sCode; ote.RealDesc = sDesc; ote.RealEngunit = sEngunit; if (sMax != "") { ote.RealMaxValue = decimal.Parse(sMax); } if (sMin != "") { ote.RealMinValue = decimal.Parse(sMin); } ote.RealSnapshot = sSnapshot; ote.RealSort = sSort; //if (sDisplay == "0") ote.RealDisplay = sDisplay; ote.RealXYZ = sXYZ; ote.RealNote = sNote; ote.RealModifyTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); if (KPI_RealTagDal.Update(ote)) { MessageBox.popupClientMessage(this.Page, "编辑成功!", "call();"); } else { MessageBox.popupClientMessage(this.Page, "编辑错误!", "call();"); } gvReal.EditIndex = -1; BindReal(); }