private static GWDataDBField[] _GetFields(GWDataDBTable table, DirectionType direction) { Type t = Null.GetType(); SortedList <string, GWDataDBField> fieldList = new SortedList <string, GWDataDBField>(Comparer.Instance); FieldInfo[] flist = t.GetFields(BindingFlags.Static | BindingFlags.Public); foreach (FieldInfo f in flist) { object o = t.InvokeMember(f.Name, BindingFlags.Static | BindingFlags.Public | BindingFlags.GetField, null, Null, new object[] { }); GWDataDBField field = o as GWDataDBField; if (field != null && field.Table == table) { if (direction == DirectionType.INBOUND && field.IsAuto) { continue; } fieldList.Add(field.FieldName, field); } } List <GWDataDBField> fList = new List <GWDataDBField>(); foreach (GWDataDBField f in fieldList.Values) { fList.Add(f); } return(fList.ToArray()); }
private bool SubmitRecord() { GWDataDBTable recordType = CheckAddValid(); if (recordType == GWDataDBTable.None) { return(false); } if (type == "Add") { if (!AddNewRecord(recordType)) { MessageBox.Show(this, "Exception occurs when add a new record to database.Do you want to continue to add this new record? \r\nIf click YES, you will continue; if click No, this operation will be given up!", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); return(false); } } else if (type == "Modify") { if (!ModifyRecord(recordType)) { MessageBox.Show(this, "Exception occurs when add a new record to database.Do you want to continue to add this new record? \r\nIf click YES, you will continue; if click No, this operation will be given up!", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); return(false); } } return(true); }
private void RefreshFieldList(GWDataDBTable table) { _comboField.Items.Clear(); _comboField.Enabled = (table != GWDataDBTable.None); GWDataDBField[] fieldList; if (_isInbound) { fieldList = GWDataDBField.GetFields(table, DirectionType.INBOUND); } else { fieldList = GWDataDBField.GetFields(table, DirectionType.OUTBOUND); } if (fieldList == null) { return; } foreach (GWDataDBField field in fieldList) { if (_isInbound && field.FieldName == GWDataDBField.i_EventType.FieldName) { continue; } _comboField.Items.Add(field.FieldName); } }
private bool ModifyRecord(GWDataDBTable recordType) { string queryString = ""; if (recordType == GWDataDBTable.None) { return(false);; } if (recordType >= GWDataDBTable.Report) { queryString += QueryRuleControl.GetUpdateString(dataGridViewReport.Columns, dataGridViewReport.Rows[0], GWDataDBTable.Report); } if (recordType >= GWDataDBTable.Order) { queryString += QueryRuleControl.GetUpdateString(dataGridViewOrder.Columns, dataGridViewOrder.Rows[0], GWDataDBTable.Order); } if (recordType >= GWDataDBTable.Patient) { queryString += QueryRuleControl.GetUpdateString(dataGridViewPatient.Columns, dataGridViewPatient.Rows[0], GWDataDBTable.Patient); int index = indexTable.Rows.Count - 1; queryString += QueryRuleControl.GetUpdateString(dataGridViewIndex.Columns, dataGridViewIndex.Rows[index], GWDataDBTable.Index); } bool result = Program.DataAccess.ExecuteNoneQuery(queryString); return(result); }
protected override GWDataDBField[] GetFieldList(GWDataDBTable table, DirectionType direction) { GWDataDBField[] list = base.GetFieldList(table, direction); if (list == null) { return(null); } List <GWDataDBField> outlist = new List <GWDataDBField>(); foreach (GWDataDBField f in list) { if (f.Table == GWDataDBField.i_EventType.Table && f.FieldName == GWDataDBField.i_EventType.FieldName) { continue; } if (f.Table == GWDataDBField.i_PROCESS_FLAG.Table && f.FieldName == GWDataDBField.i_PROCESS_FLAG.FieldName) { continue; } outlist.Add(f); } return(outlist.ToArray()); }
private string GetSelectGUID(GWDataDBTable table) { string guid = null; if (table == GWDataDBTable.Index) { int index = dataGridViewIndex.SelectedCells[0].RowIndex; guid = dataGridViewIndex.Rows[index].Cells[0].Value.ToString(); } if (table == GWDataDBTable.Patient) { int index = dataGridViewPatient.SelectedCells[0].RowIndex; guid = dataGridViewPatient.Rows[index].Cells[0].Value.ToString(); } if (table == GWDataDBTable.Order) { int index = dataGridViewOrder.SelectedCells[0].RowIndex; guid = dataGridViewOrder.Rows[index].Cells[0].Value.ToString(); } if (table == GWDataDBTable.Report) { int index = dataGridViewReport.SelectedCells[0].RowIndex; guid = dataGridViewReport.Rows[index].Cells[0].Value.ToString(); } return(guid); }
public bool IsValid() { GWDataDBTable t = GetTable(); GWDataDBField f = GetField(); return(t != GWDataDBTable.None && f != null); }
public static object[] GetGWDataField_Left(GWDataDBTable table, GWDataDBField[] Fields) { List <object> strList = new List <object>(); GWDataDBField[] allFields = GWDataDBField.GetFields(table, HYS.Common.Objects.Device.DirectionType.INBOUND); bool bExist; foreach (GWDataDBField af in allFields) { bExist = false; foreach (GWDataDBField f in Fields) { if (af.GetFullFieldName() == f.GetFullFieldName()) { bExist = true; break; } } if (!bExist) { strList.Add(af.FieldName); } } return(strList.ToArray()); }
public void SaveSetting(MappingItem item) { if (item == null) { return; } string lut = GetLUT(); string field = GetField(); GWDataDBTable table = GetTable(); item.GWDataDBField.Table = table; item.GWDataDBField.FieldName = field; item.Translating.Type = TranslatingType.None; if (_checkFixValue.Checked) { item.Translating.Type = TranslatingType.FixValue; item.Translating.ConstValue = _textFixValue.Text; } if (_checkLookupTable.Checked) { item.Translating.Type = TranslatingType.LookUpTable; item.Translating.LutName = lut; } }
private void comboBoxInTable_SelectedIndexChanged(object sender, EventArgs e) { GWDataDBTable table = (GWDataDBTable)Enum.Parse(typeof(GWDataDBTable), comboBoxInTable.Text); if (table == GWDataDBTable.None) { this.comboBoxInField.Items.Clear(); return; } GWDataDBField[] fields = GWDataDBField.GetFields(table); this.comboBoxInField.Items.Clear(); foreach (GWDataDBField field in fields) { if (field.FieldName.ToUpper() == GWDataDBField.i_IndexGuid.FieldName.ToUpper()) { continue; } if (field.FieldName.ToUpper() == GWDataDBField.i_DataDateTime.FieldName.ToUpper()) { continue; } if (field.FieldName.ToUpper() == GWDataDBField.i_PROCESS_FLAG.FieldName.ToUpper()) { continue; } if (field.FieldName.ToUpper() == GWDataDBField.p_DATA_ID.FieldName.ToUpper()) { continue; } if (field.FieldName.ToUpper() == GWDataDBField.p_DATA_DT.FieldName.ToUpper()) { continue; } if (field.FieldName.ToUpper() == GWDataDBField.o_DATA_ID.FieldName.ToUpper()) { continue; } if (field.FieldName.ToUpper() == GWDataDBField.o_DATA_DT.FieldName.ToUpper()) { continue; } if (field.FieldName.ToUpper() == GWDataDBField.r_DATA_ID.FieldName.ToUpper()) { continue; } if (field.FieldName.ToUpper() == GWDataDBField.r_DATA_DT.FieldName.ToUpper()) { continue; } this.comboBoxInField.Items.Add(field.FieldName); } this.comboBoxInField.SelectedIndex = 0; }
public static GWDataDBField[] GetFields(GWDataDBTable table, DirectionType direction) { switch (direction) { case DirectionType.INBOUND: return(GetFieldsInbound(table)); case DirectionType.OUTBOUND: return(GetFieldsOutbound(table)); default: return(GetFieldsAll(table)); } }
public static string GetHeadersQueryString(GWDataDBTable table) { string tableName = "[dbo].[" + GWDataDB.GetTableName(interfaceName, table) + "]"; StringBuilder sb = new StringBuilder(); //sb.AppendLine("USE " + GWDataDB.DataBaseName); //sb.AppendLine("IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[" + GWDataDB.GetTableName(interfaceName, table) + "]') AND type in (N'U'))"); sb.AppendLine("SELECT TOP 0" + " * FROM " + tableName); return(sb.ToString()); }
private string GetSPName(string interfaceName, GWDataDBTable table) { switch (table) { case GWDataDBTable.Patient: return("sp_" + interfaceName + "_Patient"); case GWDataDBTable.Order: return("sp_" + interfaceName + "_Order"); case GWDataDBTable.Report: return("sp_" + interfaceName + "_Report"); default: return(""); } }
private void LoadTableParameter(SQLInboundChanel chn, GWDataDBTable table, string interfaceName) { GWDataDBField[] iFields = GWDataDBField.GetFields(table); foreach (GWDataDBField field in iFields) { if (field.IsAuto) { continue; } string paramName = field.GetFullFieldName(Program.DeviceMgt.DeviceDirInfor.Header.Name).Replace(".", "_"); SQLInQueryResultItem item = new SQLInQueryResultItem(field, paramName); chn.Rule.QueryResult.MappingList.Add(item); } }
public static string GetTableName(string interfaceName, GWDataDBTable table) { switch (table) { case GWDataDBTable.Index: return(interfaceName + "_DataIndex"); case GWDataDBTable.Patient: return(interfaceName + "_PATIENT"); case GWDataDBTable.Order: return(interfaceName + "_ORDER"); case GWDataDBTable.Report: return(interfaceName + "_REPORT"); default: return(""); } }
public bool ValidateValue() { bool fix = GetFix(); bool lut = GetLUT(); string field = GetField(); GWDataDBTable table = GetTable(); if (_isOutboundQueryResult) { if (fix) { return(true); } else if (lut) { return((table != GWDataDBTable.None) && (field != "") && GetLUTName().Length > 0); } else { return((table != GWDataDBTable.None) && (field != "")); } } else { if (fix) { return((table != GWDataDBTable.None) && (field != "")); } else if (lut) { return((table != GWDataDBTable.None) && (field != "") && GetLUTName().Length > 0); } else { return(((table == GWDataDBTable.None) && (field == "")) || ((table != GWDataDBTable.None) && (field != ""))); //empty or full //if (_isOutboundQueryResult) //{ // return (lut != "") && (table != GWDataDBTable.None) && (field != ""); //} //else //{ // if (table != GWDataDBTable.None && field.Length < 1) return false; // return true; //} } } }
private void RefreshFieldList(GWDataDBTable table) { this.comboBoxField.Items.Clear(); this.comboBoxField.Enabled = (table != GWDataDBTable.None); GWDataDBField[] fieldList = GetFieldList(table, directionType); if (fieldList != null) { this.comboBoxField.Tag = fieldList; foreach (GWDataDBField field in fieldList) { this.comboBoxField.Items.Add(field.FieldName); } } NotifyValueChanged(); }
//Just one table form patient, order or report public static string GetSelectRecordString(string guid, GWDataDBTable table) { string tableName = "[dbo].[" + GWDataDB.GetTableName(interfaceName, table) + "]"; StringBuilder sb = new StringBuilder(); //sb.AppendLine("USE " + GWDataDB.DataBaseName); //sb.AppendLine("IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[" + GWDataDB.GetTableName(interfaceName, table) + "]') AND type in (N'U'))"); sb.AppendLine("SELECT " + " * FROM " + tableName); sb.AppendLine("WHERE"); #region Get Field Name string fieldname = ""; switch (table) { case GWDataDBTable.Index: { fieldname = GWDataDBField.i_IndexGuid.FieldName; break; } case GWDataDBTable.Patient: { fieldname = GWDataDBField.p_DATA_ID.FieldName; break; } case GWDataDBTable.Order: { fieldname = GWDataDBField.o_DATA_ID.FieldName; break; } case GWDataDBTable.Report: { fieldname = GWDataDBField.r_DATA_ID.FieldName; break; } } #endregion sb.AppendLine("[" + fieldname + "] = " + "\'" + guid + "\'"); return(sb.ToString()); }
private int GetActualRow(string guid, GWDataDBTable tableType) { DataTable dataTable = null; switch (tableType) { case GWDataDBTable.Index: { dataTable = indexTable; break; } case GWDataDBTable.Patient: { dataTable = patientTable; break; } case GWDataDBTable.Order: { dataTable = orderTable; break; } case GWDataDBTable.Report: { dataTable = reportTable; break; } } int actualIndex = -1; for (int i = 0; i < dataTable.Rows.Count; i++) { if (dataTable.Rows[i][0].ToString() == guid) { actualIndex = i; break; } } return(actualIndex); }
private bool SaveFieldMapping() { GWDataDBTable table = (GWDataDBTable)Enum.Parse(typeof(GWDataDBTable), comboBoxTable.Text); if (table == GWDataDBTable.None) { MessageBox.Show("Please select inbound table and field.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); comboBoxTable.Focus(); return(false); } Mapping = new MergeFieldMapping(); Mapping.OutboundTable = _map.OutboundTable; Mapping.OutboundField = _map.OutboundField; Mapping.InboundTable = comboBoxTable.Text.Trim(); Mapping.InboundField = comboBoxField.Text.Trim(); return(true); }
private static GWDataDBField[] GetFieldsAll(GWDataDBTable table) { switch (table) { case GWDataDBTable.Index: { if (_indexFields == null) { _indexFields = _GetFields(table, DirectionType.UNKNOWN); } return(_indexFields); } case GWDataDBTable.Patient: { if (_patientFields == null) { _patientFields = _GetFields(table, DirectionType.UNKNOWN); } return(_patientFields); } case GWDataDBTable.Order: { if (_orderFields == null) { _orderFields = _GetFields(table, DirectionType.UNKNOWN); } return(_orderFields); } case GWDataDBTable.Report: { if (_reportFields == null) { _reportFields = _GetFields(table, DirectionType.UNKNOWN); } return(_reportFields); } default: return(null); } }
private static GWDataDBField[] GetFieldsOutbound(GWDataDBTable table) { switch (table) { case GWDataDBTable.Index: { if (_indexFieldsO == null) { _indexFieldsO = _GetFields(table, DirectionType.OUTBOUND); } return(_indexFieldsO); } case GWDataDBTable.Patient: { if (_patientFieldsO == null) { _patientFieldsO = _GetFields(table, DirectionType.OUTBOUND); } return(_patientFieldsO); } case GWDataDBTable.Order: { if (_orderFieldsO == null) { _orderFieldsO = _GetFields(table, DirectionType.OUTBOUND); } return(_orderFieldsO); } case GWDataDBTable.Report: { if (_reportFieldsO == null) { _reportFieldsO = _GetFields(table, DirectionType.OUTBOUND); } return(_reportFieldsO); } default: return(null); } }
public static string GetTableName(string interfaceName, GWDataDBTable table) { if (interfaceName != null && interfaceName.Length > 0) { interfaceName += "_"; } switch (table) { case GWDataDBTable.Index: return(interfaceName + "DATAINDEX"); case GWDataDBTable.Patient: return(interfaceName + "PATIENT"); case GWDataDBTable.Order: return(interfaceName + "ORDER"); case GWDataDBTable.Report: return(interfaceName + "REPORT"); default: return(""); } }
internal static GWDataDBField[] GetFieldsWithoutSort(GWDataDBTable table) { Type t = Null.GetType(); List <GWDataDBField> fieldList = new List <GWDataDBField>(); FieldInfo[] flist = t.GetFields(BindingFlags.Static | BindingFlags.Public); foreach (FieldInfo f in flist) { object o = t.InvokeMember(f.Name, BindingFlags.Static | BindingFlags.Public | BindingFlags.GetField, null, Null, new object[] { }); GWDataDBField field = o as GWDataDBField; if (field != null && field.Table == table) { fieldList.Add(field); } } return(fieldList.ToArray()); }
public bool ValidateValue() { bool fix = GetFix(); string lut = GetLUT(); string field = GetField(); GWDataDBTable table = GetTable(); if (_asQueryResult) { if (fix) { return(true); } else { return((lut != "") && (table != GWDataDBTable.None) && (field != "")); } } else { if (fix) { return((table != GWDataDBTable.None) && (field != "")); } else { if (_asQueryResult) { return((lut != "") && (table != GWDataDBTable.None) && (field != "")); } else { if (table != GWDataDBTable.None && field.Length < 1) { return(false); } return(true); } } } }
private GWDataDBTable GetSelectTable() { int i = 0; GWDataDBTable table = GWDataDBTable.None; if (dataGridViewIndex.SelectedCells.Count > 0) { i++; table = GWDataDBTable.Index; } if (dataGridViewPatient.SelectedCells.Count > 0) { i++; table = GWDataDBTable.Patient; } if (dataGridViewOrder.SelectedCells.Count > 0) { i++; table = GWDataDBTable.Order; } if (dataGridViewReport.SelectedCells.Count > 0) { i++; table = GWDataDBTable.Report; } if (table == GWDataDBTable.None) { MessageBox.Show("You don't choose a record!"); return(GWDataDBTable.None); } if (i > 1) { MessageBox.Show("Please just choose one table!"); return(GWDataDBTable.None); } return(table); }
private void LoadTableSetting(SQLOutboundChanel chn, GWDataDBTable table, string inboundName, string tablePrefix) { GWDataDBField[] iFields = GWDataDBField.GetFields(table); foreach (GWDataDBField f in iFields) { if (f.IsAuto) { continue; } string paramName = f.GetFullFieldName(inboundName).Replace(".", "_"); SQLOutQueryResultItem item = new SQLOutQueryResultItem(); item.SourceField = f.GetFullFieldName(tablePrefix); item.GWDataDBField = f; item.ThirdPartyDBPatamter.FieldType = System.Data.OleDb.OleDbType.VarChar; item.ThirdPartyDBPatamter.FieldName = paramName; item.TargetField = paramName; chn.Rule.QueryResult.MappingList.Add(item); } }
public static string GetTableName(GWDataDBTable table) { return(GetTableName("", table)); }
public ReplacementRuleItem(string field, GWDataDBTable table, bool isAuto) : base(field, table, isAuto) { }
public ComposingRuleItem(string field, GWDataDBTable table, bool isAuto) : base(field, table, isAuto) { }