public static void AddDefaultConnection(Connection connect) { if (connect != null) { if (connect.DatabaseType != null) { if (!string.IsNullOrEmpty(connect.ConnectionString)) { if (connect.ConnectionGuid == Guid.Empty) { FormLog.NotifyException(true, new ExceptionLimnorDatabase("Error setting default connection: ConnectionGuid is empty")); } else { if (_defaultConnections == null) { _defaultConnections = new Dictionary <Guid, Connection>(); } if (_defaultConnections.ContainsKey(connect.ConnectionGuid)) { _defaultConnections[connect.ConnectionGuid] = connect; } else { _defaultConnections.Add(connect.ConnectionGuid, connect); } } } } } }
private void txtValue_TextChanged(object sender, System.EventArgs e) { if (editState != EnumEditState.Ready) { return; } editState = EnumEditState.ValueTextChanged; try { int n = dataGrid1.CurrentCell.RowIndex; if (n >= 0 && ds != null && ds.Tables.Count > 0 && n < ds.Tables[0].Rows.Count) { string fn = (string)(dataGrid1.CurrentRow.Cells[0].Value); EPField fld = objRet.GetField(fn); if (fld != null) { fld.FieldText = txtValue.Text; ds.Tables[0].Rows[n][2] = txtValue.Text; objRet.SQL = string.Empty; txtSQL.Text = objRet.SQL; } } } catch (Exception er) { FormLog.NotifyException(true, er); } finally { editState = EnumEditState.Ready; } }
public void Save() { if (!_loaded) { } try { int c = 0x20; List <Type> types = new List <Type>(); XmlDocument doc = VPL.XmlSerializerUtility.Save(this, types); doc.Save(ConnectionItem.GetConnectionFilename(ConnectionObject.ConnectionGuid)); if (EncryptConnectionString) { if (!ConnectionObject.ConnectionString.StartsWith(new string(new char[] { (char)(c + 1) }), StringComparison.Ordinal)) { ConnectionConfig.SetConnection(ConnectionObject.ConnectionGuid, new string(new char[] { (char)(c + 1) }) + get_pagenumber(ConnectionObject.ConnectionString)); } else { ConnectionConfig.SetConnection(ConnectionObject.ConnectionGuid, ConnectionObject.ConnectionString); } } } catch (Exception err) { FormLog.NotifyException(true, err, "Error saving connection {0}", this.ToString()); } }
bool currentCellInSynch() { try { if (_query != null && nCurrentCellColumn >= 0 && nCurrentRowIndex >= 0 && _query.Fields != null) { if (_query.Tables.Count > 0) { if (_query.Tables[0] != null) { if (_query.Fields.Count != _query.Tables[0].Columns.Count) { FormLog.LogMessage("Column count mismatch"); } else { if (_query.Tables[0].Rows.Count >= nCurrentRowIndex) { if (nCurrentCellColumn < _query.Tables[0].Columns.Count) { return(true); } } } } } } } catch { } return(false); }
protected override void OnFormClosing(FormClosingEventArgs e) { try { base.OnFormClosing(e); save(); if (_dlgUsage == enumDlgUsage.All) { } else { //merge the list? //disable new button so that we do not need to do merge here if (_dlgUsage == enumDlgUsage.Project && _listOwner != null) { if (ConnectionItem.SetProjectDatabaseConnections != null && _connectionList != null) { List <Guid> gl = new List <Guid>(); foreach (ConnectionItem ci in _connectionList) { gl.Add(ci.ConnectionGuid); } ConnectionItem.SetProjectDatabaseConnections(gl, _listOwner); } } } } catch (Exception err) { FormLog.NotifyException(true, err, "Error closing connection manager. {0}", this.ToString()); } }
public bool LoadAccess(string sPath, string sDBPass, string sUser, string sUserPass) //,out string errStr) { try { sOriginalPath = sPath; this.Text = this.Text + " - " + System.IO.Path.GetFileName(sPath); sBackupPath = sPath + ".BACKUP"; System.IO.File.Copy(sOriginalPath, sBackupPath, true); sConnectionString = ConnectionStringSelector.MakeAccessConnectionString(sOriginalPath, false, true, sDBPass, sUser, sUserPass); ConnectionStringSelector.InsertValue(ref sConnectionString, "Password", sUserPass); ConnectionStringSelector.InsertValue(ref sConnectionString, "Jet OLEDB:Database Password", sDBPass); qry = new EasyQuery(); Connection objCn = new Connection(); objCn.DatabaseType = typeof(OleDbConnection); objCn.ConnectionString = sConnectionString; qry.DatabaseConnection = new ConnectionItem(objCn); qry.Description = "Table editor"; // objCn.SetCredential(sUser, sUserPass, sDBPass); schema.dbCon = objCn; schema.LoadSchema(); loadTables(); return(true); } catch (Exception er) { FormLog.NotifyException(true, er); } finally { } return(false); }
public bool LoadData(Connection conn) { try { this.Text = this.Text + " - " + conn.ConnectionString; qry = new EasyQuery(); Connection objCn = new Connection(); objCn.NameDelimiterStyle = conn.NameDelimiterStyle; objCn.DatabaseType = conn.DatabaseType; objCn.ConnectionString = conn.ConnectionString; qry.DatabaseConnection = new ConnectionItem(objCn); qry.Description = "Table editor"; // schema.dbCon = objCn; schema.LoadSchema(); loadTables(); btCancel.Enabled = false; return(true); } catch (Exception er) { FormLog.NotifyException(true, er); } finally { } return(false); }
public void GetFields(Connection cnt) { System.Data.DataTable schemaColumn; fields = new FieldList(); Indexes = null; // //===================================================== dbWrapper db = new dbWrapper(); db.CreateCommand((Connection)cnt.Clone()); EPField fld; if (cnt.IsOleDb) { db.SetCommandText(TableName); db.SetCommandType(System.Data.CommandType.TableDirect); } else { db.SetCommandText("SELECT * FROM " + DatabaseEditUtil.SepBegin(cnt.NameDelimiterStyle) + TableName + DatabaseEditUtil.SepEnd(cnt.NameDelimiterStyle)); db.SetCommandType(System.Data.CommandType.Text); } try { if (cnt.IsOleDb || cnt.IsMSSQL) { db.OpenReader(System.Data.CommandBehavior.KeyInfo); } else { db.OpenReader(System.Data.CommandBehavior.SchemaOnly); } schemaColumn = db.GetSchemaTable(); db.CloseReader(); db.Close(); if (schemaColumn != null) { for (int i = 0; i < schemaColumn.Rows.Count; i++) { fld = EPField.MakeFieldFromColumnInfo(i, schemaColumn.Rows[i]); if (!string.IsNullOrEmpty(fld.Name)) { fld.FromTableName = TableName; fields.AddField(fld); } } } } catch (Exception er) { FormLog.NotifyException(true, er); } finally { db.CloseReader(); db.Close(); } }
protected void SetError(string sErr) { _errMsg = sErr; if (!string.IsNullOrEmpty(_errMsg)) { if (ShowErrorMessage) { FormLog.ShowMessage(_errMsg); } if (ExecuteError != null) { ExecuteError(this, EventArgs.Empty); } } }
private void btOK_Click(object sender, System.EventArgs e) { try { for (int i = 0; i < parameters.Count; i++) { parameters[i].Value = listView1.Items[i].SubItems[1].Text; } this.DialogResult = System.Windows.Forms.DialogResult.OK; Close(); } catch (Exception er) { FormLog.NotifyException(er);// clsAppGlobals.MsgBox(this, er.Message, this.Text, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Stop); } }
public static void ShowMessage(string message, params object[] values) { if (_frm != null) { if (_frm.IsDisposed) { _frm = null; } } if (_frm == null) { _frm = new FormLog(); _frm.Show(); } _frm.AddMessage(message, values); }
public void Log(string message, params object[] values) { if (LoggingEnabled) { if (!string.IsNullOrEmpty(this.LogFilePath)) { string msg; try { if (values != null && values.Length > 0) { msg = string.Format(message, values); } else { msg = message; } } catch (Exception e) { msg = ExceptionLimnorDatabase.FormExceptionText(e) + " " + message; } if (!string.IsNullOrEmpty(msg)) { StreamWriter sw = null; try { sw = new StreamWriter(LogFilePath, true, Encoding.ASCII); sw.Write(DateTime.Now.ToString("u")); sw.Write(" - "); sw.WriteLine(msg); } catch (Exception er) { FormLog.ShowMessage(ExceptionLimnorDatabase.FormExceptionText(er)); } finally { if (sw != null) { sw.Close(); } } } } } }
public static ConnectionItem LoadConnection(string dbcFile) { if (System.IO.File.Exists(dbcFile)) { try { ConnectionItem ci = XmlSerializerUtility.LoadFromXmlFile <ConnectionItem>(dbcFile); ci.SetLoaded(); return(ci); } catch (Exception err) { FormLog.NotifyException(true, err, "Invalid connection file [{0}]", dbcFile); } } return(null); }
public void AddConnection(ConnectionItem ci) { try { if (ci == null) { throw new ExceptionLimnorDatabase("Cannot add a null connection"); } if (_connectionList == null) { _connectionList = new List <ConnectionItem>(); } foreach (ConnectionItem c in _connectionList) { if (c.ConnectionObject.ConnectionGuid.Equals(ci.ConnectionObject.ConnectionGuid)) { if (!string.IsNullOrEmpty(ci.Name)) { if (string.IsNullOrEmpty(c.Name)) { c.Name = ci.Name; } } SetSelection(ci); TreeNodeConnectionItem tnc = treeView1.SelectedNode as TreeNodeConnectionItem; if (tnc != null && tnc.OwnerItem != null) { if (tnc.OwnerItem.ConnectionObject.ConnectionGuid.Equals(ci.ConnectionObject.ConnectionGuid)) { tnc.Text = c.ToString(); } } return; } } _connectionList.Add(ci); TreeNodeConnectionItem tc = new TreeNodeConnectionItem(ci); treeView1.Nodes.Add(tc); treeView1.SelectedNode = tc; } catch (Exception err) { FormLog.NotifyException(true, err, "Error adding connection {0}", this.ToString()); } }
protected void onSaveButtonClick(object sender, System.EventArgs e) { //for error log string sUpdate = ""; string sInsert = ""; string sDelete = ""; try { if (_query != null) { sDelete = _query.DeleteSql; sInsert = _query.InsertSql; sUpdate = _query.UpdateSql; if (_query.Tables[0] != null) { int nCurrentRowIndex = this.CurrentRowIndex; acceptByMouse(); Form frm = this.FindForm(); if (frm != null) { if (!frm.IsDisposed) { frm.BindingContext[_query, DataTableName].EndCurrentEdit(); if (_query.Update()) { this.CurrentRowIndex = nCurrentRowIndex; Requery(); } } } } } } catch (System.Data.DBConcurrencyException) { RequeryAfterError(); } catch (Exception er) { FormLog.NotifyException(er, "Update command:{0}.\r\nInsert command:{1}.\r\nDelete command {2}", sUpdate, sInsert, sDelete); RequeryAfterError(); } }
private void reloadFields() { if (editState == EnumEditState.Ready) { editState = EnumEditState.Loading; if (ds != null) { try { if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { EPField fld; FieldList flds = new FieldList(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (VPLUtil.ObjectToBool(ds.Tables[0].Rows[i][1])) { fld = new EPField(); fld.Name = ds.Tables[0].Rows[i][0].ToString(); if (ds.Tables[0].Rows[i][2] != null && ds.Tables[0].Rows[i][2] != System.DBNull.Value) { fld.FieldText = ds.Tables[0].Rows[i][2].ToString(); } fld.FromTableName = ds.Tables[0].TableName; flds.AddField(fld); } } objRet.SetFields(flds); showSQL(); } } } catch (Exception er) { FormLog.NotifyException(true, er); } } editState = EnumEditState.Ready; } }
void onPickValueByButton(object Sender, object Value) { if (_query != null && _query.Adapter != null && currentCellInSynch()) { try { System.Data.DataRow dw = CurrentRow; if (dw != null) { dw.BeginEdit(); dw[nCurrentCellColumn] = Value; dw.EndEdit(); _query.Adapter.Update(_query); } } catch (Exception er) { FormLog.NotifyException(er); } } }
public void BindData() { try { this.DataBindings.Clear(); if (_query != null) { if (_query.Tables.Count > 0) { if (_query.Tables[0] != null) { bindData(); } } } } catch (Exception er) { FormLog.NotifyException(er); } }
private void EPDataGrid_RowDeleted(object sender, DataRowChangeEventArgs e) { try { if (_query != null && _query.Adapter != null) { _query.Adapter.Update(_query); } } catch (System.Data.DBConcurrencyException) { Requery(); } catch (Exception er) { System.Data.DBConcurrencyException err = er as System.Data.DBConcurrencyException; if (err != null) { } FormLog.NotifyException(er); } }
public bool LoadData(EasyQuery qry, string displayField) { try { bool bLoaded = false; qry.ResetCanChangeDataSet(true); qry.Query(); bLoaded = true; ds = qry.DataStorage; if (ds != null && ds.Tables.Count > 0 && bLoaded) { if (ds.Tables[0].Columns.Count > 0) { int fldIdx = 0; this.DataSource = ds; if (!string.IsNullOrEmpty(displayField)) { for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { if (string.Compare(displayField, ds.Tables[0].Columns[i].ColumnName, StringComparison.OrdinalIgnoreCase) == 0) { fldIdx = i; break; } } } this.DisplayMember = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}.{1}", ds.Tables[0].TableName, ds.Tables[0].Columns[fldIdx].ColumnName); return(true); } } } catch (Exception er) { FormLog.NotifyException(true, er); } return(false); }
public void ExecuteCommand(FieldList rowID, int index, EPBLOB blob) { bool bClosed = (cmdUpdates[index].Connection.State == System.Data.ConnectionState.Closed); try { int i; cmdUpdates[index].Parameters[0].Value = blob.bs; for (i = 0; i < rowID.Count; i++) { cmdUpdates[index].Parameters[1 + i].Value = rowID[i].Value; } if (bClosed) { cmdUpdates[index].Connection.Open(); } cmdUpdates[index].ExecuteNonQuery(); if (bClosed) { cmdUpdates[index].Connection.Close(); } } catch (Exception er) { FormLog.NotifyException(true, er); } finally { if (bClosed) { if (cmdUpdates[index].Connection.State != System.Data.ConnectionState.Closed) { cmdUpdates[index].Connection.Close(); } } } }
protected override void OnBindDataSource() { try { EasyQuery.LogMessage2("{0} - EasyDetailsGrid.OnBindDataSource starts...", TableName); this.DataSource = null; if (QueryDef.DataStorage != null && QueryDef.DataStorage.Tables.Count > 0 && _master != null && _master.DataStorage != null) { if (QueryDef.DataStorage.Tables[TableName] != null && _master.DataStorage.Tables[_master.TableName] != null) { if (string.IsNullOrEmpty(_relname)) { _relname = string.Format(System.Globalization.CultureInfo.InvariantCulture, "rel{0}", (UInt32)(Guid.NewGuid().GetHashCode())); } bool bExist = false; foreach (DataRelation d0 in _master.DataStorage.Relations) { if (string.CompareOrdinal(d0.RelationName, _relname) == 0) { bExist = true; break; } } if (!bExist) { DataColumn[] masterColumns = _master.GetColumnsByNames(MasterKeyColumns); DataColumn[] detailColumns = this.GetColumnsByNames(DetailsKeyColumns); if (masterColumns.Length == 0 || detailColumns.Length == 0) { } else { for (int i = 0; i < masterColumns.Length; i++) { masterColumns[i].ReadOnly = true; } for (int i = 0; i < detailColumns.Length; i++) { detailColumns[i].ReadOnly = true; } DataRelation dr = new DataRelation(_relname, masterColumns, detailColumns); foreach (DataRelation dr0 in _master.DataStorage.Relations) { if (string.Compare(_relname, dr0.RelationName, StringComparison.Ordinal) == 0) { _master.DataStorage.Relations.Remove(dr0); break; } } _master.DataStorage.EnforceConstraints = false; _master.DataStorage.Relations.Add(dr); bExist = true; } } if (bExist) { BindSource.DataSource = _master.MasterSource; BindSource.DataMember = _relname; BindSource.AllowNew = !ReadOnly; } else { DataTable tbl = QueryDef.DataStorage.Tables[TableName]; if (tbl == null) { base.Query(); tbl = QueryDef.DataStorage.Tables[TableName]; } if (tbl != null) { BindSource.DataSource = _master.DataStorage; BindSource.DataMember = TableName; } } base.DataSource = BindSource; if (BindingContext != null) { BindingManagerBase bm = BindingContext[BindSource]; if (bm != null) { QueryDef.SetBindingContext(bm); } } OnFillData(); } } } catch (Exception e) { FormLog.NotifyException(ShowErrorMessage, e, "{0} - EasyDetailsGrid.OnBindDataSource", TableName); } EasyQuery.LogMessage2("{0} - EasyDetailsGrid.OnBindDataSource ends---", TableName); }
private void loadData(ProgressBar pb) { try { pb.Value = 10; pb.Refresh(); if (_connectionList == null) { if (UseProjectScope && ConnectionItem.GetProjectDatabaseConnections != null) { List <Guid> glst = new List <Guid>(); _connectionList = new List <ConnectionItem>(); if (_projectUsages != null && _projectUsages.Count > 0) { glst.AddRange(_projectUsages); } IList <Guid> gl = ConnectionItem.GetProjectDatabaseConnections(out _listOwner); if (gl != null && gl.Count > 0) { foreach (Guid g in gl) { if (g != Guid.Empty) { if (!glst.Contains(g)) { glst.Add(g); } } } } if (glst.Count > 0) { foreach (Guid g in glst) { if (g != Guid.Empty) { ConnectionItem ci = ConnectionItem.LoadConnection(g, false, false); if (ci != null) { _connectionList.Add(ci); } } } } if (_listOwner != null) { this.Text = string.Format(System.Globalization.CultureInfo.InvariantCulture, "Database connections for project {0}", _listOwner.ToString()); } } else { _dlgUsage = enumDlgUsage.All; string dir = ConnectionItem.GetConnectionFileFolder(); if (!System.IO.Directory.Exists(dir)) { System.IO.Directory.CreateDirectory(dir); } _connectionList = new List <ConnectionItem>(); string[] files = ConnectionItem.GetConnectionFiles(); if (files != null && files.Length > 0) { double r = (double)85 / (double)(files.Length); for (int i = 0; i < files.Length; i++) { Guid g = new Guid(System.IO.Path.GetFileNameWithoutExtension(files[i])); ConnectionItem ci = ConnectionItem.LoadConnection(g, false, true); if (ci != null && !ci.EncryptConnectionString) { _connectionList.Add(ci); pb.Value = 10 + (int)((i + 1) * r); pb.Refresh(); } } } } } else { _dlgUsage = enumDlgUsage.Partial; toolStripButtonCancel.Enabled = false; } pb.Value = 95; pb.Refresh(); treeView1.Nodes.Clear(); bool bSelected = false; foreach (ConnectionItem item in _connectionList) { if (item != null) { TreeNodeConnectionItem tn = new TreeNodeConnectionItem(item); treeView1.Nodes.Add(tn); if (!bSelected) { if (_currentSelection != null) { if (_currentSelection.ConnectionGuid == item.ConnectionGuid) { treeView1.SelectedNode = tn; bSelected = true; } } } } } if (!bSelected) { for (int i = 0; i < treeView1.Nodes.Count; i++) { TreeNodeConnectionItem tn = treeView1.Nodes[i] as TreeNodeConnectionItem; if (tn != null) { if (!tn.OwnerItem.IsValid) { treeView1.SelectedNode = tn; bSelected = true; break; } } } } if (!bSelected) { if (treeView1.Nodes.Count > 0) { for (int i = 0; i < treeView1.Nodes.Count; i++) { TreeNodeConnectionItem tn = treeView1.Nodes[i] as TreeNodeConnectionItem; if (tn != null) { treeView1.SelectedNode = tn; bSelected = true; break; } } } } pb.Value = 100; pb.Refresh(); } catch (Exception err) { FormLog.NotifyException(true, err); } }
void onLookupSelected(object sender, System.EventArgs e) { // int xx= 0; ComboLook cb = (ComboLook)sender; if (cb.bNoEvent) { return; } int n = cb.SelectedIndex; if (n >= 0) { object Value = cb.GetLookupData(); if (currentCellInSynch()) { bool bMatch = false; if (cbx != null && nCurrentCellColumn >= 0 && nCurrentCellColumn < cbx.Length) { bMatch = (cbx[nCurrentCellColumn] == sender); } try { System.Data.DataRow dw = CurrentRow; if (bMatch && dw != null && _query.Fields[nCurrentCellColumn].editor != null) { DataBind databind = null; DataEditorLookupDB lk = _query.Fields[nCurrentCellColumn].editor as DataEditorLookupDB; if (lk != null) { databind = lk.valuesMaps; } DataRow rv = Value as DataRow; if (databind != null && rv != null) { if (databind.AdditionalJoins != null && databind.AdditionalJoins.StringMaps != null) { for (int i = 0; i < databind.AdditionalJoins.StringMaps.Length; i++) { dw[databind.AdditionalJoins.StringMaps[i].Field1] = rv[databind.AdditionalJoins.StringMaps[i].Field2]; } } onLookup(); } else { if (rv != null) { Value = rv[1]; } bool bEQ = false; int nPos = cb.GetUpdateFieldIndex(); if (nPos < 0) { nPos = nCurrentCellColumn; } if (Value == null) { if (dw[nPos] == null) { bEQ = true; } } else if (Value == System.DBNull.Value) { bEQ = (dw[nPos] == System.DBNull.Value); } else if (Value.Equals(dw[nPos])) { bEQ = true; } if (!bEQ) { dw.BeginEdit(); dw[nPos] = Value; dw.EndEdit(); dw[nCurrentCellColumn] = ValueConvertor.ToObject(cb.Text, _query.Tables[0].Columns[nCurrentCellColumn].DataType); } // if(xx>=0) // return; // bNoEvents = true; // cb.Visible = false; // bNoEvents = false; // onRowIndexChanged(); if (!bEQ) { onLookup(); } } } } catch (Exception er) { FormLog.NotifyException(er); } } } }
protected override void OnCurrentCellChanged(EventArgs e) { try { base.OnCurrentCellChanged(e); if (bNoEvents || !pageLoaded) { return; } bool bRowChanged = false; if (nCurrentCellColumn != this.CurrentCell.ColumnNumber) { OnCellNumberChanged(); nCurrentCellColumn = this.CurrentCell.ColumnNumber; } if (nCurrentRowIndex != this.CurrentRowIndex) { nCurrentRowIndex = this.CurrentRowIndex; bRowChanged = true; } if (_query != null) { if (_query.Fields.Count > 0) { for (int i = 0; i < _query.Fields.Count; i++) { if (cbx != null) { if (cbx[i] != null) { cbx[i].Visible = false; } } if (bts != null) { if (bts[i] != null) { bts[i].Visible = false; } } } } } if (currentCellInSynch()) { sCurCaption = _query.Tables[0].Columns[nCurrentCellColumn].Caption; // if( !bReadOnly && columnEditable(nCurrentCellColumn) ) // { if (cbx != null) { if (cbx[nCurrentCellColumn] != null) { if (/*!fields[nCurrentCellColumn].ReadOnly &&*/ _query.Fields[nCurrentCellColumn].OleDbType != System.Data.OleDb.OleDbType.DBTimeStamp) { object v0 = this[nCurrentRowIndex, nCurrentCellColumn]; // string sValue = clsProperty.ToString(v0); System.Drawing.Rectangle rc = this.GetCurrentCellBounds(); cbx[nCurrentCellColumn].SetBounds(rc.Left, rc.Top, rc.Width, rc.Height); ComboLook cbxLK = cbx[nCurrentCellColumn] as ComboLook; if (cbxLK != null) { DataRowView rv; for (int i = 0; i < cbxLK.Items.Count; i++) { // string sv; object v; rv = cbxLK.Items[i] as DataRowView; if (rv != null) { v = rv[0]; } else { v = cbxLK.Items[i]; } if (LogicExp.Compare(v, enumLogicType2.Equal, v0)) { cbxLK.bNoEvent = true; cbxLK.SelectedIndex = i; cbxLK.bNoEvent = false; break; } } if (cbxLK.SelectedIndex < 0) { cbxLK.SetSelectedIndex(v0); } // } else { cbx[nCurrentCellColumn].SelectedIndex = -1; if (this[nCurrentRowIndex, nCurrentCellColumn] != null) { cbx[nCurrentCellColumn].Text = ValueConvertor.ToString(v0); } else { cbx[nCurrentCellColumn].Text = ""; } } cbx[nCurrentCellColumn].Visible = true; cbx[nCurrentCellColumn].BringToFront(); } } } if (!ReadOnly && columnEditable(nCurrentCellColumn)) { if (bts != null) { if (bts[nCurrentCellColumn] != null) { if (/*!fields[nCurrentCellColumn].ReadOnly &&*/ _query.Fields[nCurrentCellColumn].OleDbType != System.Data.OleDb.OleDbType.DBTimeStamp) { System.Drawing.Rectangle rc = this.GetCurrentCellBounds(); bts[nCurrentCellColumn].SetBounds(rc.Left + rc.Width - 20, rc.Top, 20, rc.Height); bts[nCurrentCellColumn].Visible = true; bts[nCurrentCellColumn].BringToFront(); if (_query.Fields[nCurrentCellColumn].editor != null) { if (this[nCurrentRowIndex, nCurrentCellColumn] == null) { _query.Fields[nCurrentCellColumn].editor.currentValue = ""; } else { _query.Fields[nCurrentCellColumn].editor.currentValue = this[nCurrentRowIndex, nCurrentCellColumn].ToString(); } } } } } } if (bRowChanged) { System.Data.DataRow dw = CurrentRow; if (dw != null) { for (int i = 0; i < _query.Fields.Count; i++) { _query.Fields[i].Value = dw[i]; } } onRowIndexChanged(); if (CurrentRowIndexChange != null) { CurrentRowIndexChange(this, new System.EventArgs()); } } } //else //{ // if (_query != null) // { // if (_query.Tables.Count > 0) // { // if (_query.Tables[0] != null) // { // if (nCurrentRowIndex == 0 && _query.Tables[0].Rows.Count == 0) // { // } // } // } // } //} } catch (Exception er) { FormLog.NotifyException(er); } }
public static ConnectionItem LoadConnection(Guid g, bool updateUsage, bool quickLoad) { ConnectionItem ci = null; try { string f = GetConnectionFilename(g); if (!System.IO.File.Exists(f)) { f = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, System.IO.Path.GetFileName(f)); } if (System.IO.File.Exists(f)) { try { ci = XmlSerializerUtility.LoadFromXmlFile <ConnectionItem>(f); ci.SetDataFolder(); ci.SetLoaded(); if (updateUsage) { ci.UpdateUsage(Application.ExecutablePath); } } catch (Exception errXml) { FormLog.NotifyException(true, errXml, "Invalid connection file [{0}] for connection item {1}.", f, g); } } if (quickLoad) { if (ci == null) { Connection cn = GetDefaultConnection(g); if (cn == null) { ci = new ConnectionItem(f); } else { ci = new ConnectionItem(cn); } if (updateUsage) { ci.UpdateUsage(Application.ExecutablePath); } ci.Save(); ci.SetLoaded(); } else { ci.setConnectionID(g); } } else { if (ci == null || !ci.ConnectionObject.IsConnectionReady) { Connection cn = GetDefaultConnection(g); if (cn == null) { if (ci == null) { ci = new ConnectionItem(f); } } else { ci = new ConnectionItem(cn); } if (updateUsage) { ci.UpdateUsage(Application.ExecutablePath); } ci.Save(); ci.SetLoaded(); ci._connectionChecked = true; } } } catch (Exception err) { FormLog.NotifyException(true, err, "Error loading connection item {0}.", g); } return(ci); }