/// <summary> /// 增加一条数据 /// </summary> public int Add(DNSABC.Model.DNSABC_Dns model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into DNSABC_Dns("); strSql.Append("ProductID,UserID,Domain,PASSWORD,StartTime,EndTime,isHost,isTtl,isMonitor,isGroupID,State,Remark,UpdateTime,CreateTime)"); strSql.Append(" values ("); strSql.Append("@ProductID,@UserID,@Domain,@PASSWORD,@StartTime,@EndTime,@isHost,@isTtl,@isMonitor,@isGroupID,@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("@StartTime", SqlDbType.DateTime), new SqlParameter("@EndTime", SqlDbType.DateTime), new SqlParameter("@isHost", SqlDbType.Int, 4), new SqlParameter("@isTtl", SqlDbType.Int, 4), new SqlParameter("@isMonitor", SqlDbType.Int, 4), new SqlParameter("@isGroupID", 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.StartTime; parameters[5].Value = model.EndTime; parameters[6].Value = model.isHost; parameters[7].Value = model.isTtl; parameters[8].Value = model.isMonitor; parameters[9].Value = model.isGroupID; parameters[10].Value = model.State; parameters[11].Value = model.Remark; parameters[12].Value = model.UpdateTime; parameters[13].Value = model.CreateTime; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private void ShowInfo(int Id) { DNSABC.BLL.DNSABC_Dns bll = new DNSABC.BLL.DNSABC_Dns(); DNSABC.Model.DNSABC_Dns model = bll.GetModel(Id); this.lblId.Text = model.Id.ToString(); this.lblProductID.Text = model.ProductID.ToString(); this.lblUserID.Text = model.UserID.ToString(); this.lblDomain.Text = model.Domain; this.lblPASSWORD.Text = model.PASSWORD; this.lblStartTime.Text = model.StartTime.ToString(); this.lblEndTime.Text = model.EndTime.ToString(); this.lblisHost.Text = model.isHost.ToString(); this.lblisTtl.Text = model.isTtl.ToString(); this.lblisMonitor.Text = model.isMonitor.ToString(); this.lblisGroupID.Text = model.isGroupID.ToString(); this.lblState.Text = model.State.ToString(); this.lblRemark.Text = model.Remark; this.lblUpdateTime.Text = model.UpdateTime.ToString(); this.lblCreateTime.Text = model.CreateTime.ToString(); }
/// <summary> /// 得到一个对象实体 /// </summary> public DNSABC.Model.DNSABC_Dns GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,ProductID,UserID,Domain,PASSWORD,StartTime,EndTime,isHost,isTtl,isMonitor,isGroupID,State,Remark,UpdateTime,CreateTime from DNSABC_Dns "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; DNSABC.Model.DNSABC_Dns model = new DNSABC.Model.DNSABC_Dns(); 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]["StartTime"] != null && ds.Tables[0].Rows[0]["StartTime"].ToString() != "") { model.StartTime = DateTime.Parse(ds.Tables[0].Rows[0]["StartTime"].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]["isTtl"] != null && ds.Tables[0].Rows[0]["isTtl"].ToString() != "") { model.isTtl = int.Parse(ds.Tables[0].Rows[0]["isTtl"].ToString()); } if (ds.Tables[0].Rows[0]["isMonitor"] != null && ds.Tables[0].Rows[0]["isMonitor"].ToString() != "") { model.isMonitor = int.Parse(ds.Tables[0].Rows[0]["isMonitor"].ToString()); } if (ds.Tables[0].Rows[0]["isGroupID"] != null && ds.Tables[0].Rows[0]["isGroupID"].ToString() != "") { model.isGroupID = int.Parse(ds.Tables[0].Rows[0]["isGroupID"].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); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DNSABC.Model.DNSABC_Dns model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update DNSABC_Dns set "); strSql.Append("ProductID=@ProductID,"); strSql.Append("UserID=@UserID,"); strSql.Append("Domain=@Domain,"); strSql.Append("PASSWORD=@PASSWORD,"); strSql.Append("StartTime=@StartTime,"); strSql.Append("EndTime=@EndTime,"); strSql.Append("isHost=@isHost,"); strSql.Append("isTtl=@isTtl,"); strSql.Append("isMonitor=@isMonitor,"); strSql.Append("isGroupID=@isGroupID,"); 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("@StartTime", SqlDbType.DateTime), new SqlParameter("@EndTime", SqlDbType.DateTime), new SqlParameter("@isHost", SqlDbType.Int, 4), new SqlParameter("@isTtl", SqlDbType.Int, 4), new SqlParameter("@isMonitor", SqlDbType.Int, 4), new SqlParameter("@isGroupID", 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.StartTime; parameters[5].Value = model.EndTime; parameters[6].Value = model.isHost; parameters[7].Value = model.isTtl; parameters[8].Value = model.isMonitor; parameters[9].Value = model.isGroupID; parameters[10].Value = model.State; parameters[11].Value = model.Remark; parameters[12].Value = model.UpdateTime; parameters[13].Value = model.CreateTime; parameters[14].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
protected 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(txtStartTime.Text)) { strErr += "服务开始时间格式错误!\\n"; } if (!PageValidate.IsDateTime(txtEndTime.Text)) { strErr += "服务结束时间格式错误!\\n"; } if (!PageValidate.IsNumber(txtisHost.Text)) { strErr += "主机个数 0表示主机个数不限制格式错误!\\n"; } if (!PageValidate.IsNumber(txtisTtl.Text)) { strErr += "最小TTL值 0表示TTL值不限制格式错误!\\n"; } if (!PageValidate.IsNumber(txtisMonitor.Text)) { strErr += "宕机检测个数 0表示无宕机检测功能格式错误!\\n"; } if (!PageValidate.IsNumber(txtisGroupID.Text)) { strErr += "服务器组ID 表示默认开通的服务器组格式错误!\\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 ProductID = int.Parse(this.txtProductID.Text); int UserID = int.Parse(this.txtUserID.Text); string Domain = this.txtDomain.Text; string PASSWORD = this.txtPASSWORD.Text; DateTime StartTime = DateTime.Parse(this.txtStartTime.Text); DateTime EndTime = DateTime.Parse(this.txtEndTime.Text); int isHost = int.Parse(this.txtisHost.Text); int isTtl = int.Parse(this.txtisTtl.Text); int isMonitor = int.Parse(this.txtisMonitor.Text); int isGroupID = int.Parse(this.txtisGroupID.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_Dns model = new DNSABC.Model.DNSABC_Dns(); model.ProductID = ProductID; model.UserID = UserID; model.Domain = Domain; model.PASSWORD = PASSWORD; model.StartTime = StartTime; model.EndTime = EndTime; model.isHost = isHost; model.isTtl = isTtl; model.isMonitor = isMonitor; model.isGroupID = isGroupID; model.State = State; model.Remark = Remark; model.UpdateTime = UpdateTime; model.CreateTime = CreateTime; DNSABC.BLL.DNSABC_Dns bll = new DNSABC.BLL.DNSABC_Dns(); bll.Add(model); ROYcms.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }