예제 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DNSABC.Model.DNSABC_Cdn model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into DNSABC_Cdn(");
            strSql.Append("ProductID,UserID,Domain,PASSWORD,StarTime,EndTime,isHost,isConnection,isBandwidth,State,Remark,UpdateTime,CreateTime)");
            strSql.Append(" values (");
            strSql.Append("@ProductID,@UserID,@Domain,@PASSWORD,@StarTime,@EndTime,@isHost,@isConnection,@isBandwidth,@State,@Remark,@UpdateTime,@CreateTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductID",    SqlDbType.Int,         4),
                new SqlParameter("@UserID",       SqlDbType.Int,         4),
                new SqlParameter("@Domain",       SqlDbType.VarChar,   100),
                new SqlParameter("@PASSWORD",     SqlDbType.VarChar,    50),
                new SqlParameter("@StarTime",     SqlDbType.DateTime),
                new SqlParameter("@EndTime",      SqlDbType.DateTime),
                new SqlParameter("@isHost",       SqlDbType.Int,         4),
                new SqlParameter("@isConnection", SqlDbType.Int,         4),
                new SqlParameter("@isBandwidth",  SqlDbType.Int,         4),
                new SqlParameter("@State",        SqlDbType.Int,         4),
                new SqlParameter("@Remark",       SqlDbType.VarChar,   500),
                new SqlParameter("@UpdateTime",   SqlDbType.DateTime),
                new SqlParameter("@CreateTime",   SqlDbType.DateTime)
            };
            parameters[0].Value  = model.ProductID;
            parameters[1].Value  = model.UserID;
            parameters[2].Value  = model.Domain;
            parameters[3].Value  = model.PASSWORD;
            parameters[4].Value  = model.StarTime;
            parameters[5].Value  = model.EndTime;
            parameters[6].Value  = model.isHost;
            parameters[7].Value  = model.isConnection;
            parameters[8].Value  = model.isBandwidth;
            parameters[9].Value  = model.State;
            parameters[10].Value = model.Remark;
            parameters[11].Value = model.UpdateTime;
            parameters[12].Value = model.CreateTime;

            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_Cdn   bll   = new DNSABC.BLL.DNSABC_Cdn();
     DNSABC.Model.DNSABC_Cdn model = bll.GetModel(Id);
     this.lblId.Text           = model.Id.ToString();
     this.txtProductID.Text    = model.ProductID.ToString();
     this.txtUserID.Text       = model.UserID.ToString();
     this.txtDomain.Text       = model.Domain;
     this.txtPASSWORD.Text     = model.PASSWORD;
     this.txtStarTime.Text     = model.StarTime.ToString();
     this.txtEndTime.Text      = model.EndTime.ToString();
     this.txtisHost.Text       = model.isHost.ToString();
     this.txtisConnection.Text = model.isConnection.ToString();
     this.txtisBandwidth.Text  = model.isBandwidth.ToString();
     this.txtState.Text        = model.State.ToString();
     this.txtRemark.Text       = model.Remark;
     this.txtUpdateTime.Text   = model.UpdateTime.ToString();
     this.txtCreateTime.Text   = model.CreateTime.ToString();
 }
예제 #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DNSABC.Model.DNSABC_Cdn GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,ProductID,UserID,Domain,PASSWORD,StarTime,EndTime,isHost,isConnection,isBandwidth,State,Remark,UpdateTime,CreateTime from DNSABC_Cdn ");
            strSql.Append(" where ProductID=@ProductID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductID", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            DNSABC.Model.DNSABC_Cdn model = new DNSABC.Model.DNSABC_Cdn();
            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]["UserID"] != null && ds.Tables[0].Rows[0]["UserID"].ToString() != "")
                {
                    model.UserID = int.Parse(ds.Tables[0].Rows[0]["UserID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Domain"] != null && ds.Tables[0].Rows[0]["Domain"].ToString() != "")
                {
                    model.Domain = ds.Tables[0].Rows[0]["Domain"].ToString();
                }
                if (ds.Tables[0].Rows[0]["PASSWORD"] != null && ds.Tables[0].Rows[0]["PASSWORD"].ToString() != "")
                {
                    model.PASSWORD = ds.Tables[0].Rows[0]["PASSWORD"].ToString();
                }
                if (ds.Tables[0].Rows[0]["StarTime"] != null && ds.Tables[0].Rows[0]["StarTime"].ToString() != "")
                {
                    model.StarTime = DateTime.Parse(ds.Tables[0].Rows[0]["StarTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EndTime"] != null && ds.Tables[0].Rows[0]["EndTime"].ToString() != "")
                {
                    model.EndTime = DateTime.Parse(ds.Tables[0].Rows[0]["EndTime"].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]["State"] != null && ds.Tables[0].Rows[0]["State"].ToString() != "")
                {
                    model.State = int.Parse(ds.Tables[0].Rows[0]["State"].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();
                }
                if (ds.Tables[0].Rows[0]["UpdateTime"] != null && ds.Tables[0].Rows[0]["UpdateTime"].ToString() != "")
                {
                    model.UpdateTime = DateTime.Parse(ds.Tables[0].Rows[0]["UpdateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CreateTime"] != null && ds.Tables[0].Rows[0]["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DNSABC.Model.DNSABC_Cdn model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update DNSABC_Cdn set ");
            strSql.Append("ProductID=@ProductID,");
            strSql.Append("UserID=@UserID,");
            strSql.Append("Domain=@Domain,");
            strSql.Append("PASSWORD=@PASSWORD,");
            strSql.Append("StarTime=@StarTime,");
            strSql.Append("EndTime=@EndTime,");
            strSql.Append("isHost=@isHost,");
            strSql.Append("isConnection=@isConnection,");
            strSql.Append("isBandwidth=@isBandwidth,");
            strSql.Append("State=@State,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("UpdateTime=@UpdateTime,");
            strSql.Append("CreateTime=@CreateTime");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductID",    SqlDbType.Int,         4),
                new SqlParameter("@UserID",       SqlDbType.Int,         4),
                new SqlParameter("@Domain",       SqlDbType.VarChar,   100),
                new SqlParameter("@PASSWORD",     SqlDbType.VarChar,    50),
                new SqlParameter("@StarTime",     SqlDbType.DateTime),
                new SqlParameter("@EndTime",      SqlDbType.DateTime),
                new SqlParameter("@isHost",       SqlDbType.Int,         4),
                new SqlParameter("@isConnection", SqlDbType.Int,         4),
                new SqlParameter("@isBandwidth",  SqlDbType.Int,         4),
                new SqlParameter("@State",        SqlDbType.Int,         4),
                new SqlParameter("@Remark",       SqlDbType.VarChar,   500),
                new SqlParameter("@UpdateTime",   SqlDbType.DateTime),
                new SqlParameter("@CreateTime",   SqlDbType.DateTime),
                new SqlParameter("@Id",           SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.ProductID;
            parameters[1].Value  = model.UserID;
            parameters[2].Value  = model.Domain;
            parameters[3].Value  = model.PASSWORD;
            parameters[4].Value  = model.StarTime;
            parameters[5].Value  = model.EndTime;
            parameters[6].Value  = model.isHost;
            parameters[7].Value  = model.isConnection;
            parameters[8].Value  = model.isBandwidth;
            parameters[9].Value  = model.State;
            parameters[10].Value = model.Remark;
            parameters[11].Value = model.UpdateTime;
            parameters[12].Value = model.CreateTime;
            parameters[13].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #5
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtProductID.Text))
            {
                strErr += "产品ID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtUserID.Text))
            {
                strErr += "用户ID格式错误!\\n";
            }
            if (this.txtDomain.Text.Trim().Length == 0)
            {
                strErr += "域名 域名是唯一的不能为空!\\n";
            }
            if (this.txtPASSWORD.Text.Trim().Length == 0)
            {
                strErr += "域名密码 随机生成w3e4r2r6r6t4不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtStarTime.Text))
            {
                strErr += "注册时间格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtEndTime.Text))
            {
                strErr += "到期时间格式错误!\\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 (!PageValidate.IsNumber(txtState.Text))
            {
                strErr += "解析状态 0为停用格式错误!\\n";
            }
            if (this.txtRemark.Text.Trim().Length == 0)
            {
                strErr += "备注不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtUpdateTime.Text))
            {
                strErr += "更新时间格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtCreateTime.Text))
            {
                strErr += "创建时间格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      Id           = int.Parse(this.lblId.Text);
            int      ProductID    = int.Parse(this.txtProductID.Text);
            int      UserID       = int.Parse(this.txtUserID.Text);
            string   Domain       = this.txtDomain.Text;
            string   PASSWORD     = this.txtPASSWORD.Text;
            DateTime StarTime     = DateTime.Parse(this.txtStarTime.Text);
            DateTime EndTime      = DateTime.Parse(this.txtEndTime.Text);
            int      isHost       = int.Parse(this.txtisHost.Text);
            int      isConnection = int.Parse(this.txtisConnection.Text);
            int      isBandwidth  = int.Parse(this.txtisBandwidth.Text);
            int      State        = int.Parse(this.txtState.Text);
            string   Remark       = this.txtRemark.Text;
            DateTime UpdateTime   = DateTime.Parse(this.txtUpdateTime.Text);
            DateTime CreateTime   = DateTime.Parse(this.txtCreateTime.Text);


            DNSABC.Model.DNSABC_Cdn model = new DNSABC.Model.DNSABC_Cdn();
            model.Id           = Id;
            model.ProductID    = ProductID;
            model.UserID       = UserID;
            model.Domain       = Domain;
            model.PASSWORD     = PASSWORD;
            model.StarTime     = StarTime;
            model.EndTime      = EndTime;
            model.isHost       = isHost;
            model.isConnection = isConnection;
            model.isBandwidth  = isBandwidth;
            model.State        = State;
            model.Remark       = Remark;
            model.UpdateTime   = UpdateTime;
            model.CreateTime   = CreateTime;

            DNSABC.BLL.DNSABC_Cdn bll = new DNSABC.BLL.DNSABC_Cdn();
            bll.Update(model);
            ROYcms.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }