/// <summary>增加一条数据 /// /// </summary> /// <param name="model">实体对象</param> /// <returns>返回新增实体ID</returns> public int Add(Nikita.Assist.CodeMaker.Model.Bse_ControlType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Bse_ControlType("); strSql.Append(" ControlType, Ctl_Simple, Ctl_Name, Ctl_NameSpace, Ctl_Width, Ctl_Height, Ctl_Type, State, Sort, Type, IsSelf )"); strSql.Append(" values ("); strSql.Append(" @ControlType, @Ctl_Simple, @Ctl_Name, @Ctl_NameSpace, @Ctl_Width, @Ctl_Height, @Ctl_Type, @State, @Sort, @Type, @IsSelf )"); SQLiteHelper h = GlobalHelp.GetSQLiteHelper(); h.CreateCommand(strSql.ToString()); if (model.ControlType == null) { h.AddParameter("@ControlType", DBNull.Value); } else { h.AddParameter("@ControlType", model.ControlType); } if (model.Ctl_Simple == null) { h.AddParameter("@Ctl_Simple", DBNull.Value); } else { h.AddParameter("@Ctl_Simple", model.Ctl_Simple); } if (model.Ctl_Name == null) { h.AddParameter("@Ctl_Name", DBNull.Value); } else { h.AddParameter("@Ctl_Name", model.Ctl_Name); } if (model.Ctl_NameSpace == null) { h.AddParameter("@Ctl_NameSpace", DBNull.Value); } else { h.AddParameter("@Ctl_NameSpace", model.Ctl_NameSpace); } if (model.Ctl_Width == null) { h.AddParameter("@Ctl_Width", DBNull.Value); } else { h.AddParameter("@Ctl_Width", model.Ctl_Width); } if (model.Ctl_Height == null) { h.AddParameter("@Ctl_Height", DBNull.Value); } else { h.AddParameter("@Ctl_Height", model.Ctl_Height); } if (model.Ctl_Type == null) { h.AddParameter("@Ctl_Type", DBNull.Value); } else { h.AddParameter("@Ctl_Type", model.Ctl_Type); } if (model.State == null) { h.AddParameter("@State", DBNull.Value); } else { h.AddParameter("@State", model.State); } if (model.Sort == null) { h.AddParameter("@Sort", DBNull.Value); } else { h.AddParameter("@Sort", model.Sort); } if (model.Type == null) { h.AddParameter("@Type", DBNull.Value); } else { h.AddParameter("@Type", model.Type); } if (model.IsSelf == null) { h.AddParameter("@IsSelf", DBNull.Value); } else { h.AddParameter("@IsSelf", model.IsSelf); } h.ExecuteNonQuery(); string strSql2 = "select max(id) from Bse_ControlType"; h.CreateCommand(strSql2); int intResult; string strObj = h.ExecuteScalar(); if (!int.TryParse(strObj, out intResult)) { return(0); } return(intResult); }
/// <summary>更新一条数据 /// /// </summary> /// <param name="model">实体对象</param> /// <returns>返回受影响的行数</returns> public bool Update(Nikita.Assist.CodeMaker.Model.Bse_ControlType model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Bse_ControlType set "); strSql.Append(" ControlType=@ControlType, Ctl_Simple=@Ctl_Simple, Ctl_Name=@Ctl_Name, Ctl_NameSpace=@Ctl_NameSpace, Ctl_Width=@Ctl_Width, Ctl_Height=@Ctl_Height, Ctl_Type=@Ctl_Type, State=@State, Sort=@Sort, Type=@Type, IsSelf=@IsSelf "); strSql.Append(" where id=@id "); SQLiteHelper h = GlobalHelp.GetSQLiteHelper(); h.CreateCommand(strSql.ToString()); if (model.ControlType == null) { h.AddParameter("@ControlType", DBNull.Value); } else { h.AddParameter("@ControlType", model.ControlType); } if (model.Ctl_Simple == null) { h.AddParameter("@Ctl_Simple", DBNull.Value); } else { h.AddParameter("@Ctl_Simple", model.Ctl_Simple); } if (model.Ctl_Name == null) { h.AddParameter("@Ctl_Name", DBNull.Value); } else { h.AddParameter("@Ctl_Name", model.Ctl_Name); } if (model.Ctl_NameSpace == null) { h.AddParameter("@Ctl_NameSpace", DBNull.Value); } else { h.AddParameter("@Ctl_NameSpace", model.Ctl_NameSpace); } if (model.Ctl_Width == null) { h.AddParameter("@Ctl_Width", DBNull.Value); } else { h.AddParameter("@Ctl_Width", model.Ctl_Width); } if (model.Ctl_Height == null) { h.AddParameter("@Ctl_Height", DBNull.Value); } else { h.AddParameter("@Ctl_Height", model.Ctl_Height); } if (model.Ctl_Type == null) { h.AddParameter("@Ctl_Type", DBNull.Value); } else { h.AddParameter("@Ctl_Type", model.Ctl_Type); } if (model.State == null) { h.AddParameter("@State", DBNull.Value); } else { h.AddParameter("@State", model.State); } if (model.Sort == null) { h.AddParameter("@Sort", DBNull.Value); } else { h.AddParameter("@Sort", model.Sort); } if (model.Type == null) { h.AddParameter("@Type", DBNull.Value); } else { h.AddParameter("@Type", model.Type); } if (model.IsSelf == null) { h.AddParameter("@IsSelf", DBNull.Value); } else { h.AddParameter("@IsSelf", model.IsSelf); } h.AddParameter("@id", model.Ctl_Id); return(h.ExecuteNonQuery()); }