/// <summary> /// 更新一条数据 /// </summary> public bool Update(Bsam.Core.Model.Models.Model.Sys_User_In_Group model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Sys_User_In_Group set "); strSql.Append("UserId=@UserId,"); strSql.Append("UserGroupId=@UserGroupId"); strSql.Append(" where "); SQLiteParameter[] parameters = { new SQLiteParameter("@UserId", DbType.Int32, 4), new SQLiteParameter("@UserGroupId", DbType.Int32, 4) }; parameters[0].Value = model.UserId; parameters[1].Value = model.UserGroupId; int rows = DbHelperSQLite.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(txtUserId.Text)) { strErr += "UserId格式错误!\\n"; } if (!PageValidate.IsNumber(txtUserGroupId.Text)) { strErr += "UserGroupId格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int UserId = int.Parse(this.txtUserId.Text); int UserGroupId = int.Parse(this.txtUserGroupId.Text); Bsam.Core.Model.Models.Model.Sys_User_In_Group model = new Bsam.Core.Model.Models.Model.Sys_User_In_Group(); model.UserId = UserId; model.UserGroupId = UserGroupId; Bsam.Core.Model.Models.BLL.Sys_User_In_Group bll = new Bsam.Core.Model.Models.BLL.Sys_User_In_Group(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }
private void ShowInfo() { Bsam.Core.Model.Models.BLL.Sys_User_In_Group bll = new Bsam.Core.Model.Models.BLL.Sys_User_In_Group(); Bsam.Core.Model.Models.Model.Sys_User_In_Group model = bll.GetModel(); this.txtUserId.Text = model.UserId.ToString(); this.txtUserGroupId.Text = model.UserGroupId.ToString(); }
/// <summary> /// 得到一个对象实体 /// </summary> public Bsam.Core.Model.Models.Model.Sys_User_In_Group DataRowToModel(DataRow row) { Bsam.Core.Model.Models.Model.Sys_User_In_Group model = new Bsam.Core.Model.Models.Model.Sys_User_In_Group(); if (row != null) { if (row["UserId"] != null && row["UserId"].ToString() != "") { model.UserId = int.Parse(row["UserId"].ToString()); } if (row["UserGroupId"] != null && row["UserGroupId"].ToString() != "") { model.UserGroupId = int.Parse(row["UserGroupId"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Bsam.Core.Model.Models.Model.Sys_User_In_Group GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select UserId,UserGroupId from Sys_User_In_Group "); strSql.Append(" where "); SQLiteParameter[] parameters = { }; Bsam.Core.Model.Models.Model.Sys_User_In_Group model = new Bsam.Core.Model.Models.Model.Sys_User_In_Group(); DataSet ds = DbHelperSQLite.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }