1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Data;
- namespace SysBaseLibs
- {
- public class DALibs
- {
- public static bool IsValuesMatch(DataRow poDr, string pcFields, string pcValues)
- {
- bool lbRetVal = false;
- Dictionary<string, object> loht = UtilStr .StrToDictionary(pcFields, pcValues);
- lbRetVal = IsValuesMatch(poDr, loht);
- return lbRetVal;
- }
- public static bool IsValuesMatch(DataRow poDr, Dictionary<string, object> poCriteria)
- {
- bool lbRetVal = false;
- if (poDr != null && poCriteria != null)
- {
- foreach (string lcColName in poCriteria.Keys)
- {
- object loValue = poCriteria[lcColName];
- if (poDr[lcColName] != null)
- {
- lbRetVal = CompareStatic(poDr[lcColName].ToString(), loValue);
- }
- else
- lbRetVal = false;
- if (!lbRetVal)
- return lbRetVal;
- }
- }
- return lbRetVal;
- }
- public static bool CompareStatic(string pcValue1, object poObject2)
- {
- bool lbRetVal = false;
- if (poObject2 == null)
- return lbRetVal;
- if (poObject2 is string)
- lbRetVal = (string.Compare(pcValue1.Trim(), poObject2.ToString().Trim(), true) == 0);
- if (poObject2 is DateTime)
- lbRetVal = (DateTime.Compare(UtilStr.StrToDt(pcValue1), (DateTime)poObject2) == 0);
- if (poObject2 is decimal)
- lbRetVal = (decimal.Compare(Utils.ValD(pcValue1), Utils.ValD(poObject2.ToString())) == 0);
- return lbRetVal;
- }
- public static string GetColumnId(string pcTableAndColumn)
- {
- string lcRetVal = pcTableAndColumn;
- Array loArr = UtilStr.StrToArrayEx(pcTableAndColumn, ".");
- if (loArr != null && loArr.Length == 2)
- lcRetVal = loArr.GetValue(1).ToString();
- return lcRetVal;
- }
- public static string GetTableId(string pcTableAndColumn)
- {
- string lcRetVal = pcTableAndColumn;
- Array loArr = UtilStr.StrToArrayEx(pcTableAndColumn, ".");
- if (loArr != null && loArr.Length == 2)
- lcRetVal = loArr.GetValue(0).ToString();
- return lcRetVal;
- }
- // Properties
- private static string _ConnectionStr = "";
- public static string CenterConnectionStr
- {
- get
- {
- if (_ConnectionStr.Trim().Length == 0)
- _ConnectionStr = AppEnv.DBConnectString;
- return _ConnectionStr;
- }
- }
- }
- public delegate bool evDataOperationRequested(rsQuery poQuery);
- public delegate void evFieldValueChanged(rsQuery poQuery, string pcFieldName);
- public delegate void evRefreshRequested(rsQuery poQuery);
- public delegate void evRecordMoved();
- //public delegate void evDeleteRecordLocally(rsTable poNpTable, DataRow poDataRow, int piIndex);
- public delegate void evDBOperationError(string pcErrorMsgs, string ErrorFields);
- }
|