| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- using System.Collections;
- using System.Data;
- using IwbZero.IocNamed;
- using IwbZero.IwbBase;
- using IwbZero.IwbDataQuery;
- using IwbZero.ToolCommon.StringModel;
- using WeEngine.ComponentInfo;
- using WeEngine.Components.InterfaceFactory;
- namespace WeEngine.Components.Statements
- {
- /// <summary>
- /// 设置数据源记录条数
- /// </summary>
- [IocNamed(CompStmtType.DataSourceOperation)]
- public class DataSourceOperationStatement : IStatementRunner
- {
- public bool Run(ComponentRunner runner, IwbXmlNode poStatement)
- {
- string str = poStatement.GetChildValue("Operation").UAndT();
- string childValue = poStatement.GetChildValue("Condition");
- string pcDataSourceId = poStatement.GetChildValue("DataSourceId");
- string str4 = poStatement.GetChildValue("OriginalId");
- IwbDataSource dataSource = runner.GetDataSource(pcDataSourceId);
- IwbDataSource source2 = null;
- if (str4 != "")
- {
- source2 = runner.GetDataSource(str4);
- }
- if (dataSource == null)
- {
- return false;
- }
- switch (str)
- {
- case "OPEN":
- {
- ArrayList list = Condition.ConditionMappingToArrayList(childValue);
- string pcSource = "";
- foreach (Condition condition in list)
- {
- string str6;
- string source = condition.Source;
- string key = condition.Target.UAndT();
- if (runner.FilterFields.ContainsKey(key))
- {
- str6 = runner.FilterFields[key].ToString();
- if (str6 == "")
- {
- source = "";
- }
- }
- else
- {
- str6 = runner.Evaluate(condition.Target);
- }
- if (source != "")
- {
- pcSource = pcSource.AddStr( $"[{source}]=[{str6}]");
- }
- }
- IwbQuery query = dataSource.GetData(pcSource);
- if ((query != null) && query.IsOpened)
- {
- dataSource.Data = query;
- return true;
- }
- return false;
- }
-
- case "NEWRECORD":
- if ((dataSource.Data != null) && dataSource.Data.IsOpened)
- {
- dataSource.Data.NewRow();
- }
- return true;
- case "DELETERECORD":
- if ((dataSource.Data != null) && (dataSource.Data.CurrentRow != null))
- {
- dataSource.Data.DeleteCurrentRow();
- }
- return true;
- case "CLEAR":
- if ((dataSource.Data != null) && dataSource.Data.IsOpened)
- {
- dataSource.Data.CurrentTable.Rows.Clear();
- dataSource.Data.CurrentTable.AcceptChanges();
- }
- return true;
- case "ACCEPT":
- if ((dataSource.Data != null) && dataSource.Data.IsOpened)
- {
- dataSource.Data.CurrentTable.AcceptChanges();
- }
- return true;
- case "UNDO":
- if ((dataSource.Data != null) && dataSource.Data.IsOpened)
- {
- dataSource.Data.CurrentTable.RejectChanges();
- }
- return true;
- case "COPYCURRENT":
- if (((dataSource.Data != null) && dataSource.Data.IsOpened) && ((source2?.Data != null) && (source2.Data.CurrentRow != null)))
- {
- dataSource.Data.AddCurrentRowFrom(source2.Data);
- }
- return true;
- case "COPYRECORDS":
- if (((dataSource.Data != null) && dataSource.Data.IsOpened) && ((source2?.Data != null) && (source2.Data.CurrentRow != null)))
- {
- DataRow currentRow = source2.Data.CurrentRow;
- childValue = Condition.ConditionMappingToConditionString(childValue);
- for (int i = 0; i < source2.Data.RecCount; i++)
- {
- source2.Data.Go(i);
- if (runner.EvaluateBool(childValue))
- {
- dataSource.Data.AddCurrentRowFrom(source2.Data);
- }
- }
- source2.Data.GoTo(currentRow);
- }
- return true;
- case "Sort":
- {
- ArrayList list2 = poStatement.GetChildValue("Sorting").MappingToArrayList();
- string pcSort = "";
- foreach (IwbIdName name in list2)
- {
- string str12 = pcSort;
- pcSort = str12 + name.Id + " " + name.Name + ",";
- }
- pcSort = pcSort.TrimEnd(new char[] { ',' });
- if (pcSort != "")
- {
- dataSource.Data.SortBy(pcSort);
- }
- return true;
- }
- }
- return true;
- }
- }
- }
|