private void LoadData() { int id = GetInt("id"); if (id > 0) { CurrentModule = Modules.Instance.GetModel(id, true); txtModuleName.Value = CurrentModule.ModuleName; txtParentName.Value = CurrentModule.ParentName; } }
protected void btnSubmit_Click(object sender, EventArgs e) { ModuleInfo entity = new ModuleInfo(); int id = GetInt("id"); if (id > 0) entity = Modules.Instance.GetModel(id, true); FillData(entity); if (id > 0) Modules.Instance.Update(entity); else Modules.Instance.Add(entity); Modules.Instance.ReloadModuleListCache(); Response.Redirect("modulemg.aspx"); }
public override void AddModule(ModuleInfo entity) { string sql = @"INSERT INTO ComOpp_Module( [ModuleName] ,[ParentName] ,[Sort] )VALUES( @ModuleName ,@ParentName ,(SELECT ISNULL(MAX([Sort]),0) + 1 FROM ComOpp_Module) )"; SqlParameter[] p = { new SqlParameter("@ModuleName",entity.ModuleName), new SqlParameter("@ParentName",entity.ParentName) }; SqlHelper.ExecuteNonQuery(_con, CommandType.Text, sql, p); }
public override void UpdateModule(ModuleInfo entity) { string sql = @" UPDATE ComOpp_Module set ModuleName = @ModuleName ,ParentName = @ParentName WHERE ID=@ID"; SqlParameter[] parameters = { new SqlParameter("@ID", entity.ID), new SqlParameter("@ModuleName", entity.ModuleName), new SqlParameter("@ParentName", entity.ParentName) }; SqlHelper.ExecuteNonQuery(_con, CommandType.Text, sql, parameters); }
private void FillData(ModuleInfo entity) { entity.ModuleName = txtModuleName.Value; entity.ParentName = txtParentName.Value; }
public void Update(ModuleInfo entity) { CommonDataProvider.Instance().UpdateModule(entity); }
public void Add(ModuleInfo entity) { CommonDataProvider.Instance().AddModule(entity); }
public abstract void UpdateModule(ModuleInfo entity);
public abstract void AddModule(ModuleInfo entity);
public static ModuleInfo PopulateModuleInfo(IDataReader reader) { ModuleInfo entity = new ModuleInfo() { ID = (int)reader["ID"], ModuleName = reader["ModuleName"] as string, ParentName = reader["ParentName"] as string, Sort = DataConvert.SafeInt(reader["Sort"]) }; return entity; }