/// <summary>
        /// 页面信息检查
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        bool CheckVal(out string msg)
        {
            bool flag = false;

            msg = "";

            string sID = ViewState["said"].ToString();

            txt_SACode.Value = txt_SACode.Value.Trim();
            txt_SAName.Value = txt_SAName.Value.Trim();

            /////////////////////////////////////////////////////////////////////
            //
            if (txt_SACode.Value.Equals(""))
            {
                msg += "代码不能为空!\r\n";
                flag = true;
                return(flag);
            }
            else
            {
                if (!Regex.IsMatch(txt_SACode.Value, @"^\w+$"))
                {
                    msg += "代码只能由数字、字母和下划线组成!\r\n";
                    flag = true;
                    return(flag);
                }

                if (string.IsNullOrWhiteSpace(sID))
                {
                    if (KPI_SATagDal.CodeExist(txt_SACode.Value, sID) ||
                        ALLDal.CodeExist(txt_SACode.Value, ""))
                    {
                        msg += "命名已存在,请检查!\r\n";
                        flag = true;
                        return(flag);
                    }
                }
                else
                {
                    if (KPI_SATagDal.CodeExist(txt_SACode.Value, sID) ||
                        ALLDal.CodeExist(txt_SACode.Value, sID))
                    {
                        msg += "命名已存在,请检查!\r\n";
                        flag = true;
                        return(flag);
                    }
                }
            }

            if (txt_SAName.Value.Equals(""))
            {
                msg += "名称不能为空!\r\n";
                flag = true;
                return(flag);
            }


            return(flag);
        }
Example #2
0
        protected void gvCurve_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            HtmlInputHidden key = (HtmlInputHidden)gvCurve.Rows[e.RowIndex].Cells[0].FindControl("curveid");

            string sID    = key.Value;
            string sCode  = ((TextBox)(gvCurve.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim();
            string sName  = ((TextBox)(gvCurve.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim();
            string sDesc  = ((TextBox)(gvCurve.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim();
            string sGroup = ((TextBox)(gvCurve.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim();
            string sMonth = ((TextBox)(gvCurve.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString().Trim();
            string sValid = ((DropDownList)(gvCurve.Rows[e.RowIndex].Cells[6].FindControl("ddlValid"))).SelectedValue;

            string msg = "";

            if (sCode == "")
            {
                msg += "代码不能为空!\r\n";
            }

            if (sName == "")
            {
                msg += "名称不能为空!\r\n";
            }

            if (msg != "")
            {
                MessageBox.popupClientMessage(this.Page, msg);
                return;
            }

            //代码是否重复
            if (CurveTagDal.CodeExist(sCode, sID) || ALLDal.CodeExist(sCode, sID))
            {
                MessageBox.popupClientMessage(this.Page, "已存在相同的代码!");
                return;
            }

            //更新
            CurveTagEntity ote = new CurveTagEntity();

            ote.CurveID      = sID;
            ote.CurveCode    = sCode;
            ote.CurveName    = sName;
            ote.CurveDesc    = sDesc;
            ote.CurveGroup   = sGroup;
            ote.CurveMonth   = sMonth;
            ote.CurveIndex   = 100;
            ote.CurveIsValid = int.Parse(sValid);

            ote.CurveModifyTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");

            if (CurveTagDal.Update(ote))
            {
                MessageBox.popupClientMessage(this.Page, "编辑成功!", "call();");
            }
            else
            {
                MessageBox.popupClientMessage(this.Page, "编辑错误!", "call();");
            }

            gvCurve.EditIndex = -1;

            BindValues();
        }
        /// <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);
        }
Example #4
0
        protected bool ImportFromExcelToCreateAndModify(DataSet ds)
        {
            try
            {
                System.Data.DataTable dt = ds.Tables[0];

                int  nAll      = dt.Rows.Count;
                int  nCreate   = 0;
                int  nModify   = 0;
                int  nNotValid = 0;
                bool bExist    = false;

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    if (dr["SelectX"].ToString().ToLower() == "x")
                    {
                        string RealCode = dr["RealCode"].ToString().Trim();

                        //判断是否存在
                        bExist = KPI_RealTagDal.CodeExist(RealCode, "");

                        string keyid = PageControl.GetGuid();
                        if (bExist)
                        {
                            keyid = KPI_RealTagDal.GetID(RealCode);

                            //MessageBox.popupClientMessage(this.Page, " 该机组的输出标签已存在!", "call();");
                            //nExist += 1;
                            //continue;
                        }
                        else
                        {
                            //其他表存在也不能创建
                            if (ALLDal.CodeExist(RealCode, ""))
                            {
                                nNotValid += 1;
                                continue;
                            }
                        }

                        //main tag
                        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();

                        if (bExist)
                        {
                            KPI_RealTagDal.Update(mEntity);
                            nModify += 1;
                        }
                        else
                        {
                            KPI_RealTagDal.Insert(mEntity);
                            nCreate += 1;
                        }
                    }
                }

                string strInfor = "标签点总数为:{0}个, 创建成功:{1}个, 修改成功: {2}个,其他表存在Code: {3}个。";
                strInfor = string.Format(strInfor, nAll, nCreate, nModify, nNotValid);

                MessageBox.popupClientMessage(this.Page, strInfor, "call();");

                return(true);
            }
            catch (Exception ee)
            {
                //
                MessageBox.popupClientMessage(this.Page, ee.Message, "call();");

                return(false);
            }
        }
Example #5
0
        protected bool ImportFromExcelToCreateAndModify(DataSet ds)
        {
            string strKPIError = "";

            try
            {
                System.Data.DataTable dt = ds.Tables[0];

                int  nAll      = dt.Rows.Count;
                int  nCreate   = 0;
                int  nModify   = 0;
                int  nNotValid = 0;
                bool bExist    = false;

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    if (dr["SelectX"].ToString().ToLower() == "x")
                    {
                        string ECCode = dr["ECCode"].ToString().Trim();

                        strKPIError = ECCode;

                        //判断是否存在
                        bExist = ECTagDal.CodeExist(ECCode, "");

                        string keyid = PageControl.GetGuid();
                        if (bExist)
                        {
                            keyid = ECTagDal.GetECIDByCode(ECCode);

                            //MessageBox.popupClientMessage(this.Page, " 该机组的输出标签已存在!", "call();");
                            //nExist += 1;
                            //continue;
                        }
                        else
                        {
                            //其他表存在也不能创建
                            if (ALLDal.CodeExist(ECCode, ""))
                            {
                                nNotValid += 1;
                                continue;
                            }
                        }

                        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;


                        if (bExist)
                        {
                            ECTagDal.Update(mEntity);
                            nModify += 1;
                        }
                        else
                        {
                            ECTagDal.Insert(mEntity);
                            nCreate += 1;
                        }
                    }
                }

                string strInfor = "标签点总数为:{0}个, 创建成功:{1}个, 修改成功: {2}个,其他表存在Code: {3}个。";
                strInfor = string.Format(strInfor, nAll, nCreate, nModify, nNotValid);

                MessageBox.popupClientMessage(this.Page, strInfor, "call();");

                return(true);
            }
            catch (Exception ee)
            {
                //
                MessageBox.popupClientMessage(this.Page, strKPIError + ": " + ee.Message, "call();");

                return(false);
            }
        }
Example #6
0
        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();
        }