private void ShowInfo(int NationID) { Maticsoft.BLL.Nation bll = new Maticsoft.BLL.Nation(); Maticsoft.Model.Nation model = bll.GetModel(NationID); this.lblNationID.Text = model.NationID.ToString(); this.lblN_Name.Text = model.N_Name; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.Nation model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Nation set "); strSql.Append("N_Name=@N_Name"); strSql.Append(" where NationID=@NationID"); SqlParameter[] parameters = { new SqlParameter("@N_Name", SqlDbType.NVarChar, 50), new SqlParameter("@NationID", SqlDbType.Int, 4) }; parameters[0].Value = model.N_Name; parameters[1].Value = model.NationID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtN_Name.Text.Trim().Length == 0) { strErr += "民族名不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int NationID = int.Parse(this.lblNationID.Text); string N_Name = this.txtN_Name.Text; Maticsoft.Model.Nation model = new Maticsoft.Model.Nation(); model.NationID = NationID; model.N_Name = N_Name; Maticsoft.BLL.Nation bll = new Maticsoft.BLL.Nation(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.Nation model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Nation("); strSql.Append("N_Name)"); strSql.Append(" values ("); strSql.Append("@N_Name)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@N_Name", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.N_Name; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Nation DataRowToModel(DataRow row) { Maticsoft.Model.Nation model=new Maticsoft.Model.Nation(); if (row != null) { if(row["NationID"]!=null && row["NationID"].ToString()!="") { model.NationID=int.Parse(row["NationID"].ToString()); } if(row["N_Name"]!=null) { model.N_Name=row["N_Name"].ToString(); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Nation DataRowToModel(DataRow row) { Maticsoft.Model.Nation model = new Maticsoft.Model.Nation(); if (row != null) { if (row["NationID"] != null && row["NationID"].ToString() != "") { model.NationID = int.Parse(row["NationID"].ToString()); } if (row["N_Name"] != null) { model.N_Name = row["N_Name"].ToString(); } } return(model); }
protected void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(this.txtN_Name.Text.Trim().Length==0) { strErr+="民族名不能为空!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } string N_Name=this.txtN_Name.Text; Maticsoft.Model.Nation model=new Maticsoft.Model.Nation(); model.N_Name=N_Name; Maticsoft.BLL.Nation bll=new Maticsoft.BLL.Nation(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","add.aspx"); }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtN_Name.Text.Trim().Length == 0) { strErr += "民族名不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string N_Name = this.txtN_Name.Text; Maticsoft.Model.Nation model = new Maticsoft.Model.Nation(); model.N_Name = N_Name; Maticsoft.BLL.Nation bll = new Maticsoft.BLL.Nation(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Nation GetModel(int NationID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 NationID,N_Name from Nation "); strSql.Append(" where NationID=@NationID"); SqlParameter[] parameters = { new SqlParameter("@NationID", SqlDbType.Int, 4) }; parameters[0].Value = NationID; Maticsoft.Model.Nation model = new Maticsoft.Model.Nation(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(this.txtN_Name.Text.Trim().Length==0) { strErr+="民族名不能为空!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int NationID=int.Parse(this.lblNationID.Text); string N_Name=this.txtN_Name.Text; Maticsoft.Model.Nation model=new Maticsoft.Model.Nation(); model.NationID=NationID; model.N_Name=N_Name; Maticsoft.BLL.Nation bll=new Maticsoft.BLL.Nation(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","list.aspx"); }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.Nation GetModel(int NationID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 NationID,N_Name from Nation "); strSql.Append(" where NationID=@NationID"); SqlParameter[] parameters = { new SqlParameter("@NationID", SqlDbType.Int,4) }; parameters[0].Value = NationID; Maticsoft.Model.Nation model=new Maticsoft.Model.Nation(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }