/// <summary> /// 初始化 /// </summary> private void Initialize() { #region 页面内容 Key.Text = string.Empty; Name.Text = string.Empty; Remark.Text = string.Empty; //数据源 DataTable configs; using (iiConfig configProvider = new iiConfig()) { configs = configProvider.GetList("Config"); } //配置 iiGlobal.BindListItems(CID, configs.DefaultView, "Name", "Key", false); try { CID.SelectedValue = this.CurrentID; } catch { } CID.Enabled = false; #endregion //绑定列表 this.BindList(); }
/// <summary> /// 绑定列表 /// </summary> private void BindList() { using (iiConfig configProvider = new iiConfig()) { List.DataSource = configProvider.GetList("Role"); } List.DataBind(); }
/// <summary> /// 绑定列表 /// </summary> private void BindList() { using (iiConfig configProvider = new iiConfig()) { List.DataSource = configProvider.GetList(CID.SelectedValue, Key.Text, Name.Text, Remark.Text); } List.DataBind(); }
/// <summary> /// 绑定项目 /// </summary> private void BindItem() { DataRow config; using (iiConfig configProvider = new iiConfig()) { config = configProvider.GetItem(this.CurrentID, this.CurrentKey); } Key.Text = config["Key"].ToString().Trim(); Key.Enabled = false; Name.Text = config["Name"].ToString(); Remark.Text = config["Remark"].ToString(); }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void OKButton_Click(object sender, EventArgs e) { using (iiConfig configProvider = new iiConfig()) { if (this.CurrentKey.Length == 0) { //新增 if (configProvider.GetItem(this.CurrentID, Key.Text) == null) //不存在 { try { configProvider.Create(this.CurrentID, Key.Text, Name.Text, Remark.Text); } catch (Exception error) { this.ShowErrorMessage(this.GetGlobalResourceString("CreateErrorMessage") + error.Message); return; } } else { this.ShowWarningMessage(this.GetGlobalResourceString("ExistedErrorMessage")); return; } } else { //编辑 try { configProvider.Update(this.CurrentID, Key.Text, Name.Text, Remark.Text); } catch (Exception error) { this.ShowErrorMessage(this.GetGlobalResourceString("UpdateErrorMessage") + error.Message); return; } } } //回调 this.DialogCallback("'CloseRefresh'", "window"); }
/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DeleteButton_Click(object sender, EventArgs e) { bool deleted = false; using (iiConfig configProvider = new iiConfig()) { foreach (GridViewRow row in List.Rows) { HtmlInputCheckBox rowCheckControl = (HtmlInputCheckBox)row.FindControl("RowCheck"); if (rowCheckControl.Checked) { try { //删除 configProvider.Delete( List.DataKeys[row.RowIndex]["ID"].ToString().Trim(), List.DataKeys[row.RowIndex]["Key"].ToString().Trim() ); } catch (Exception error) { this.ShowErrorMessage(this.GetGlobalResourceString("DeleteErrorMessage") + error.Message); return; } //有项被删除 deleted = true; } } } if (deleted) { this.BindList(); } else { this.ShowInfoMessage(this.GetGlobalResourceString("NotSelectMessage")); } }