public static bool CheckRequired(VGridControl gridControl, string[] allowColumn = null) { DataTable dt = (DataTable)gridControl.DataSource; VGridRows columnList = gridControl.Rows; for (int i = 0; i < dt.Rows.Count; i++) { foreach (DataColumn col in dt.Columns) { bool allowNull = false; if (allowColumn != null) { allowNull = Array.IndexOf(allowColumn, col.ColumnName) >= 0; } if (dt.Rows[i].RowState != DataRowState.Deleted && string.IsNullOrEmpty(dt.Rows[i][col].ToString()) && allowNull == false) { string warnText = "還有第{0}筆資料[{1}]尚未填寫!"; var column = columnList.ColumnByFieldName(col.ColumnName); string caption = column.Properties.Caption.Trim().Replace("\r\n", ""); MessageDisplay.Warning(string.Format(warnText, i + 1, caption)); gridControl.FocusedRow = columnList.GetRowByFieldName(col.ColumnName); gridControl.FocusedRecord = 2; return(false); } } } return(true); }
private void IteratePropertyGridControl(VGridRows rows) { foreach (BaseRow r in rows) { if (r.HasChildren) { IteratePropertyGridControl(r.ChildRows); } Apply(r.Properties, r.Properties.FieldName); } }
// 是否保存密码,点击时更新vGridControl状态 void edtSavePassword_EditValueChanged(object sender, EventArgs e) { CheckEdit editCheck = sender as CheckEdit; VGridRows rows = this.vGridControl.Rows; if (rows != null) { BaseRow row = rows["itemSavePassword"]; if (row != null) { row.Properties.Value = editCheck.EditValue; } } }
// 连接服务器 private void btnConnect_Click(object sender, EventArgs e) { VGridRows rows = this.vGridControl.Rows; if (rows != null) { BaseRow row = rows["itemServer"]; if (row != null && row.Properties.Value != null) { Server = row.Properties.Value.ToString(); } row = rows["itemUserName"]; if (row != null && row.Properties.Value != null) { UserName = row.Properties.Value.ToString(); } row = rows["itemPassword"]; if (row != null && row.Properties.Value != null) { Password = row.Properties.Value.ToString(); } row = rows["itemSavePassword"]; if (row != null && row.Properties.Value != null) { SavePassword = row.Properties.Value.ToString(); } XML.Clear(xmlFile); XML.Update(xmlFile, "Server", "server", Server); int nIndex = 1; for (int i = 1; i < comboBoxServer.Items.Count + 1; i++) { if (comboBoxServer.Items[i - 1].ToString() != Server) { XML.Update(xmlFile, "Server", "server" + nIndex, comboBoxServer.Items[i - 1].ToString()); nIndex++; } } XML.Update(xmlFile, "UserName", "", UserName); XML.Update(xmlFile, "Password", "", Password); XML.Update(xmlFile, "SavePassword", "", SavePassword); } this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }
// 初始化登录窗口 private void LoginForm_Load(object sender, EventArgs e) { VGridRows rows = this.vGridControl.Rows; if (rows != null) { UserName = XML.Read(xmlFile, "UserName", ""); Password = XML.Read(xmlFile, "Password", ""); BaseRow row = rows["itemUserName"]; if (row != null) { row.Properties.Value = UserName; } row = rows["itemPassword"]; if (row != null) { row.Properties.Value = Password; } } }
// 初始化登陆窗口 private void LoginForm_Load(object sender, EventArgs e) { VGridRows rows = this.vGridControl.Rows; if (rows != null) { int nIndex = 1; string historyServer = string.Empty; while (true) { historyServer = XML.Read(xmlFile, "Server", "server" + nIndex); if (historyServer == "" || historyServer == string.Empty) { break; } else { if (comboBoxServer.Items.Contains(historyServer) == false) { comboBoxServer.Items.Add(historyServer); } } nIndex++; } Server = XML.Read(xmlFile, "Server", "server"); UserName = XML.Read(xmlFile, "UserName", ""); Password = XML.Read(xmlFile, "Password", ""); SavePassword = XML.Read(xmlFile, "SavePassword", ""); if (comboBoxServer != null) { if (comboBoxServer.Items.Contains(Server) == false) { comboBoxServer.Items.Insert(0, Server); } } BaseRow row = rows["itemServer"]; if (row != null) { row.Properties.Value = Server; } row = rows["itemUserName"]; if (row != null) { row.Properties.Value = UserName; } row = rows["itemPassword"]; if (row != null) { row.Properties.Value = Password; } row = rows["itemSavePassword"]; if (row != null) { bool savePassword = true; bool.TryParse(SavePassword, out savePassword); row.Properties.Value = savePassword; } } }
/// <summary> /// 切换用户组,刷新组信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void listBoxUserGroups_SelectedIndexChanged(object sender, EventArgs e) { if (listBoxUserGroups.SelectedItem == null) { return; } List <string> colNames = new List <string>(); colNames.Add("属性"); colNames.Add("值"); List <string> PropertyNames = new List <string>(); PropertyNames.Add("组名称"); PropertyNames.Add("IP范围"); PropertyNames.Add("模块列表"); PropertyNames.Add("检查权限"); List <string> PropertyValues = new List <string>(); foreach (DataRow dtRow in dtUserGroups.Rows) { string groupName = dtRow["GroupName"].ToString(); if (groupName == listBoxUserGroups.SelectedItem.ToString()) { PropertyValues.Add(dtRow["GroupName"].ToString()); PropertyValues.Add(dtRow["IPRanges"].ToString()); PropertyValues.Add(dtRow["AllowApps"].ToString()); PropertyValues.Add(dtRow["Roles"].ToString()); break; } } UserGroup userGroup = GetUserGroupFromGroupName(listBoxUserGroups.SelectedItem.ToString()); //// 设置组属性数据 VGridRows rows = this.vGridControl.Rows; if (rows != null) { rows.Clear(); DevExpress.XtraVerticalGrid.Rows.EditorRow rowTitle = new DevExpress.XtraVerticalGrid.Rows.EditorRow("PropertyTitle"); rows.Add(rowTitle); rowTitle.Properties.Caption = "属性"; rowTitle.Properties.Value = "值"; for (int i = 0; i < PropertyNames.Count; i++) { DevExpress.XtraVerticalGrid.Rows.EditorRow row = new DevExpress.XtraVerticalGrid.Rows.EditorRow(PropertyNames[i]); rows.Add(row); row.Properties.Caption = PropertyNames[i]; if (i == 2 || i == 3) { row.Properties.RowEdit = this.comboBoxEdit; } else { row.Properties.RowEdit = this.textEdit; } if (i < PropertyValues.Count) { row.Properties.Value = PropertyValues[i]; switch (i) { case 1: if (userGroup.nStatus == 2) { row.Properties.Value = userGroup.IPRanges; } else { userGroup.IPRanges = PropertyValues[i]; } break; case 2: if (userGroup.nStatus == 2) { row.Properties.Value = userGroup.AllowApps; } else { userGroup.AllowApps = PropertyValues[i]; } break; case 3: if (userGroup.nStatus == 2) { row.Properties.Value = userGroup.Roles; } else { userGroup.Roles = PropertyValues[i]; } break; } } } } }