private void ShowInfo() { Bsam.Core.Model.Models.BLL.Sys_Module_Config_Tmpl bll = new Bsam.Core.Model.Models.BLL.Sys_Module_Config_Tmpl(); Bsam.Core.Model.Models.Model.Sys_Module_Config_Tmpl model = bll.GetModel(); this.txtId.Text = model.Id.ToString(); this.txtModuleType.Text = model.ModuleType; this.txtModuleConfig.Text = model.ModuleConfig; this.txtDateTimeCreated.Text = model.DateTimeCreated.ToString(); this.txtUserCreator.Text = model.UserCreator; this.txtDateTimeModified.Text = model.DateTimeModified.ToString(); this.txtUserModified.Text = model.UserModified; this.chkState.Checked = model.State; }
private void ShowInfo() { Bsam.Core.Model.Models.BLL.Sys_Module_Config_Tmpl bll = new Bsam.Core.Model.Models.BLL.Sys_Module_Config_Tmpl(); Bsam.Core.Model.Models.Model.Sys_Module_Config_Tmpl model = bll.GetModel(); this.lblId.Text = model.Id.ToString(); this.lblModuleType.Text = model.ModuleType; this.lblModuleConfig.Text = model.ModuleConfig; this.lblDateTimeCreated.Text = model.DateTimeCreated.ToString(); this.lblUserCreator.Text = model.UserCreator; this.lblDateTimeModified.Text = model.DateTimeModified.ToString(); this.lblUserModified.Text = model.UserModified; this.lblState.Text = model.State?"是":"否"; }
/// <summary> /// 得到一个对象实体 /// </summary> public Bsam.Core.Model.Models.Model.Sys_Module_Config_Tmpl DataRowToModel(DataRow row) { Bsam.Core.Model.Models.Model.Sys_Module_Config_Tmpl model = new Bsam.Core.Model.Models.Model.Sys_Module_Config_Tmpl(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["ModuleType"] != null) { model.ModuleType = row["ModuleType"].ToString(); } if (row["ModuleConfig"] != null) { model.ModuleConfig = row["ModuleConfig"].ToString(); } if (row["DateTimeCreated"] != null && row["DateTimeCreated"].ToString() != "") { model.DateTimeCreated = DateTime.Parse(row["DateTimeCreated"].ToString()); } if (row["UserCreator"] != null) { model.UserCreator = row["UserCreator"].ToString(); } if (row["DateTimeModified"] != null && row["DateTimeModified"].ToString() != "") { model.DateTimeModified = DateTime.Parse(row["DateTimeModified"].ToString()); } if (row["UserModified"] != null) { model.UserModified = row["UserModified"].ToString(); } if (row["State"] != null && row["State"].ToString() != "") { if ((row["State"].ToString() == "1") || (row["State"].ToString().ToLower() == "true")) { model.State = true; } else { model.State = false; } } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Bsam.Core.Model.Models.Model.Sys_Module_Config_Tmpl model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Sys_Module_Config_Tmpl set "); strSql.Append("Id=@Id,"); strSql.Append("ModuleType=@ModuleType,"); strSql.Append("ModuleConfig=@ModuleConfig,"); strSql.Append("DateTimeCreated=@DateTimeCreated,"); strSql.Append("UserCreator=@UserCreator,"); strSql.Append("DateTimeModified=@DateTimeModified,"); strSql.Append("UserModified=@UserModified,"); strSql.Append("State=@State"); strSql.Append(" where "); SQLiteParameter[] parameters = { new SQLiteParameter("@Id", DbType.Int32, 4), new SQLiteParameter("@ModuleType", DbType.String, 0), new SQLiteParameter("@ModuleConfig", DbType.String, 0), new SQLiteParameter("@DateTimeCreated", DbType.Date), new SQLiteParameter("@UserCreator", DbType.String, 0), new SQLiteParameter("@DateTimeModified", DbType.Date), new SQLiteParameter("@UserModified", DbType.String, 0), new SQLiteParameter("@State", DbType.bit, 1) }; parameters[0].Value = model.Id; parameters[1].Value = model.ModuleType; parameters[2].Value = model.ModuleConfig; parameters[3].Value = model.DateTimeCreated; parameters[4].Value = model.UserCreator; parameters[5].Value = model.DateTimeModified; parameters[6].Value = model.UserModified; parameters[7].Value = model.State; int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Bsam.Core.Model.Models.Model.Sys_Module_Config_Tmpl model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Sys_Module_Config_Tmpl("); strSql.Append("Id,ModuleType,ModuleConfig,DateTimeCreated,UserCreator,DateTimeModified,UserModified,State)"); strSql.Append(" values ("); strSql.Append("@Id,@ModuleType,@ModuleConfig,@DateTimeCreated,@UserCreator,@DateTimeModified,@UserModified,@State)"); SQLiteParameter[] parameters = { new SQLiteParameter("@Id", DbType.Int32, 4), new SQLiteParameter("@ModuleType", DbType.String, 0), new SQLiteParameter("@ModuleConfig", DbType.String, 0), new SQLiteParameter("@DateTimeCreated", DbType.Date), new SQLiteParameter("@UserCreator", DbType.String, 0), new SQLiteParameter("@DateTimeModified", DbType.Date), new SQLiteParameter("@UserModified", DbType.String, 0), new SQLiteParameter("@State", DbType.bit, 1) }; parameters[0].Value = model.Id; parameters[1].Value = model.ModuleType; parameters[2].Value = model.ModuleConfig; parameters[3].Value = model.DateTimeCreated; parameters[4].Value = model.UserCreator; parameters[5].Value = model.DateTimeModified; parameters[6].Value = model.UserModified; parameters[7].Value = model.State; int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Bsam.Core.Model.Models.Model.Sys_Module_Config_Tmpl GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select Id,ModuleType,ModuleConfig,DateTimeCreated,UserCreator,DateTimeModified,UserModified,State from Sys_Module_Config_Tmpl "); strSql.Append(" where "); SQLiteParameter[] parameters = { }; Bsam.Core.Model.Models.Model.Sys_Module_Config_Tmpl model = new Bsam.Core.Model.Models.Model.Sys_Module_Config_Tmpl(); DataSet ds = DbHelperSQLite.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsNumber(txtId.Text)) { strErr += "Id格式错误!\\n"; } if (this.txtModuleType.Text.Trim().Length == 0) { strErr += "ModuleType不能为空!\\n"; } if (this.txtModuleConfig.Text.Trim().Length == 0) { strErr += "ModuleConfig不能为空!\\n"; } if (!PageValidate.IsDateTime(txtDateTimeCreated.Text)) { strErr += "DateTimeCreated格式错误!\\n"; } if (this.txtUserCreator.Text.Trim().Length == 0) { strErr += "UserCreator不能为空!\\n"; } if (!PageValidate.IsDateTime(txtDateTimeModified.Text)) { strErr += "DateTimeModified格式错误!\\n"; } if (this.txtUserModified.Text.Trim().Length == 0) { strErr += "UserModified不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int Id = int.Parse(this.txtId.Text); string ModuleType = this.txtModuleType.Text; string ModuleConfig = this.txtModuleConfig.Text; DateTime DateTimeCreated = DateTime.Parse(this.txtDateTimeCreated.Text); string UserCreator = this.txtUserCreator.Text; DateTime DateTimeModified = DateTime.Parse(this.txtDateTimeModified.Text); string UserModified = this.txtUserModified.Text; bool State = this.chkState.Checked; Bsam.Core.Model.Models.Model.Sys_Module_Config_Tmpl model = new Bsam.Core.Model.Models.Model.Sys_Module_Config_Tmpl(); model.Id = Id; model.ModuleType = ModuleType; model.ModuleConfig = ModuleConfig; model.DateTimeCreated = DateTimeCreated; model.UserCreator = UserCreator; model.DateTimeModified = DateTimeModified; model.UserModified = UserModified; model.State = State; Bsam.Core.Model.Models.BLL.Sys_Module_Config_Tmpl bll = new Bsam.Core.Model.Models.BLL.Sys_Module_Config_Tmpl(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }