private void EnableSelected(Hashtable Params) { IModelForm instance = PickParam(Params).GetValue <IModelForm>(ActionUtil.ActionID); if (instance != null) { StandardGrid gridList = instance.GetActived <ListModelFormProxy>().GridControl; if (gridList.SelectedRows.Count > 0) { if (AlertBox.ShowWarning("是否确认【启用】当前及其所有子节点数据?", instance, MessageBoxButtons.YesNo) != DialogResult.Yes) { return; } string userid = GetControl().GetContext().MyInfo["USERID"].ToString(); foreach (DataGridViewRow gridRow in gridList.SelectedRows) { DataRowView item = (DataRowView)gridRow.DataBoundItem; item["STATE"] = AosuApp.state.Enabled; item["ETIME"] = DateTime.Now; item["EUSER"] = userid; string pID = item["CATEGORYID"].ToString().Trim(); DataView dvChildren = new DataView(((DataSet)gridList.DataSource).Tables[gridList.DataMember], "CATEGORYID LIKE '" + pID + "%'", "CATEGORYID", DataViewRowState.CurrentRows); if (dvChildren.Count > 0) { foreach (DataRowView child in dvChildren) { child["STATE"] = AosuApp.state.Enabled; child["ETIME"] = DateTime.Now; child["EUSER"] = userid; DataGridViewRow gridChildRow = gridList.Rows.OfType <DataGridViewRow>().FirstOrDefault(cm => ((DataRowView)cm.DataBoundItem)["CATEGORYID"] == child["CATEGORYID"]); if (gridChildRow != null) { gridList.InvalidateRow(gridChildRow.Index); } } } gridList.InvalidateRow(gridRow.Index); } } } }
private void CreateNewAccount(Hashtable Params) { IModelForm instance = PickParam(Params).GetValue <IModelForm>(ActionUtil.ActionID); if (instance != null) { FCreateAccount fInstance = new FCreateAccount(); if (fInstance.ShowViewDialog(instance) == DialogResult.OK) { DataSet dsPassport = MemberDBUtils.GetMemberAndPassport(GetControl(), fInstance.AccountID, fInstance.SuperDomain); if (dsPassport != null) { StandardGrid gridList = instance.GetActived <ListModelFormProxy>().GridControl; // 为列表数据源构建一条新记录,并定位到新记录上。 DataRow rowNew = ((DataSet)gridList.DataSource).Tables[gridList.DataMember].NewRow(); foreach (DataRow rowField in instance.GetItem <StandardModelSettings>(PickParam(Params).GetValueAsString("ListModelView")).Fields.Tables[DictSet.TableName].Rows) { FieldItem fieldItem = new FieldItem(rowField); try { rowNew[fieldItem.FieldName] = dsPassport.Tables[fieldItem.PersistentTable].Rows[0][fieldItem.PersistentField]; } catch (Exception) { } } ((DataSet)gridList.DataSource).Tables[gridList.DataMember].Rows.Add(rowNew); rowNew.AcceptChanges(); // 插入新行并列表重新定位。 DataGridViewRow objCurrentRow = gridList.Rows.OfType <DataGridViewRow>().FirstOrDefault(cm => ((DataRowView)cm.DataBoundItem).Row == rowNew); if (objCurrentRow != null) { gridList.CurrentCell = gridList[0, objCurrentRow.Index]; gridList.InvalidateRow(objCurrentRow.Index); } } AlertBox.ShowTips("创建成功!", instance, MessageBoxButtons.OK); } } }