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 RealCode = dr["RealCode"].ToString().Trim(); //判断是否存在 if (!KPI_RealTagDal.CodeExist(RealCode, "")) { //MessageBox.popupClientMessage(this.Page, " 该机组的输出标签已存在!", "call();"); nEmpty += 1; continue; } else { //main tag //string RealID = KPI_RealTagDal.GetRealID(RealCode); KPI_RealTagEntity mEntity = new KPI_RealTagEntity(); mEntity.RealID = KPI_RealTagDal.GetID(RealCode); KPI_RealTagDal.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); } }
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 void btnAddReal_Click(object sender, EventArgs e) { if (ddlUnitID.SelectedValue == "ALL") { MessageBox.popupClientMessage(this.Page, "请选择具体机组!", "call();"); return; } string UnitID = ddlUnitID.SelectedValue.Trim(); int index = KPI_RealTagDal.IDCounts(UnitID); string sID = PageControl.GetGuid(); KPI_RealTagEntity ote = new KPI_RealTagEntity(); ote.RealID = sID; ote.UnitID = UnitID; ote.RealCode = "InputCode"; ote.RealDesc = "Input DEsc"; ote.RealEngunit = "Input Engunit"; ote.RealSnapshot = "0"; ote.RealSort = "1"; ote.RealDisplay = "0"; ote.RealXYZ = "0"; ote.RealNote = ""; ote.RealCreateTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); ote.RealModifyTime = ote.RealCreateTime; if (KPI_RealTagDal.Insert(ote)) { //MessageBox.popupClientMessage(this.Page, "添加成功!", "call();"); } else { MessageBox.popupClientMessage(this.Page, "添加错误!", "call();"); } gvReal.EditIndex = index; BindReal(); }
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(); }