//计算界面公式: UIValue('控件名','字段名') bool CalcUIFormula(ref string sQueryFilter) { SortedList <string, Control> sortCtrls = new SortedList <string, Control>(); foreach (Control ctrl in flowPanel.Controls) { sortCtrls.Add(ctrl.Name, ctrl); } sQueryFilter = sQueryFilter.ToLower(); int idx = sQueryFilter.IndexOf("uivalue"); while (idx > -1) { int idx2 = idx + "uivalue".Length; while (sQueryFilter.Length > idx2 + 1 && sQueryFilter[idx2 + 1] == ' ') { idx2++; } if (sQueryFilter[idx2] == '(') { idx2++; int idx3 = sQueryFilter.IndexOf(')', idx2); if (idx3 > idx2) { string sPara = sQueryFilter.Substring(idx2, idx3 - idx2); string[] arr = sPara.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (arr.Length == 2) { string sCtrlName = arr[0].Trim("'".ToCharArray()); string sColCode = arr[1].Trim("'".ToCharArray()); if (!sortCtrls.ContainsKey(sCtrlName)) { string sMsg = string.Format("过滤表达式错误:控件 {0} 不存在!", sCtrlName); MessageBox.Show(sMsg, "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return(false); } Control ctrl = sortCtrls[sCtrlName]; IWindowCtrl winCtrl = (IWindowCtrl)ctrl; object objVal = winCtrl.GetSelectValue(sColCode); string sVal = (objVal != null) ? objVal.ToString() : ""; sQueryFilter = sQueryFilter.Substring(0, idx) + sVal + sQueryFilter.Substring(idx3 + 1); } } } idx = sQueryFilter.IndexOf("uivalue", idx + 1); } return(true); }
void RefreshLinkageWindowControl(CWindowControl WindowControl) { List <Control> lstCtrls = new List <Control>(); foreach (Control ctrl in panelTop.Controls) { lstCtrls.Add(ctrl); } foreach (Control ctrl in panelBottom.Controls) { lstCtrls.Add(ctrl); } foreach (Control ctrl in panelLeft.Controls) { lstCtrls.Add(ctrl); } foreach (Control ctrl in panelRight.Controls) { lstCtrls.Add(ctrl); } foreach (Control ctrl in panelFill.Controls) { lstCtrls.Add(ctrl); } List <CBaseObject> lstLT = WindowControl.LinkageWindowControlMgr.GetList(); foreach (CBaseObject obj in lstLT) { CLinkageWindowControl LinkageWindowControl = (CLinkageWindowControl)obj; CWindowControl swc = (CWindowControl)WindowControl.m_ObjectMgr.Find(LinkageWindowControl.SlaveID); if (swc != null) { foreach (Control ctrl in lstCtrls) { if ((CWindowControl)(ctrl.Tag) == swc) { IWindowCtrl winCtrl = (IWindowCtrl)ctrl; if (winCtrl.GetCtrlType() == ControlType.TableGrid) { TableGrid teLT = (TableGrid)ctrl; CTableInWindowControl tiw = teLT.TableInWindowControl; string sQueryFilter = tiw.QueryFilter; if (CalcUIFormula(ref sQueryFilter)) { teLT.BaseObjectMgr.GetList(sQueryFilter); teLT.LoadData(); } } else if (winCtrl.GetCtrlType() == ControlType.TableTab) { TableTab tabLT = (TableTab)ctrl; foreach (TabPage page in tabLT.tabControl.TabPages) { TableGrid teLT = (TableGrid)page.Controls[0]; CTableInWindowControl tiw = teLT.TableInWindowControl; string sQueryFilter = tiw.QueryFilter; if (CalcUIFormula(ref sQueryFilter)) { teLT.BaseObjectMgr.GetList(sQueryFilter); teLT.LoadData(); } } } else if (winCtrl.GetCtrlType() == ControlType.ListBox) { UIListBox listBoxLT = (UIListBox)ctrl; CTableInWindowControl tiw = listBoxLT.TableInWindowControl; string sQueryFilter = tiw.QueryFilter; if (CalcUIFormula(ref sQueryFilter)) { listBoxLT.BaseObjectMgr.GetList(sQueryFilter); listBoxLT.LoadData(); } } else if (winCtrl.GetCtrlType() == ControlType.ComboBox) { UIComboBox combBoxLT = (UIComboBox)ctrl; CTableInWindowControl tiw = combBoxLT.TableInWindowControl; string sQueryFilter = tiw.QueryFilter; if (CalcUIFormula(ref sQueryFilter)) { combBoxLT.BaseObjectMgr.GetList(sQueryFilter); combBoxLT.LoadData(); } } } } } } }