public InfoSourceInfo GetModel(int id, bool fromCache = false) { InfoSourceInfo entity = null; List <InfoSourceInfo> list = GetList(fromCache); entity = list.Find(c => c.ID == id); return(entity); }
public string GetName(int id) { InfoSourceInfo entity = GetModel(id, true); if (entity == null) { return(string.Empty); } return(entity.Name); }
public static InfoSourceInfo PopulateInfoSourceInfo(IDataReader reader) { InfoSourceInfo entity = new InfoSourceInfo() { ID = (int)reader["ID"], Name = reader["Name"] as string, DataLevel = (int)reader["DataLevel"], CorporationID = (int)reader["CorporationID"], Sort = DataConvert.SafeInt(reader["Sort"]) }; return(entity); }
private void LoadData() { int id = GetInt("id"); if (id > 0) { CurrentInfoSource = InfoSources.Instance.GetModel(id); if (CurrentInfoSource == null) WriteMessage("/message.aspx", "系统提示", "无效信息来源!", "", "/index.aspx"); else { if (!Admin.Administrator && Admin.CorporationID != CurrentInfoSource.CorporationID) WriteMessage("/message.aspx", "系统提示", "没有权限!", "", "/index.aspx"); if (!Admin.Administrator && CurrentInfoSource.DataLevel == 0) WriteMessage("/message.aspx", "系统提示", "没有权限!", "", "/index.aspx"); txtName.Value = CurrentInfoSource.Name; } } }
protected void btnSubmit_Click(object sender, EventArgs e) { InfoSourceInfo entity = new InfoSourceInfo(); int id = GetInt("id"); if (id > 0) { entity = InfoSources.Instance.GetModel(id, true); FillData(entity); InfoSources.Instance.Update(entity); } else { FillData(entity); entity.DataLevel = GetInt("corpid") == 0 ? 0 : 1; InfoSources.Instance.Add(entity); } InfoSources.Instance.ReloadInfoSourceListCache(); Response.Redirect(string.IsNullOrEmpty(FromUrl) ? "infotypemg.aspx" : FromUrl); }
public abstract void AddInfoSource(InfoSourceInfo entity);
public void Add(InfoSourceInfo entity) { CommonDataProvider.Instance().AddInfoSource(entity); }
public void Update(InfoSourceInfo entity) { CommonDataProvider.Instance().UpdateInfoSource(entity); }
public override void AddInfoSource(InfoSourceInfo entity) { string sql = @"INSERT INTO ComOpp_InfoSource( [Name] ,[CorporationID] ,[DataLevel] ,[Sort] )VALUES( @Name ,@CorporationID ,@DataLevel ,(SELECT ISNULL(MAX([Sort]),0) + 1 FROM ComOpp_InfoSource WHERE [CorporationID] = @CorporationID) )"; SqlParameter[] p = { new SqlParameter("@Name",entity.Name), new SqlParameter("@CorporationID",entity.CorporationID), new SqlParameter("@DataLevel",entity.DataLevel) }; SqlHelper.ExecuteNonQuery(_con, CommandType.Text, sql, p); }
private void FillData(InfoSourceInfo entity) { entity.Name = txtName.Value; entity.CorporationID = GetInt("corpid"); }
public abstract void UpdateInfoSource(InfoSourceInfo entity);
public override void UpdateInfoSource(InfoSourceInfo entity) { string sql = @" UPDATE ComOpp_InfoSource set Name = @Name WHERE ID=@ID"; SqlParameter[] parameters = { new SqlParameter("@ID", entity.ID), new SqlParameter("@Name", entity.Name) }; SqlHelper.ExecuteNonQuery(_con, CommandType.Text, sql, parameters); }
public static InfoSourceInfo PopulateInfoSourceInfo(IDataReader reader) { InfoSourceInfo entity = new InfoSourceInfo() { ID = (int)reader["ID"], Name = reader["Name"] as string, DataLevel = (int)reader["DataLevel"], CorporationID = (int)reader["CorporationID"], Sort = DataConvert.SafeInt(reader["Sort"]) }; return entity; }