public string GetName(int id) { GiveupCauseInfo entity = GetModel(id, true); if (entity == null) { return(string.Empty); } return(entity.Name); }
public GiveupCauseInfo GetModel(int id, bool fromCache = false) { GiveupCauseInfo entity = null; List <GiveupCauseInfo> list = GetList(fromCache); entity = list.Find(c => c.ID == id); return(entity); }
public static GiveupCauseInfo PopulateGiveupCauseInfo(IDataReader reader) { GiveupCauseInfo entity = new GiveupCauseInfo() { 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) { CurrentGiveupCause = GiveupCauses.Instance.GetModel(id); if (CurrentGiveupCause == null) WriteMessage("/message.aspx", "系统提示", "无效放弃原因!", "", "/index.aspx"); else { if (!Admin.Administrator && Admin.CorporationID != CurrentGiveupCause.CorporationID) WriteMessage("/message.aspx", "系统提示", "没有权限!", "", "/index.aspx"); if (!Admin.Administrator && CurrentGiveupCause.DataLevel == 0) WriteMessage("/message.aspx", "系统提示", "没有权限!", "", "/index.aspx"); txtName.Value = CurrentGiveupCause.Name; } } }
protected void btnSubmit_Click(object sender, EventArgs e) { GiveupCauseInfo entity = new GiveupCauseInfo(); int id = GetInt("id"); if (id > 0) { entity = GiveupCauses.Instance.GetModel(id, true); FillData(entity); GiveupCauses.Instance.Update(entity); } else { FillData(entity); entity.DataLevel = GetInt("corpid") == 0 ? 0 : 1; GiveupCauses.Instance.Add(entity); } GiveupCauses.Instance.ReloadGiveupCauseListCache(); Response.Redirect(string.IsNullOrEmpty(FromUrl) ? "giveupcausemg.aspx" : FromUrl); }
public abstract void AddGiveupCause(GiveupCauseInfo entity);
public void Add(GiveupCauseInfo entity) { CommonDataProvider.Instance().AddGiveupCause(entity); }
public void Update(GiveupCauseInfo entity) { CommonDataProvider.Instance().UpdateGiveupCause(entity); }
public override void AddGiveupCause(GiveupCauseInfo entity) { string sql = @"INSERT INTO ComOpp_GiveupCause( [Name] ,[CorporationID] ,[DataLevel] ,[Sort] )VALUES( @Name ,@CorporationID ,@DataLevel ,(SELECT ISNULL(MAX([Sort]),0) + 1 FROM ComOpp_GiveupCause 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(GiveupCauseInfo entity) { entity.Name = txtName.Value; entity.CorporationID = GetInt("corpid"); }
public abstract void UpdateGiveupCause(GiveupCauseInfo entity);
public override void UpdateGiveupCause(GiveupCauseInfo entity) { string sql = @" UPDATE ComOpp_GiveupCause 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 GiveupCauseInfo PopulateGiveupCauseInfo(IDataReader reader) { GiveupCauseInfo entity = new GiveupCauseInfo() { ID = (int)reader["ID"], Name = reader["Name"] as string, DataLevel = (int)reader["DataLevel"], CorporationID = (int)reader["CorporationID"], Sort = DataConvert.SafeInt(reader["Sort"]) }; return entity; }