Exemple #1
0
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <returns></returns>
        bool Insert(string ecid)
        {
            ECTagEntity mEntity = new ECTagEntity();

            mEntity.ECID = ecid;
            //mEntity.UnitID = ddl_UnitID.SelectedValue;
            //mEntity.SeqID = ddl_SeqID.Value.Trim();
            //mEntity.KpiID = ddl_KpiID.SelectedValue;
            //mEntity.EngunitID = ddl_EngunitID.Value.Trim();
            //mEntity.CycleID = ddl_CycleID.Value.Trim();

            //mEntity.ECIsValid = int.Parse(ddl_ECIsValid.Value);
            //mEntity.ECIsCalc = int.Parse(ddl_ECIsCalc.Value);
            //mEntity.ECIsDisplay = int.Parse(ddl_ECIsDisplay.Value);
            //mEntity.ECIsTotal = int.Parse(ddl_ECIsTotal.Value);

            //mEntity.ECCode = txt_ECCode.Value.Trim();
            //mEntity.ECName = txt_ECName.Value.Trim();
            //mEntity.ECDesc = txt_ECDesc.Value.Trim();
            //mEntity.ECIndex = int.Parse(txt_ECIndex.Value.Trim());
            //mEntity.ECWeb = ddl_ECWeb.Value;

            ////
            //mEntity.ECDesign = txt_ECDesign.Value;
            //mEntity.ECOptimal = txt_ECOptimal.Value;
            //mEntity.ECMaxValue = int.Parse(txt_ECMaxValue.Value.Trim());
            //mEntity.ECMinValue = int.Parse(txt_ECMinValue.Value.Trim());
            //mEntity.ECWeight = int.Parse(txt_ECWeight.Value.Trim());

            //mEntity.ECNote = txt_ECNote.Value.Trim();
            //mEntity.ECCreateTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
            //mEntity.ECModifyTime = mEntity.ECCreateTime;

            return(ECTagDal.Insert(mEntity));
        }
        /// <summary>
        /// 插入数据
        /// </summary>
        /// <returns></returns>
        bool Insert(string ecid)
        {
            //
            //插入时更新所有的字段
            //
            ECTagEntity mEntity = new ECTagEntity();

            mEntity.ECID      = ecid;
            mEntity.UnitID    = ddl_UnitID.SelectedValue;
            mEntity.SeqID     = ddl_SeqID.Value.Trim();
            mEntity.KpiID     = ddl_KpiID.SelectedValue;
            mEntity.EngunitID = ddl_EngunitID.Value.Trim();
            mEntity.CycleID   = ddl_CycleID.Value.Trim();

            mEntity.ECCode    = txt_ECCode.Value.Trim();
            mEntity.ECName    = txt_ECName.Value.Trim();
            mEntity.ECDesc    = txt_ECDesc.Value.Trim();
            mEntity.ECIndex   = int.Parse(txt_ECIndex.Value);
            mEntity.ECWeb     = ddl_ECWeb.Value;
            mEntity.ECIsValid = int.Parse(ddl_ECIsValid.Value);

            mEntity.ECIsCalc    = int.Parse(ddl_ECIsCalc.Value);
            mEntity.ECIsAsses   = int.Parse(ddl_ECIsAsses.Value);
            mEntity.ECIsZero    = int.Parse(ddl_ECIsZero.Value);
            mEntity.ECIsDisplay = int.Parse(ddl_ECIsDisplay.Value);
            mEntity.ECIsTotal   = int.Parse(ddl_ECIsTotal.Value);
            mEntity.ECDesign    = txt_ECDesign.Value;

            mEntity.ECOptimal = txt_ECOptimal.Value;
            if (txt_ECMaxValue.Value != "")
            {
                mEntity.ECMaxValue = decimal.Parse(txt_ECMaxValue.Value);
            }
            if (txt_ECMinValue.Value != "")
            {
                mEntity.ECMinValue = decimal.Parse(txt_ECMinValue.Value);
            }
            mEntity.ECWeight    = decimal.Parse(txt_ECWeight.Value.Trim());
            mEntity.ECDenom     = decimal.Parse(txt_ECDenom.Value.Trim());
            mEntity.ECCalcClass = int.Parse(txt_ECCalcClass.Value.Trim());
            mEntity.ECFilterExp = "";

            mEntity.ECCalcExp       = "";
            mEntity.ECCalcDesc      = "";
            mEntity.ECIsSnapshot    = 0;
            mEntity.ECXLineType     = 0;
            mEntity.ECXLineGetType  = 0;
            mEntity.ECXLineXRealTag = "";

            mEntity.ECXLineYRealTag = "";
            mEntity.ECXLineZRealTag = "";
            mEntity.ECXLineXYZ      = "";
            mEntity.ECScoreExp      = "";
            mEntity.ECCurveGroup    = "";
            mEntity.ECIsSort        = 0;
            mEntity.ECType          = 0;

            mEntity.ECSort       = 0;
            mEntity.ECScore      = "";
            mEntity.ECExExp      = "";
            mEntity.ECExScore    = "";
            mEntity.ECNote       = txt_ECNote.Value.Trim();
            mEntity.ECCreateTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");

            mEntity.ECModifyTime = mEntity.ECCreateTime;

            return(ECTagDal.Insert(mEntity));
        }
        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);
            }
        }