Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MesWeb.Model.T_ParameterCode model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_ParameterCode set ");
            strSql.Append("ParameterCode=@ParameterCode,");
            strSql.Append("ParameterType=@ParameterType,");
            strSql.Append("ParameterName=@ParameterName,");
            strSql.Append("ParameterUnitID=@ParameterUnitID,");
            strSql.Append("ParameterBit=@ParameterBit,");
            strSql.Append("Type=@Type");
            strSql.Append(" where ParameterCodeID=@ParameterCodeID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ParameterCode",   SqlDbType.Int,       4),
                new SqlParameter("@ParameterType",   SqlDbType.Int,       4),
                new SqlParameter("@ParameterName",   SqlDbType.NVarChar, 50),
                new SqlParameter("@ParameterUnitID", SqlDbType.Int,       4),
                new SqlParameter("@ParameterBit",    SqlDbType.Int,       4),
                new SqlParameter("@Type",            SqlDbType.Int,       4),
                new SqlParameter("@ParameterCodeID", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ParameterCode;
            parameters[1].Value = model.ParameterType;
            parameters[2].Value = model.ParameterName;
            parameters[3].Value = model.ParameterUnitID;
            parameters[4].Value = model.ParameterBit;
            parameters[5].Value = model.Type;
            parameters[6].Value = model.ParameterCodeID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        public JsonResult EditParamCode(MesWeb.Model.T_ParameterCode code)
        {
            log = LogFactory.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.FullName + ":" + MethodBase.GetCurrentMethod().Name);
            var bllParamCode = new MesWeb.BLL.T_ParameterCode();
            var retData      = new VM_Result_Data();

            try {
                if (bllParamCode.Update(code))
                {
                    retData.Code    = RESULT_CODE.OK;
                    retData.Content = "更新成功";
                }
                else
                {
                    retData.Content = "更新失败";
                    log.Error("更新参数失败");
                }
            } catch (Exception e) {
                log.Fatal("更新参数类型发生异常", e);
            }

            return(Json(retData));
        }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MesWeb.Model.T_ParameterCode model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_ParameterCode(");
            strSql.Append("ParameterCode,ParameterType,ParameterName,ParameterUnitID,ParameterBit,Type)");
            strSql.Append(" values (");
            strSql.Append("@ParameterCode,@ParameterType,@ParameterName,@ParameterUnitID,@ParameterBit,@Type)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ParameterCode",   SqlDbType.Int,       4),
                new SqlParameter("@ParameterType",   SqlDbType.Int,       4),
                new SqlParameter("@ParameterName",   SqlDbType.NVarChar, 50),
                new SqlParameter("@ParameterUnitID", SqlDbType.Int,       4),
                new SqlParameter("@ParameterBit",    SqlDbType.Int,       4),
                new SqlParameter("@Type",            SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ParameterCode;
            parameters[1].Value = model.ParameterType;
            parameters[2].Value = model.ParameterName;
            parameters[3].Value = model.ParameterUnitID;
            parameters[4].Value = model.ParameterBit;
            parameters[5].Value = model.Type;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MesWeb.Model.T_ParameterCode DataRowToModel(DataRow row)
 {
     MesWeb.Model.T_ParameterCode model = new MesWeb.Model.T_ParameterCode();
     if (row != null)
     {
         if (row["ParameterCodeID"] != null && row["ParameterCodeID"].ToString() != "")
         {
             model.ParameterCodeID = int.Parse(row["ParameterCodeID"].ToString());
         }
         if (row["ParameterCode"] != null && row["ParameterCode"].ToString() != "")
         {
             model.ParameterCode = int.Parse(row["ParameterCode"].ToString());
         }
         if (row["ParameterType"] != null && row["ParameterType"].ToString() != "")
         {
             model.ParameterType = int.Parse(row["ParameterType"].ToString());
         }
         if (row["ParameterName"] != null)
         {
             model.ParameterName = row["ParameterName"].ToString();
         }
         if (row["ParameterUnitID"] != null && row["ParameterUnitID"].ToString() != "")
         {
             model.ParameterUnitID = int.Parse(row["ParameterUnitID"].ToString());
         }
         if (row["ParameterBit"] != null && row["ParameterBit"].ToString() != "")
         {
             model.ParameterBit = int.Parse(row["ParameterBit"].ToString());
         }
         if (row["Type"] != null && row["Type"].ToString() != "")
         {
             model.Type = int.Parse(row["Type"].ToString());
         }
     }
     return(model);
 }
Пример #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MesWeb.Model.T_ParameterCode GetModel(int ParameterCodeID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ParameterCodeID,ParameterCode,ParameterType,ParameterName,ParameterUnitID,ParameterBit,Type from T_ParameterCode ");
            strSql.Append(" where ParameterCodeID=@ParameterCodeID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ParameterCodeID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ParameterCodeID;

            MesWeb.Model.T_ParameterCode model = new MesWeb.Model.T_ParameterCode();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #6
0
        protected VM_Fusioncharts_MSLine getMachineCPKMSLineData(int machineID, MesWeb.Model.T_ParameterCode code, int dataCount = 12)
        {
            var msLine             = new VM_Fusioncharts_MSLine();
            var bllParamData       = new MesWeb.BLL.T_CollectedDataParameters();
            var bllSensorParamCode = new MesWeb.BLL.T_SensorModule_T_ParameterCode();
            var bllParamUnit       = new MesWeb.BLL.T_ParameterUnit();
            var bllParamSet        = new MesWeb.BLL.T_ParametersCol();

            var dataList     = bllParamData.GetModelList("MachineID = " + machineID + "and ParameterCodeID = " + code.ParameterCodeID);
            var paramSetting = bllParamSet.GetModelList("ParameterCodeID = " + (int)code.ParameterCodeID).FirstOrDefault();
            var paramUnit    = bllParamUnit.GetModel((int)code.ParameterUnitID);

            var chart = new FusionChart {
                caption      = code.ParameterName,
                numberSuffix = paramUnit.ParameterUnitSymbol,
                yAxisName    = paramUnit.ParameterUnitName,
                xAxisName    = "时间"
            };

            var maxLine = new FusionLine {
                startvalue   = paramSetting.ParametersColMaxiumValue,
                displayvalue = "最大值",
            };
            var minLine = new FusionLine {
                startvalue   = paramSetting.ParametersColMiniumValue,
                displayvalue = "最小值",
            };
            var maxCPKLine = new FusionLine {
                startvalue   = "2.0",
                displayvalue = "CPK最大值"
            };
            var minCPKLine = new FusionLine {
                startvalue   = "0.2",
                displayvalue = "CPK最小值"
            };

            var trendline = new FusionTrendLine();

            trendline.line.Add(maxLine);
            trendline.line.Add(minLine);
            trendline.line.Add(maxCPKLine);
            trendline.line.Add(minCPKLine);
            var cpkDataSet    = new FusionMSDataset();
            var sensorDataSet = new FusionMSDataset();

            cpkDataSet.seriesname    = "CPK";
            sensorDataSet.seriesname = code.ParameterName;
            var categories = new FusionMSCategories();

            for (int i = 0; i < dataList.Count; i++)
            {
                var data = dataList[i];
                categories.category.Add(new FusionMSCategorie {
                    label = data.CollectedTime.ToString().Split(' ')[1]
                });
                sensorDataSet.data.Add(new MSlineValue {
                    value = float.Parse(data.CollectedValue).ToString("0.00")
                });
                cpkDataSet.data.Add(new MSlineValue {
                    value = GetCPKValue(code.ParameterCodeID, machineID).ToString("0.00")
                });
            }
            msLine.categories.Add(categories);
            msLine.chart = chart;
            msLine.trendlines.Add(trendline);
            msLine.dataset.Add(sensorDataSet);
            msLine.dataset.Add(cpkDataSet);
            return(msLine);
        }