/// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DNSABC.Model.DNSABC_ProductModelCdn model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into DNSABC_ProductModelCdn(");
            strSql.Append("ProductID,isHost,isConnection,isBandwidth,Remark)");
            strSql.Append(" values (");
            strSql.Append("@ProductID,@isHost,@isConnection,@isBandwidth,@Remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductID",    SqlDbType.Int,     4),
                new SqlParameter("@isHost",       SqlDbType.Int,     4),
                new SqlParameter("@isConnection", SqlDbType.Int,     4),
                new SqlParameter("@isBandwidth",  SqlDbType.Int,     4),
                new SqlParameter("@Remark",       SqlDbType.VarChar, 500)
            };
            parameters[0].Value = model.ProductID;
            parameters[1].Value = model.isHost;
            parameters[2].Value = model.isConnection;
            parameters[3].Value = model.isBandwidth;
            parameters[4].Value = model.Remark;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #2
0
 private void ShowInfo(int Id)
 {
     DNSABC.BLL.DNSABC_ProductModelCdn   bll   = new DNSABC.BLL.DNSABC_ProductModelCdn();
     DNSABC.Model.DNSABC_ProductModelCdn model = bll.GetModel(Id);
     this.lblId.Text           = model.Id.ToString();
     this.lblProductID.Text    = model.ProductID.ToString();
     this.lblisHost.Text       = model.isHost.ToString();
     this.lblisConnection.Text = model.isConnection.ToString();
     this.lblisBandwidth.Text  = model.isBandwidth.ToString();
     this.lblRemark.Text       = model.Remark;
 }
예제 #3
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtProductID.Text))
            {
                strErr += "编号ID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtisHost.Text))
            {
                strErr += "主机个数 0表示主机个数不限制格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtisConnection.Text))
            {
                strErr += "连接数 0表示连接数不限制格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtisBandwidth.Text))
            {
                strErr += "带宽 0表示带宽不限制格式错误!\\n";
            }
            if (this.txtRemark.Text.Trim().Length == 0)
            {
                strErr += "备注不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    Id           = int.Parse(this.lblId.Text);
            int    ProductID    = int.Parse(this.txtProductID.Text);
            int    isHost       = int.Parse(this.txtisHost.Text);
            int    isConnection = int.Parse(this.txtisConnection.Text);
            int    isBandwidth  = int.Parse(this.txtisBandwidth.Text);
            string Remark       = this.txtRemark.Text;


            DNSABC.Model.DNSABC_ProductModelCdn model = new DNSABC.Model.DNSABC_ProductModelCdn();
            model.Id           = Id;
            model.ProductID    = ProductID;
            model.isHost       = isHost;
            model.isConnection = isConnection;
            model.isBandwidth  = isBandwidth;
            model.Remark       = Remark;

            DNSABC.BLL.DNSABC_ProductModelCdn bll = new DNSABC.BLL.DNSABC_ProductModelCdn();
            bll.Update(model);
            ROYcms.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DNSABC.Model.DNSABC_ProductModelCdn GetModel(int ProductID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,ProductID,isHost,isConnection,isBandwidth,Remark from DNSABC_ProductModelCdn ");
            strSql.Append(" where ProductID=@ProductID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ProductID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"] != null && ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProductID"] != null && ds.Tables[0].Rows[0]["ProductID"].ToString() != "")
                {
                    model.ProductID = int.Parse(ds.Tables[0].Rows[0]["ProductID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["isHost"] != null && ds.Tables[0].Rows[0]["isHost"].ToString() != "")
                {
                    model.isHost = int.Parse(ds.Tables[0].Rows[0]["isHost"].ToString());
                }
                if (ds.Tables[0].Rows[0]["isConnection"] != null && ds.Tables[0].Rows[0]["isConnection"].ToString() != "")
                {
                    model.isConnection = int.Parse(ds.Tables[0].Rows[0]["isConnection"].ToString());
                }
                if (ds.Tables[0].Rows[0]["isBandwidth"] != null && ds.Tables[0].Rows[0]["isBandwidth"].ToString() != "")
                {
                    model.isBandwidth = int.Parse(ds.Tables[0].Rows[0]["isBandwidth"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Remark"] != null && ds.Tables[0].Rows[0]["Remark"].ToString() != "")
                {
                    model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DNSABC.Model.DNSABC_ProductModelCdn model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update DNSABC_ProductModelCdn set ");
            strSql.Append("ProductID=@ProductID,");
            strSql.Append("isHost=@isHost,");
            strSql.Append("isConnection=@isConnection,");
            strSql.Append("isBandwidth=@isBandwidth,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where ProductID=@ProductID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductID",    SqlDbType.Int,       4),
                new SqlParameter("@isHost",       SqlDbType.Int,       4),
                new SqlParameter("@isConnection", SqlDbType.Int,       4),
                new SqlParameter("@isBandwidth",  SqlDbType.Int,       4),
                new SqlParameter("@Remark",       SqlDbType.VarChar, 500),
                new SqlParameter("@Id",           SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ProductID;
            parameters[1].Value = model.isHost;
            parameters[2].Value = model.isConnection;
            parameters[3].Value = model.isBandwidth;
            parameters[4].Value = model.Remark;
            parameters[5].Value = model.ProductID;

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

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