Esempio n. 1
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public bool Update(ESMonitor.Model.ESMin model)
        {
            int rowsAffected = 0;

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",            SqlDbType.BigInt,     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("@WindSpeed",     SqlDbType.Float,      8),
                new SqlParameter("@Rain",          SqlDbType.Float,      8),
                new SqlParameter("@WindDirection", SqlDbType.Float,      8),
                new SqlParameter("@Temperature",   SqlDbType.Float,      8),
                new SqlParameter("@Humidity",      SqlDbType.Float,      8),
                new SqlParameter("@Airpressure",   SqlDbType.Float,      8),
                new SqlParameter("@DataStatus",    SqlDbType.Char,       1),
                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.WindSpeed;
            parameters[6].Value  = model.Rain;
            parameters[7].Value  = model.WindDirection;
            parameters[8].Value  = model.Temperature;
            parameters[9].Value  = model.Humidity;
            parameters[10].Value = model.Airpressure;
            parameters[11].Value = model.DataStatus;
            parameters[12].Value = model.DevId;
            parameters[13].Value = model.Country;
            parameters[14].Value = model.Pm25;
            parameters[15].Value = model.Pm100;

            DbHelperSQL.RunProcedure("T_ESMin_Update", parameters, out rowsAffected);
            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
 private void ShowInfo(int Id)
 {
     ESMonitor.BLL.ESMin   bll   = new ESMonitor.BLL.ESMin();
     ESMonitor.Model.ESMin 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;
 }
Esempio n. 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ESMonitor.Model.ESMin GetModel(long Id)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.BigInt, 8)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 4
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 (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;

            ESMonitor.Model.ESMin model = new ESMonitor.Model.ESMin();
            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;

            ESMonitor.BLL.ESMin bll = new ESMonitor.BLL.ESMin();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Esempio n. 5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ESMonitor.Model.ESMin DataRowToModel(DataRow row)
 {
     ESMonitor.Model.ESMin model = new ESMonitor.Model.ESMin();
     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["WindSpeed"] != null && row["WindSpeed"].ToString() != "")
         {
             model.WindSpeed = double.Parse(row["WindSpeed"].ToString());
         }
         if (row["Rain"] != null && row["Rain"].ToString() != "")
         {
             model.Rain = double.Parse(row["Rain"].ToString());
         }
         if (row["WindDirection"] != null && row["WindDirection"].ToString() != "")
         {
             model.WindDirection = double.Parse(row["WindDirection"].ToString());
         }
         if (row["Temperature"] != null && row["Temperature"].ToString() != "")
         {
             model.Temperature = double.Parse(row["Temperature"].ToString());
         }
         if (row["Humidity"] != null && row["Humidity"].ToString() != "")
         {
             model.Humidity = double.Parse(row["Humidity"].ToString());
         }
         if (row["Airpressure"] != null && row["Airpressure"].ToString() != "")
         {
             model.Airpressure = double.Parse(row["Airpressure"].ToString());
         }
         if (row["DataStatus"] != null)
         {
             model.DataStatus = row["DataStatus"].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);
 }