private void UpdateRecStatus(GridField gridField, bool isDelete, string globalRecordId) { Epi.Data.Services.CollectedDataProvider collectedData = this.EnterCheckCodeEngine.Project.CollectedData; Epi.Data.Query updateQuery = collectedData.CreateQuery("update " + gridField.TableName + " set [RecStatus] = @RecStatus where [FKEY] = @FKEY"); updateQuery.Parameters.Add(new Epi.Data.QueryParameter("@RecStatus", DbType.Int32, isDelete ? 0 : 1)); updateQuery.Parameters.Add(new Epi.Data.QueryParameter("@FKEY", DbType.String, globalRecordId)); collectedData.ExecuteNonQuery(updateQuery); }
private DataTable GetFromData(string toRecordGuid) { string uniqueKeys = ""; string parens = ""; string joins = ""; foreach (Epi.View epiView in view.Project.Views) { if (!string.IsNullOrEmpty(epiView.TableName) && db.TableExists(epiView.TableName)) { uniqueKeys += "t" + epiView.Id + ".UniqueKey as Key" + epiView.Id + ", "; parens += "("; joins += "left outer join " + epiView.TableName + " t" + epiView.Id + " on m.FromRecordGuid = t" + epiView.Id + ".GlobalRecordId) "; } } uniqueKeys = uniqueKeys.Substring(0, uniqueKeys.Length - 2) + " "; Epi.Data.Query query = db.CreateQuery(@"Select FromRecordGuid, ToRecordGuid, FromViewId, ToViewId, " + uniqueKeys + " from " + parens + "metaLinks m " + joins + " where m.ToRecordGuid = @GlobalRecordId"); query.Parameters.Add(new Epi.Data.QueryParameter("@GlobalRecordId", DbType.StringFixedLength, toRecordGuid)); return(db.Select(query)); }
private void UpdateRecStatus(View view, bool isDelete, string globalRecordId) { Epi.Data.Services.CollectedDataProvider collectedData = this.EnterCheckCodeEngine.Project.CollectedData; Epi.Data.Query updateQuery = collectedData.CreateQuery("update " + view.TableName + " set [RecStatus] = @RecStatus where [GlobalRecordId] = @GlobalRecordId"); updateQuery.Parameters.Add(new Epi.Data.QueryParameter("@RecStatus", DbType.Int32, isDelete ? 0 : 1)); updateQuery.Parameters.Add(new Epi.Data.QueryParameter("@GlobalRecordId", DbType.String, globalRecordId)); collectedData.ExecuteNonQuery(updateQuery); // < GRID TABLES > foreach (GridField gridField in view.Fields.GridFields) { UpdateRecStatus(gridField, isDelete, globalRecordId); } // < CHILD VIEW > List <Epi.Fields.RelatedViewField> RelatedViewList = FindRelatedFields(view); foreach (Epi.Fields.RelatedViewField field in RelatedViewList) { View relatedView = this.EnterCheckCodeEngine.Project.GetViewById(field.RelatedViewID); if (collectedData.TableExists(relatedView.Name)) { Epi.Data.Query childRecordQuery = collectedData.CreateQuery("Select GlobalRecordId From " + relatedView.TableName + " Where [FKEY] = @FKEY"); childRecordQuery.Parameters.Add(new Epi.Data.QueryParameter("@FKEY", DbType.String, globalRecordId)); IDataReader dataReader = collectedData.ExecuteReader(childRecordQuery); while (dataReader.Read()) { string readerGlobalRecordId = dataReader["GlobalRecordId"].ToString(); UpdateRecStatus(relatedView, isDelete, readerGlobalRecordId); } } } }
/// <summary> /// Load the form with the saved data /// </summary> private new void LoadFormData() { Configuration config = Configuration.GetNewInstance(); FontStyle style = FontStyle.Regular; if (config.Settings.EditorFontBold) { style |= FontStyle.Bold; } if (config.Settings.EditorFontItalics) { style |= FontStyle.Italic; } field.PromptFont = new Font(config.Settings.EditorFontName, (float)config.Settings.EditorFontSize, style); style = FontStyle.Regular; if (config.Settings.ControlFontBold) { style |= FontStyle.Bold; } if (config.Settings.ControlFontItalics) { style |= FontStyle.Italic; } field.ControlFont = new Font(config.Settings.ControlFontName, (float)config.Settings.ControlFontSize, style); txtPrompt.Text = field.PromptText; txtFieldName.Text = field.Name; if (!string.IsNullOrEmpty(field.SourceTableName)) { this.sourceTableName = field.SourceTableName; this.textColumnName = field.TextColumnName; txtDataSource.Text = field.SourceTableName + " :: " + field.TextColumnName; } chkReadOnly.Checked = field.IsReadOnly; chkRepeatLast.Checked = field.ShouldRepeatLast; chkRequired.Checked = field.IsRequired; promptFont = field.PromptFont; controlFont = field.ControlFont; if (!(String.IsNullOrEmpty(txtPrompt.Text))) { btnDataSource.Enabled = true; } else { btnDataSource.Enabled = false; } Epi.Data.IDbDriver db = Epi.Data.DBReadExecute.GetDataDriver(page.view.Project.CollectedDataConnectionString); Epi.Data.Query query = db.CreateQuery("select [Name], [FieldId] " + "from metaFields " + "where [PageId] = @pageID and [FieldTypeId] in (1,3,4,17, 18, 19, 27) " + " and [ViewId] = @viewID " + "order by [Name]"); query.Parameters.Add(new Epi.Data.QueryParameter("@pageID", DbType.Int32, page.Id)); query.Parameters.Add(new Epi.Data.QueryParameter("@viewID", DbType.Int32, page.view.Id)); //DataTable textFields = page.GetMetadata().GetTextFieldsForPage(page.GetView().Id, page.Id); DataTable textFields = db.Select(query); string expression = "Name = '" + txtFieldName.Text + "'"; string sortOrder = "Name DESC"; DataRow[] rows = textFields.Select(expression, sortOrder); if (rows.Length > 0) { textFields.Rows.Remove(rows[0]); } lbxLinkedFields.DataSource = textFields; lbxLinkedFields.DisplayMember = ColumnNames.NAME; if (!(string.IsNullOrEmpty(txtDataSource.Text))) { selectedIndex = page.GetProject().CollectedData.GetTableColumnNames(field.SourceTableName); String textFieldName = string.Empty; for (int i = 0; i < textFields.Rows.Count; i++) { textFieldName = textFields.Rows[i][ColumnNames.NAME].ToString(); if (selectedIndex.Contains(textFieldName)) { lbxLinkedFields.SetSelected(lbxLinkedFields.FindStringExact(textFieldName), true); } else { lbxLinkedFields.SetSelected(lbxLinkedFields.FindStringExact(textFieldName), false); } } lbxLinkedFields.Enabled = true; lblSelectFields.Enabled = true; lbxLinkedFields.Visible = true; lblSelectFields.Visible = true; btnOk.Enabled = true; } else { btnOk.Enabled = true; } }