Beispiel #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(WebDemo.Model.WebDemo.Hosts model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Hosts(");
            strSql.Append("CollectorID,HostID,HostName,HostAddr,Remark,flag,LimitNum,HostComType,HostType,HostRDate,DownloadFlag,PowerType,HostNo,HostLimitNum,IsRelay,IsDownMeterType)");
            strSql.Append(" values (");
            strSql.Append("@CollectorID,@HostID,@HostName,@HostAddr,@Remark,@flag,@LimitNum,@HostComType,@HostType,@HostRDate,@DownloadFlag,@PowerType,@HostNo,@HostLimitNum,@IsRelay,@IsDownMeterType)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CollectorID",     SqlDbType.Int,       4),
                new SqlParameter("@HostID",          SqlDbType.Int,       4),
                new SqlParameter("@HostName",        SqlDbType.VarChar,  50),
                new SqlParameter("@HostAddr",        SqlDbType.VarChar,  50),
                new SqlParameter("@Remark",          SqlDbType.VarChar, 500),
                new SqlParameter("@flag",            SqlDbType.Int,       4),
                new SqlParameter("@LimitNum",        SqlDbType.Int,       4),
                new SqlParameter("@HostComType",     SqlDbType.Int,       4),
                new SqlParameter("@HostType",        SqlDbType.Int,       4),
                new SqlParameter("@HostRDate",       SqlDbType.VarChar,  10),
                new SqlParameter("@DownloadFlag",    SqlDbType.Int,       4),
                new SqlParameter("@PowerType",       SqlDbType.Int,       4),
                new SqlParameter("@HostNo",          SqlDbType.Int,       4),
                new SqlParameter("@HostLimitNum",    SqlDbType.Int,       4),
                new SqlParameter("@IsRelay",         SqlDbType.Int,       4),
                new SqlParameter("@IsDownMeterType", SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.CollectorID;
            parameters[1].Value  = model.HostID;
            parameters[2].Value  = model.HostName;
            parameters[3].Value  = model.HostAddr;
            parameters[4].Value  = model.Remark;
            parameters[5].Value  = model.flag;
            parameters[6].Value  = model.LimitNum;
            parameters[7].Value  = model.HostComType;
            parameters[8].Value  = model.HostType;
            parameters[9].Value  = model.HostRDate;
            parameters[10].Value = model.DownloadFlag;
            parameters[11].Value = model.PowerType;
            parameters[12].Value = model.HostNo;
            parameters[13].Value = model.HostLimitNum;
            parameters[14].Value = model.IsRelay;
            parameters[15].Value = model.IsDownMeterType;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 private void ShowInfo(int HostID)
 {
     WebDemo.BLL.WebDemo.Hosts   bll   = new WebDemo.BLL.WebDemo.Hosts();
     WebDemo.Model.WebDemo.Hosts model = bll.GetModel(HostID);
     this.lblCollectorID.Text     = model.CollectorID.ToString();
     this.lblHostID.Text          = model.HostID.ToString();
     this.lblHostName.Text        = model.HostName;
     this.lblHostAddr.Text        = model.HostAddr;
     this.lblRemark.Text          = model.Remark;
     this.lblflag.Text            = model.flag.ToString();
     this.lblLimitNum.Text        = model.LimitNum.ToString();
     this.lblHostComType.Text     = model.HostComType.ToString();
     this.lblHostType.Text        = model.HostType.ToString();
     this.lblHostRDate.Text       = model.HostRDate;
     this.lblDownloadFlag.Text    = model.DownloadFlag.ToString();
     this.lblPowerType.Text       = model.PowerType.ToString();
     this.lblHostNo.Text          = model.HostNo.ToString();
     this.lblHostLimitNum.Text    = model.HostLimitNum.ToString();
     this.lblIsRelay.Text         = model.IsRelay.ToString();
     this.lblIsDownMeterType.Text = model.IsDownMeterType.ToString();
 }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebDemo.Model.WebDemo.Hosts GetModel(int HostID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 CollectorID,HostID,HostName,HostAddr,Remark,flag,LimitNum,HostComType,HostType,HostRDate,DownloadFlag,PowerType,HostNo,HostLimitNum,IsRelay,IsDownMeterType from Hosts ");
            strSql.Append(" where HostID=@HostID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@HostID", SqlDbType.Int, 4)
            };
            parameters[0].Value = HostID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtCollectorID.Text))
            {
                strErr += "集中器编号格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtHostID.Text))
            {
                strErr += "楼宇主机编号格式错误!\\n";
            }
            if (this.txtHostName.Text.Trim().Length == 0)
            {
                strErr += "楼宇主机名称不能为空!\\n";
            }
            if (this.txtHostAddr.Text.Trim().Length == 0)
            {
                strErr += "地址不能为空!\\n";
            }
            if (this.txtRemark.Text.Trim().Length == 0)
            {
                strErr += "备注信息不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtflag.Text))
            {
                strErr += "flag格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtLimitNum.Text))
            {
                strErr += "LimitNum格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtHostComType.Text))
            {
                strErr += "HostComType格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtHostType.Text))
            {
                strErr += "HostType格式错误!\\n";
            }
            if (this.txtHostRDate.Text.Trim().Length == 0)
            {
                strErr += "HostRDate不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtDownloadFlag.Text))
            {
                strErr += "DownloadFlag格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtPowerType.Text))
            {
                strErr += "PowerType格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtHostNo.Text))
            {
                strErr += "HostNo格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtHostLimitNum.Text))
            {
                strErr += "HostLimitNum格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtIsRelay.Text))
            {
                strErr += "IsRelay格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtIsDownMeterType.Text))
            {
                strErr += "IsDownMeterType格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    CollectorID     = int.Parse(this.txtCollectorID.Text);
            int    HostID          = int.Parse(this.txtHostID.Text);
            string HostName        = this.txtHostName.Text;
            string HostAddr        = this.txtHostAddr.Text;
            string Remark          = this.txtRemark.Text;
            int    flag            = int.Parse(this.txtflag.Text);
            int    LimitNum        = int.Parse(this.txtLimitNum.Text);
            int    HostComType     = int.Parse(this.txtHostComType.Text);
            int    HostType        = int.Parse(this.txtHostType.Text);
            string HostRDate       = this.txtHostRDate.Text;
            int    DownloadFlag    = int.Parse(this.txtDownloadFlag.Text);
            int    PowerType       = int.Parse(this.txtPowerType.Text);
            int    HostNo          = int.Parse(this.txtHostNo.Text);
            int    HostLimitNum    = int.Parse(this.txtHostLimitNum.Text);
            int    IsRelay         = int.Parse(this.txtIsRelay.Text);
            int    IsDownMeterType = int.Parse(this.txtIsDownMeterType.Text);

            WebDemo.Model.WebDemo.Hosts model = new WebDemo.Model.WebDemo.Hosts();
            model.CollectorID     = CollectorID;
            model.HostID          = HostID;
            model.HostName        = HostName;
            model.HostAddr        = HostAddr;
            model.Remark          = Remark;
            model.flag            = flag;
            model.LimitNum        = LimitNum;
            model.HostComType     = HostComType;
            model.HostType        = HostType;
            model.HostRDate       = HostRDate;
            model.DownloadFlag    = DownloadFlag;
            model.PowerType       = PowerType;
            model.HostNo          = HostNo;
            model.HostLimitNum    = HostLimitNum;
            model.IsRelay         = IsRelay;
            model.IsDownMeterType = IsDownMeterType;

            WebDemo.BLL.WebDemo.Hosts bll = new WebDemo.BLL.WebDemo.Hosts();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Beispiel #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebDemo.Model.WebDemo.Hosts DataRowToModel(DataRow row)
 {
     WebDemo.Model.WebDemo.Hosts model = new WebDemo.Model.WebDemo.Hosts();
     if (row != null)
     {
         if (row["CollectorID"] != null && row["CollectorID"].ToString() != "")
         {
             model.CollectorID = int.Parse(row["CollectorID"].ToString());
         }
         if (row["HostID"] != null && row["HostID"].ToString() != "")
         {
             model.HostID = int.Parse(row["HostID"].ToString());
         }
         if (row["HostName"] != null)
         {
             model.HostName = row["HostName"].ToString();
         }
         if (row["HostAddr"] != null)
         {
             model.HostAddr = row["HostAddr"].ToString();
         }
         if (row["Remark"] != null)
         {
             model.Remark = row["Remark"].ToString();
         }
         if (row["flag"] != null && row["flag"].ToString() != "")
         {
             model.flag = int.Parse(row["flag"].ToString());
         }
         if (row["LimitNum"] != null && row["LimitNum"].ToString() != "")
         {
             model.LimitNum = int.Parse(row["LimitNum"].ToString());
         }
         if (row["HostComType"] != null && row["HostComType"].ToString() != "")
         {
             model.HostComType = int.Parse(row["HostComType"].ToString());
         }
         if (row["HostType"] != null && row["HostType"].ToString() != "")
         {
             model.HostType = int.Parse(row["HostType"].ToString());
         }
         if (row["HostRDate"] != null)
         {
             model.HostRDate = row["HostRDate"].ToString();
         }
         if (row["DownloadFlag"] != null && row["DownloadFlag"].ToString() != "")
         {
             model.DownloadFlag = int.Parse(row["DownloadFlag"].ToString());
         }
         if (row["PowerType"] != null && row["PowerType"].ToString() != "")
         {
             model.PowerType = int.Parse(row["PowerType"].ToString());
         }
         if (row["HostNo"] != null && row["HostNo"].ToString() != "")
         {
             model.HostNo = int.Parse(row["HostNo"].ToString());
         }
         if (row["HostLimitNum"] != null && row["HostLimitNum"].ToString() != "")
         {
             model.HostLimitNum = int.Parse(row["HostLimitNum"].ToString());
         }
         if (row["IsRelay"] != null && row["IsRelay"].ToString() != "")
         {
             model.IsRelay = int.Parse(row["IsRelay"].ToString());
         }
         if (row["IsDownMeterType"] != null && row["IsDownMeterType"].ToString() != "")
         {
             model.IsDownMeterType = int.Parse(row["IsDownMeterType"].ToString());
         }
     }
     return(model);
 }
Beispiel #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebDemo.Model.WebDemo.Hosts model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Hosts set ");
            strSql.Append("CollectorID=@CollectorID,");
            strSql.Append("HostName=@HostName,");
            strSql.Append("HostAddr=@HostAddr,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("flag=@flag,");
            strSql.Append("LimitNum=@LimitNum,");
            strSql.Append("HostComType=@HostComType,");
            strSql.Append("HostType=@HostType,");
            strSql.Append("HostRDate=@HostRDate,");
            strSql.Append("DownloadFlag=@DownloadFlag,");
            strSql.Append("PowerType=@PowerType,");
            strSql.Append("HostNo=@HostNo,");
            strSql.Append("HostLimitNum=@HostLimitNum,");
            strSql.Append("IsRelay=@IsRelay,");
            strSql.Append("IsDownMeterType=@IsDownMeterType");
            strSql.Append(" where HostID=@HostID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CollectorID",     SqlDbType.Int,       4),
                new SqlParameter("@HostName",        SqlDbType.VarChar,  50),
                new SqlParameter("@HostAddr",        SqlDbType.VarChar,  50),
                new SqlParameter("@Remark",          SqlDbType.VarChar, 500),
                new SqlParameter("@flag",            SqlDbType.Int,       4),
                new SqlParameter("@LimitNum",        SqlDbType.Int,       4),
                new SqlParameter("@HostComType",     SqlDbType.Int,       4),
                new SqlParameter("@HostType",        SqlDbType.Int,       4),
                new SqlParameter("@HostRDate",       SqlDbType.VarChar,  10),
                new SqlParameter("@DownloadFlag",    SqlDbType.Int,       4),
                new SqlParameter("@PowerType",       SqlDbType.Int,       4),
                new SqlParameter("@HostNo",          SqlDbType.Int,       4),
                new SqlParameter("@HostLimitNum",    SqlDbType.Int,       4),
                new SqlParameter("@IsRelay",         SqlDbType.Int,       4),
                new SqlParameter("@IsDownMeterType", SqlDbType.Int,       4),
                new SqlParameter("@HostID",          SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.CollectorID;
            parameters[1].Value  = model.HostName;
            parameters[2].Value  = model.HostAddr;
            parameters[3].Value  = model.Remark;
            parameters[4].Value  = model.flag;
            parameters[5].Value  = model.LimitNum;
            parameters[6].Value  = model.HostComType;
            parameters[7].Value  = model.HostType;
            parameters[8].Value  = model.HostRDate;
            parameters[9].Value  = model.DownloadFlag;
            parameters[10].Value = model.PowerType;
            parameters[11].Value = model.HostNo;
            parameters[12].Value = model.HostLimitNum;
            parameters[13].Value = model.IsRelay;
            parameters[14].Value = model.IsDownMeterType;
            parameters[15].Value = model.HostID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }