Exemple #1
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public long Add(ESMonitor.Model.ESHour model)
        {
            int rowsAffected;

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",           SqlDbType.Int,        8),
                new SqlParameter("@StatId",       SqlDbType.Int,        4),
                new SqlParameter("@TP",           SqlDbType.Float,      8),
                new SqlParameter("@DB",           SqlDbType.Float,      8),
                new SqlParameter("@UpdateTime",   SqlDbType.DateTime),
                new SqlParameter("@DataStatus",   SqlDbType.Char,       1),
                new SqlParameter("@ValidDataNum", SqlDbType.Int,        4),
                new SqlParameter("@DevId",        SqlDbType.Int,        4),
                new SqlParameter("@Country",      SqlDbType.VarChar,   20),
                new SqlParameter("@Pm25",         SqlDbType.Float,      8),
                new SqlParameter("@Pm100",        SqlDbType.Float, 8)
            };
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value     = model.StatId;
            parameters[2].Value     = model.TP;
            parameters[3].Value     = model.DB;
            parameters[4].Value     = model.UpdateTime;
            parameters[5].Value     = model.DataStatus;
            parameters[6].Value     = model.ValidDataNum;
            parameters[7].Value     = model.DevId;
            parameters[8].Value     = model.Country;
            parameters[9].Value     = model.Pm25;
            parameters[10].Value    = model.Pm100;
            DbHelperSQL.RunProcedure("T_ESHour_ADD", parameters, out rowsAffected);
            return((long)parameters[0].Value);
        }
Exemple #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ESMonitor.Model.ESHour DataRowToModel(DataRow row)
 {
     ESMonitor.Model.ESHour model = new ESMonitor.Model.ESHour();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = long.Parse(row["Id"].ToString());
         }
         if (row["StatId"] != null && row["StatId"].ToString() != "")
         {
             model.StatId = int.Parse(row["StatId"].ToString());
         }
         if (row["TP"] != null && row["TP"].ToString() != "")
         {
             model.TP = double.Parse(row["TP"].ToString());
         }
         if (row["DB"] != null && row["DB"].ToString() != "")
         {
             model.DB = double.Parse(row["DB"].ToString());
         }
         if (row["UpdateTime"] != null && row["UpdateTime"].ToString() != "")
         {
             model.UpdateTime = DateTime.Parse(row["UpdateTime"].ToString());
         }
         if (row["DevId"] != null && row["DevId"].ToString() != "")
         {
             model.DevId = int.Parse(row["DevId"].ToString());
         }
         if (row["Country"] != null)
         {
             model.Country = row["Country"].ToString();
         }
         if (row["DataStatus"] != null)
         {
             model.DataStatus = row["DataStatus"].ToString();
         }
         if (row["ValidDataNum"] != null && row["ValidDataNum"].ToString() != "")
         {
             model.ValidDataNum = int.Parse(row["ValidDataNum"].ToString());
         }
         if (row["DevId"] != null && row["DevId"].ToString() != "")
         {
             model.DevId = int.Parse(row["DevId"].ToString());
         }
         if (row["Country"] != null)
         {
             model.Country = row["Country"].ToString();
         }
         if (row["PM25"] != null)
         {
             model.Pm25 = double.Parse(row["PM25"].ToString());
         }
         if (row["PM100"] != null)
         {
             model.Pm100 = double.Parse(row["PM100"].ToString());
         }
     }
     return(model);
 }
Exemple #3
0
 private void ShowInfo(int Id)
 {
     ESMonitor.BLL.ESHour   bll   = new ESMonitor.BLL.ESHour();
     ESMonitor.Model.ESHour model = bll.GetModel(Id);
     this.lblId.Text            = model.Id.ToString();
     this.lblStatCode.Text      = model.StatCode;
     this.lblTP.Text            = model.TP.ToString();
     this.lblDB.Text            = model.DB.ToString();
     this.lblDatatime.Text      = model.Datatime.ToString();
     this.lblWindSpeed.Text     = model.WindSpeed.ToString();
     this.lblRain.Text          = model.Rain.ToString();
     this.lblWindDirection.Text = model.WindDirection.ToString();
     this.lblTemperature.Text   = model.Temperature.ToString();
     this.lblHumidity.Text      = model.Humidity.ToString();
     this.lblAirpressure.Text   = model.Airpressure.ToString();
     this.lblDataStatus.Text    = model.DataStatus;
     this.lblValidDataNum.Text  = model.ValidDataNum.ToString();
 }
Exemple #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ESMonitor.Model.ESHour GetModel(int Id)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.BigInt, 8)
            };
            parameters[0].Value = Id;

            ESMonitor.Model.ESHour model = new ESMonitor.Model.ESHour();
            DataSet ds = DbHelperSQL.RunProcedure("T_ESHour_GetModel", parameters, "ds");

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemple #5
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public bool Update(ESMonitor.Model.ESHour model)
        {
            int rowsAffected = 0;

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",           SqlDbType.Int,        8),
                new SqlParameter("@StatId",       SqlDbType.Int,        4),
                new SqlParameter("@TP",           SqlDbType.Float,      8),
                new SqlParameter("@DB",           SqlDbType.Float,      8),
                new SqlParameter("@UpdateTime",   SqlDbType.DateTime),
                new SqlParameter("@DataStatus",   SqlDbType.Char,       1),
                new SqlParameter("@ValidDataNum", SqlDbType.Int,        4),
                new SqlParameter("@DevId",        SqlDbType.Int,        4),
                new SqlParameter("@Country",      SqlDbType.VarChar,   20),
                new SqlParameter("@Pm25",         SqlDbType.Float,      8),
                new SqlParameter("@Pm100",        SqlDbType.Float, 8)
            };
            parameters[0].Value  = model.Id;
            parameters[1].Value  = model.StatId;
            parameters[2].Value  = model.TP;
            parameters[3].Value  = model.DB;
            parameters[4].Value  = model.UpdateTime;
            parameters[5].Value  = model.DataStatus;
            parameters[6].Value  = model.ValidDataNum;
            parameters[7].Value  = model.DevId;
            parameters[8].Value  = model.Country;
            parameters[9].Value  = model.Pm25;
            parameters[10].Value = model.Pm100;

            DbHelperSQL.RunProcedure("T_ESHour_Update", parameters, out rowsAffected);
            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtStatCode.Text.Trim().Length == 0)
            {
                strErr += "StatCode不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtTP.Text))
            {
                strErr += "TP格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtDB.Text))
            {
                strErr += "DB格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtDatatime.Text))
            {
                strErr += "Datatime格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtWindSpeed.Text))
            {
                strErr += "WindSpeed格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtRain.Text))
            {
                strErr += "Rain格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtWindDirection.Text))
            {
                strErr += "WindDirection格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtTemperature.Text))
            {
                strErr += "Temperature格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtHumidity.Text))
            {
                strErr += "Humidity格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtAirpressure.Text))
            {
                strErr += "Airpressure格式错误!\\n";
            }
            if (this.txtDataStatus.Text.Trim().Length == 0)
            {
                strErr += "DataStatus不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtValidDataNum.Text))
            {
                strErr += "ValidDataNum格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   StatCode      = this.txtStatCode.Text;
            decimal  TP            = decimal.Parse(this.txtTP.Text);
            decimal  DB            = decimal.Parse(this.txtDB.Text);
            DateTime Datatime      = DateTime.Parse(this.txtDatatime.Text);
            decimal  WindSpeed     = decimal.Parse(this.txtWindSpeed.Text);
            decimal  Rain          = decimal.Parse(this.txtRain.Text);
            decimal  WindDirection = decimal.Parse(this.txtWindDirection.Text);
            decimal  Temperature   = decimal.Parse(this.txtTemperature.Text);
            decimal  Humidity      = decimal.Parse(this.txtHumidity.Text);
            decimal  Airpressure   = decimal.Parse(this.txtAirpressure.Text);
            string   DataStatus    = this.txtDataStatus.Text;
            int      ValidDataNum  = int.Parse(this.txtValidDataNum.Text);

            ESMonitor.Model.ESHour model = new ESMonitor.Model.ESHour();
            model.StatCode      = StatCode;
            model.TP            = TP;
            model.DB            = DB;
            model.Datatime      = Datatime;
            model.WindSpeed     = WindSpeed;
            model.Rain          = Rain;
            model.WindDirection = WindDirection;
            model.Temperature   = Temperature;
            model.Humidity      = Humidity;
            model.Airpressure   = Airpressure;
            model.DataStatus    = DataStatus;
            model.ValidDataNum  = ValidDataNum;

            ESMonitor.BLL.ESHour bll = new ESMonitor.BLL.ESHour();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }