/// <summary> /// Builds the data entry interface based on table /// </summary> protected void BuildUnplannedEvent() { // Build UI: build column layout based on default metadata var inputs = CICHelper.GetCaisisInputControlsByTableName(QueryTableName, null); int colCount = new Caisis.Controller.PatientDataEntryController(null).GetNumDisplayColumns(QueryTableName); DataEntryLayout.BuildLayout(inputs, colCount, new string[] { }); // Populate: populate exising record if (!string.IsNullOrEmpty(PriKeyField.Value)) { int priKey = int.Parse(PriKeyField.Value); // load record and populate form var biz = BusinessObjectFactory.BuildBusinessObject(QueryTableName); biz.Get(priKey); // populate section with biz base.PopulateForm(DataEntryLayout, biz); // set related record if exists if (!string.IsNullOrEmpty(PatientItemId.Value)) { int patientItemId = int.Parse(base.DecrypyValue(PatientItemId.Value)); RelatedRecord relatedRecord = Caisis.Controller.RelatedRecordController.GetRelatedRecords("ProtocolMgr_PatientItems", patientItemId, QueryTableName, priKey).FirstOrDefault(); if (relatedRecord != null) { RelatedRecordId.Value = relatedRecord[RelatedRecord.RelatedRecordId].ToString(); } } } }
private static DataSet GetAllObjectForDataLookups(string strTableName, string strQueryColumn) { try { Type businessObjectType = BusinessObjectFactory.GetBusinessObject(strTableName + "Info").GetType(); string strQueryCommand = string.Empty; if (businessObjectType != null) { if (businessObjectType.GetProperty("AAStatus") != null) { strQueryCommand = string.Format("Select {0} From [{1}] Where [AAStatus]='Alive'", strQueryColumn, strTableName); } else { strQueryCommand = string.Format("Select {0} From [{1}]", strQueryColumn, strTableName); } } else { strQueryCommand = string.Format("Select {0} From [{1}]", strQueryColumn, strTableName); } return(SqlDatabaseHelper.RunQuery(SqlDatabaseHelper.GetQuery(strQueryCommand))); } catch { } return(null); }
/// <summary> /// Writes the inserted date value to the client. /// </summary> private void UpdateStopDateAndReturn() { string newDate = string.Empty; // validate required mappings if (TABLE_MAPPINGS.ContainsKey(Table) && BusinessObjectFactory.CanBuildBusinessObject(Table) && PriKey.HasValue) { int patientId = int.Parse(Session[SessionKey.PatientId].ToString()); // create instance IBusinessObject biz = BusinessObjectFactory.BuildBusinessObject(Table); // load record and validate biz.Get(PriKey.Value); if (!biz.IsEmpty) { // turn on validation of patient biz.EnableSaveValidation(patientId); // the date field representing the stop date string dateField = TABLE_MAPPINGS[Table]; // check for date text field string dateTextField = dateField + "Text"; if (biz.HasField(dateField)) { // determine if updating stop date of nullifying bool doStop = Checked; if (doStop) { // set date fields DateTime date = QueryDate.HasValue ? QueryDate.Value : DateTime.Today; // ?? use DateTime.Today for normalization biz[dateField] = date; if (biz.HasField(dateTextField)) { biz[dateTextField] = date.ToShortDateString(); } // set short date newDate = date.ToShortDateString(); } // nullify stop date fields else { biz[dateField] = null; if (biz.HasField(dateTextField)) { biz[dateTextField] = null; } newDate = string.Empty; } } // update biz.Save(); } } else { newDate = string.Empty; } // write the new short stop date Response.Write(newDate); }
protected string RecordDetails(string tableName, string primaryKey) { string recordDetails = ""; if (BOL.BusinessObjectFactory.CanBuildBusinessObject(tableName)) { IBusinessObject biz = BusinessObjectFactory.BuildBusinessObject(tableName); biz.Get(int.Parse(primaryKey)); string tableDisplayName = (biz.TableLabel.Length > 0) ? biz.TableLabel : tableName; Dictionary <string, string> HPIRecordDataEntryFields = new Dictionary <string, string>(); HPIRecordDataEntryFields = CICHelper.GetCaisisInputControlsByTableName(tableName).ToDictionary(i => i.Field, i => pdec.GetFieldLabel(i.Table, i.Field)); if (HPIRecordDataEntryFields.Keys.Count > 0) { recordDetails = "<span id=\"HPIRecordDetailsBubbleContent_" + tableName + "_" + primaryKey + "\" class=\"HPIRecordDetailsBubbleContent\"><table><tr><td colspan=\"2\" class=\"HPIRecordDetailsBubbleTitle\" >" + tableDisplayName + "</td>"; foreach (string fieldName in HPIRecordDataEntryFields.Keys) { string fieldLabel = HPIRecordDataEntryFields[fieldName]; string fieldValue = biz[fieldName].ToString(); if (fieldValue.Length > 0) { recordDetails += "<tr><td>" + fieldLabel + "</td><td>" + fieldValue + "</td></tr>"; } } recordDetails += "</table></span>"; } } return(recordDetails); }
/// <summary> /// Adds a grid using the current configuration proerpties /// </summary> /// <param name="tableName"></param> /// <param name="totalBlankRows"></param> /// <param name="totalVisibleBlankRows"></param> /// <param name="tableFieldsMetadata"></param> public virtual void BuildLayout(string tableName, int totalBlankRows, int totalVisibleBlankRows, Dictionary <string, Dictionary <string, string> > tableFieldsMetadata) { IEnumerable <IBusinessObject> dataSource = from i in Enumerable.Range(0, totalBlankRows) select BusinessObjectFactory.BuildBusinessObject(tableName) as IBusinessObject; BuildLayout(tableName, dataSource, totalBlankRows, totalVisibleBlankRows, tableFieldsMetadata); }
public Client() { BusinessObjectFactory businessObjectFactory = new BusinessObjectFactory(); BusinessObject businessObject = businessObjectFactory.CreateFromId(123); var items = businessObject.Items; }
public virtual BusinessObject GetBusinessObject(int pRowHandle, params string[] pProperties) { if (pRowHandle < 0) { return(null); } if (string.IsNullOrWhiteSpace(VinaDataSource)) { VinaDbUtil vinaDbUtil = new VinaDbUtil(); BusinessObject obj = BusinessObjectFactory.GetBusinessObject(VinaDataSource + "Info"); if (obj != null) { System.Threading.Tasks.Parallel.For(0, pProperties.Length, i => { object objProp = (MainView as DevExpress.XtraGrid.Views.Grid.GridView).GetRowCellValue(pRowHandle, pProperties[i]); if (objProp != DBNull.Value) { vinaDbUtil.SetPropertyValue(obj, pProperties[i], objProp); } }); } return(obj); } return((BusinessObject)(MainView as DevExpress.XtraGrid.Views.Grid.GridView).GetRow(pRowHandle)); }
protected void ShowDxBiopsy(int DxBiopsyId) { BusinessObject biz = BusinessObjectFactory.BuildBusinessObject("Procedures"); biz.Get(DxBiopsyId); DiagnosisDateText.Text = biz[BOL.Procedure.ProcDateText].ToString(); }
protected void addGFRParams() { bool AgeOK = false; bool GenderOK = false; bool RaceOK = false; IBusinessObject biz = BusinessObjectFactory.BuildBusinessObject("Patients"); biz.Get(this._patientId); string ptGender = biz[BOL.Patient.PtGender].ToString(); string ptRace = biz[BOL.Patient.PtRace].ToString(); int ptAge = 0; DateTime ptBirthDate; if (DateTime.TryParse(biz[BOL.Patient.PtBirthDate].ToString(), out ptBirthDate)) { ptAge = Convert.ToInt32(Math.Floor(((DateTime.Now - ptBirthDate).TotalDays) / (365.242222))); AgeOK = true; } double k = 0; double a = 0; if (ptGender.ToUpper() == "MALE") { k = 0.9; a = -0.411; GenderOK = true; } else if (ptGender.ToUpper() == "FEMALE") { k = 0.7; a = -0.329; GenderOK = true; } if (ptRace.Length > 0) { RaceOK = true; } if (GenderOK && RaceOK && AgeOK) { gfr_calcOK.Text = "true"; gfr_k.Text = k.ToString(); gfr_a.Text = a.ToString(); gfr_age.Text = ptAge.ToString(); gfr_genderMod.Text = ptGender.ToUpper() == "FEMALE" ? "1.018" : "1"; gfr_raceMod.Text = ptRace.ToUpper().Contains("BLACK") ? "1.159" : "1"; } else { gfr_calcOK.Text = "false"; gfr_k.Text = "0"; gfr_a.Text = "0"; gfr_age.Text = "0"; gfr_genderMod.Text = "0"; gfr_raceMod.Text = "0"; } }
internal MyAppCollection( BusinessContext BusinessContext, ICollection <TEntry> entrySet, Func <TEntry, int> keySelector, BusinessObjectFactory <TObject, TEntry, int> factory ) : base(BusinessContext, entrySet, keySelector, factory) { }
public MyAppQueryContext ( BusinessContext businessContext, BusinessObjectFactory <TObject, TEntry, Int32> objectFactory, BusinessCollectionFactory <TCollection, TReadOnlyCollection, TObject, TEntry, Int32> collectionFactory ) : base(businessContext, objectFactory, collectionFactory) { }
protected BusinessCollection( BusinessContext businessContext, ICollection <TEntry> entrySet, Func <TEntry, TKey> keySelector, BusinessObjectFactory <TObject, TEntry, TKey> factory ) : base(businessContext, entrySet, keySelector, factory) { }
/// <summary> /// Save the data entry form and close /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SaveClick(object sender, EventArgs e) { var biz = BusinessObjectFactory.BuildBusinessObject(QueryTableName); if (!string.IsNullOrEmpty(PriKeyField.Value)) { biz.Get(int.Parse(PriKeyField.Value)); } int patientId = (int)Session[Patient.PatientId];//int.Parse(BaseDecryptedPatientId) int parentKey = biz.HasField(Patient.PatientId) ? patientId : -1; CICHelper.SetBOValues(DataEntryLayout.Controls, biz, parentKey); biz.Save(); // update hidden field int priKey = (int)biz[biz.PrimaryKeyName]; PriKeyField.Value = priKey.ToString(); // create patient item if needed PatientItem item = new PatientItem(); int patientItemId; if (!string.IsNullOrEmpty(PatientItemId.Value)) { item.Get(int.Parse(base.DecrypyValue(PatientItemId.Value))); } else { item[PatientItem.PatientSchemaId] = PatientSchemaId; item[PatientItem.Status] = "Unplanned"; } // determine schedule date var dateFields = from field in biz.FieldNames where field.EndsWith("Date") select field; if (dateFields.Count() > 0) { item[PatientItem.ScheduledDate] = biz[dateFields.First()].ToString(); } item.Save(); patientItemId = (int)item[item.PrimaryKeyName]; PatientItemId.Value = base.EncryptValue(patientItemId.ToString()); // now create association via related records if (string.IsNullOrEmpty(RelatedRecordId.Value)) { int relatedRecordId = PatientProtocolController.CreateUnplannedVisitRelatedRecord(patientItemId, biz.TableName, priKey); RelatedRecordId.Value = relatedRecordId.ToString(); } RegisterUpdateScript(false); // re populate BuildUnplannedEvent(); }
/// <summary> /// Helper function used to create child records for projects based on lookup codes /// </summary> /// <param name="parentBizo"></param> /// <param name="childBizo"></param> /// <param name="parentBizoNameField"></param> /// <param name="childBizoNameField"></param> /// <param name="PARENT_LKP_FIELD_TYPE"></param> /// <param name="CHILD_LKP_FIELD_TYPE"></param> /// <param name="validate">Whether to check if parent has child records before inserting</param> /// <param name="doSave">true if to save populated biz objects before returning </param> /// <returns></returns> private static List <BusinessObject> CreateChildRecordByBizLkpCodes(BusinessObject parentBizo, BusinessObject childBizo, string parentBizoNameField, string childBizoNameField, string PARENT_LKP_FIELD_TYPE, string CHILD_LKP_FIELD_TYPE, bool validate, bool doSave) { List <BusinessObject> childBizList = new List <BusinessObject>(); int bizPriKey = int.Parse(parentBizo[parentBizo.PrimaryKeyName].ToString()); string bizNameField = parentBizo[parentBizoNameField].ToString(); // Check child Bizo to ensure no records have been created //BusinessObject checker = BusinessObjectFactory.BuildBusinessObject(childBizo.TableName); //checker.GetByParent(bizPriKey); //if (checker.RecordCount > 0 && validate) //{ // return childBizList; //} if (validate) { string tablename = childBizo.TableName; string parentKeyName = BusinessObject.GetParentKeyName(tablename); var criteria = new Dictionary <string, object>() { { parentKeyName, bizPriKey } }; if (BusinessObject.Exists(tablename, criteria)) { return(childBizList); } } LookupCodeDa da = new LookupCodeDa(); DataRow[] lkpRecords = da.GetLookupsByFieldName(PARENT_LKP_FIELD_TYPE).Tables[0].Select("", LKP_SORT_ORDER); foreach (DataRow lkpRecord in lkpRecords) { string lkpCode = lkpRecord[LookupCode.LkpCode].ToString(); if (lkpCode == bizNameField) { int lkpCodeId = int.Parse(lkpRecord[LookupCode.LookupCodeId].ToString()); DataRow[] childLkpRecords = da.GetChildCodesByLookupIdAndChildLookupName(lkpCodeId, CHILD_LKP_FIELD_TYPE).Select("", LKP_SORT_ORDER); foreach (DataRow childLkpRecord in childLkpRecords) { string childLkpCode = childLkpRecord[LookupCode.LkpCode].ToString(); BusinessObject childBiz = BusinessObjectFactory.BuildBusinessObject(childBizo.TableName); childBiz[childBiz.ParentKeyName] = bizPriKey; childBiz[childBizoNameField] = childLkpCode; childBiz.Save(); childBizList.Add(childBiz); } } } return(childBizList); }
/// <summary> /// /// </summary> /// <param name="table"></param> /// <returns></returns> private Dictionary <string, string> Create(string table) { // create static dictionary reference instead of building instace on every call of table type if (!TableBaseDictionary.ContainsKey(table)) { Dictionary <string, string> entry = BusinessObjectFactory.BuildBusinessObject(table).FieldNames.ToDictionary(k => k, v => string.Empty); TableBaseDictionary.Add(table, entry); } return(new Dictionary <string, string>(TableBaseDictionary[table])); }
/* * protected void AddTables(ArrayList selectedTables, BusinessObject [] tableList) * { * foreach (BusinessObject biz in tableList) * { * selectedTables.Add(biz); * } * * } */ protected ArrayList ConvertNamesToTables(ArrayList selectedTableNames) { ArrayList tables = new ArrayList(); //BusinessObjectFactory fact = new BusinessObjectFactory(); //BusinessObjectFactory fact = new BusinessObjectFactory(); foreach (string tableName in selectedTableNames) { tables.Add(BusinessObjectFactory.BuildBusinessObject(tableName)); } return(tables); }
private void WriteChildRecordResponse() { string response = ""; if (TABLE_MAPPINGS.ContainsKey(Table) && BusinessObjectFactory.CanBuildBusinessObject(Table) && PriKey.HasValue) { string childTable = TABLE_MAPPINGS[Table]; if (BusinessObjectFactory.CanBuildBusinessObject(childTable)) { int patientId = int.Parse(Session[SessionKey.PatientId].ToString()); // load parent BusinessObject parent = BusinessObjectFactory.BuildBusinessObject(Table); parent.Get(PriKey.Value); if (!parent.IsEmpty) { // get prefix (i.e. "MedTx", "RadTx") string prefix = childTable.Substring(0, childTable.IndexOf("Tx") + 2); // turn on validation of patient parent.EnableSaveValidation(patientId); // create child instance BusinessObject child = BusinessObjectFactory.BuildBusinessObject(childTable); child.EnableSaveValidation(patientId); // set foreign key child[child.ParentKeyName] = parent[parent.PrimaryKeyName]; // set fields foreach (string field in COPY_FIELDS) { string parentField = prefix + field; string childField = prefix + "Admin" + field; if (parent.FieldNames.Contains(parentField) && child.FieldNames.Contains(childField)) { child[childField] = parent[parentField]; } } // sepcial date fields DateTime date = QueryDate.HasValue ? QueryDate.Value : DateTime.Today; child[prefix + "AdminStartDateText"] = date.ToShortDateString(); child[prefix + "AdminStartDate"] = date; // insert child.Save(); response = "- Administered " + (DateTime.Today.Date == date.Date ? "Today" : date.ToShortDateString()) + " -"; } } } Response.Write(response); }
/// <summary> /// Adds a grid based on the current table name /// </summary> /// <param name="tableName"></param> public virtual void BuildLayout(string tableName) { // validate table if (BusinessObjectFactory.CanBuildBusinessObject(tableName)) { // get config Caisis.Controller.PatientDataEntryController pdec = new Caisis.Controller.PatientDataEntryController(); int totalBlankRows = pdec.GetTotalBlankGridRows(tableName); int totalVisibleBlankRows = pdec.GetVisibleBlankGridRows(tableName); var tableFieldsMetadata = pdec.GetTableFieldsMetadata(tableName); BuildLayout(tableName, totalBlankRows, totalVisibleBlankRows, tableFieldsMetadata); } }
public void ReloadDatas( ) { if (RelationConfig == null) { return; } VoucherProvider.ReCalculateRelation(RelationConfig.GERelationConfigID); if (MainGridCtrl != null && RelationConfig.IsFromSource) { object datasource = null; Type objType = BusinessObjectFactory.GetBusinessObjectType(RelationConfig.SourceTableName); if (objType != null) { Type typeABCList = typeof(ABCList <>).MakeGenericType(objType); MethodInfo method; if (typeABCList != null) { datasource = ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(typeABCList); method = typeABCList.GetMethod("LoadData", new Type[] { typeof(List <BusinessObject>) }); method.Invoke(datasource, new object[] { VoucherProvider.GetOpenningRelationObjects(RelationConfig.GERelationConfigID, false) }); } } bindingMain.DataSource = datasource; bindingMain.ResetBindings(false); this.MainGridCtrl.GridDefaultView.BestFitColumns(); } if (ItemGridCtrl != null && RelationConfig.IsFromSourceItem) { object datasource = null; Type objType = BusinessObjectFactory.GetBusinessObjectType(RelationConfig.SourceItemTableName); if (objType != null) { Type typeABCList = typeof(ABCList <>).MakeGenericType(objType); MethodInfo method; if (typeABCList != null) { datasource = ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(typeABCList); method = typeABCList.GetMethod("LoadData", new Type[] { typeof(List <BusinessObject>) }); method.Invoke(datasource, new object[] { VoucherProvider.GetOpenningRelationObjects(RelationConfig.GERelationConfigID, true) }); } } bindingItem.DataSource = datasource; bindingItem.ResetBindings(false); this.ItemGridCtrl.GridDefaultView.BestFitColumns(); } }
public AdminBaseMetadataPage(string metadataItemTableName, string attributeTableName, string attributeFieldName, string attributeValueTableName, string attributeValueFieldName) : base() { // set required fields for populating/updates this.metadataItemTableName = metadataItemTableName; this.attributeTableName = attributeTableName; this.attributeFieldName = attributeFieldName; this.attributeValueTableName = attributeValueTableName; this.attributeValueFieldName = attributeValueFieldName; this.BIZ_METADATA_TABLE = BusinessObjectFactory.BuildBusinessObject(this.metadataItemTableName); this.BIZ_ATTRIBUTE_TABLE = BusinessObjectFactory.BuildBusinessObject(this.attributeTableName); this.BIZ_ATTRIBUTE_VALUE_TABLE = BusinessObjectFactory.BuildBusinessObject(this.attributeValueTableName); }
/// <summary> /// Sets the Audit Grid for the clicked row in the CurrentRecord Grid. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void SetAuditGridViewOnViewClick(object sender, EventArgs e) { LinkButton viewRecordButton = sender as LinkButton; GridViewRow row = viewRecordButton.NamingContainer as GridViewRow; row.CssClass = "CurrentGridRow"; //string tableName = currentRecordBiz.Tablename; int priKey = int.Parse(viewRecordButton.CommandArgument); //BizObject biz = BOFactory.GetBO(tableName); //biz.Get(priKey); IBusinessObject biz = BusinessObjectFactory.BuildBusinessObject(bizObjects_tablename); biz.Get(priKey); SetAuditGrid(biz); }
public BusinessQueryContext ( BusinessContext businessContext, BusinessObjectFactory <TObject, TEntry, TKey> objectFactory, BusinessCollectionFactory <TCollection, TReadOnlyCollection, TObject, TEntry, TKey> collectionFactory, IDictionary <object, IBusinessQueryFilter <TCollection, TReadOnlyCollection, TObject, TEntry, TKey> > customFilters = null, IBusinessQueryFilter <TCollection, TReadOnlyCollection, TObject, TEntry, TKey> finalizingFilter = null ) { BusinessContext = businessContext; ObjectFactory = objectFactory; CollectionFactory = collectionFactory; CustomFilters = customFilters.ToImmutableDictionary(); FinalizingFilter = finalizingFilter; }
/// <summary> /// /// </summary> /// <param name="table"></param> private void SetTable(MetadataTable table) { tableId = (int)table[MetadataTable.TableId]; TableName = table[MetadataTable.TableName_Field].ToString(); biz = BusinessObjectFactory.BuildBusinessObject(TableName); if (tableId.HasValue) { CurrentTableId.Value = tableId.Value.ToString(); } else { CurrentTableId.Value = string.Empty; } }
/// <summary> /// Adds the child table's data entry input fields for the child table /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BuildRptrChildDataEntry(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { // get child table and data string childTableName = childTableName = e.Item.DataItem.ToString(); IEnumerable <IBusinessObject> childRecords = _children[childTableName]; // locate data entry control var childDataEntry = GetChildDataEntry(e.Item); // get child input fields var childInputFields = GetInputControls(childTableName); // build interface bool childIsGrid = pdec.IsGridView(childTableName); // grid interface if (childIsGrid) { // add data entry fields interface // important, at least 1 child bizo var childGridRecords = childRecords; // shouldn't ever hit here, blank data populated ??? - ac if (childRecords.Count() == 0) { childRecords = new List <IBusinessObject>() { BusinessObjectFactory.BuildBusinessObject(childTableName) }; } CaisisGridView grid = CICHelper.AddGridViewByTableName(childDataEntry, childRecords, childTableName); bool childRecordsExist = childRecords.Where(c => c.PrimaryKeyHasValue).Count() > 0; grid.VisibleBlankRows = childRecordsExist ? 0 : 1; } // standard data entry interface else { var childDataEntryControl = BuildChildDataEntryInterface(childInputFields); // add data entry fields interface childDataEntry.Controls.Add(childDataEntryControl); // set values on inital load if (childRecords.Count() > 0 && !Page.IsPostBack) { IEnumerable <ICaisisInputControl> inputFields = PageUtil.GetControls <ICaisisInputControl>(e.Item); SetFieldValues(childRecords.First(), inputFields); } } } }
// set literal that displays the record note is associated with private void SetReferencedRecord(string tableName, int tableRecordId, bool showReferencesCheckbox) { // display information about the reference record if exists if (tableRecordId != null && tableRecordId > 0) { string recordInfo = ""; string date = ""; // get Table Label from Meta Data // TODO: THIS LOGIC SHOULD BE BUILT INTO THE MIDDLE TIER, i.e. BusinessObject.GetTableMetaLabel() MetadataDa da = new MetadataDa(); DataTable dt = new DataTable(); dt = da.GetTableMetaDataByTableName(tableName); if (dt.Rows.Count == 1) { recordInfo = "This note references " + dt.Rows[0][MetadataTable.TableLabel_Field].ToString(); } // instiantiate an biz object by table name and if there is a date text value, show it BusinessObject bo = BusinessObjectFactory.BuildBusinessObject(tableName); bo.Get(tableRecordId); IEnumerable <string> columnNames = bo.FieldNames; foreach (string column in columnNames) { if (column.ToLower().Contains("datetext") && !column.ToLower().Contains("stop")) { date = bo[column].ToString(); // check for date length and make sure "stop" is not part of column name if (date.Length > 0) { recordInfo += " dated " + date + "."; } } } RecordReferencedTitle.Text = recordInfo; if (showReferencesCheckbox) { RecordReferenced.Visible = true; RecordReferenced.Checked = true; // RecordReferencedRow.Visible = true; } } }
/// <summary> /// Manually update "dirty" attributes /// </summary> private void Update() { // update table and field attributes (generic update) foreach (var grid in new ExtendedGridView[] { TableAttributesGrid, FieldAttributesGrid }) { string table = grid.TableName; string priKeyName = BusinessObject.GetPrimaryKeyName(table); foreach (GridViewRow row in grid.Rows) { object rowPriKey = grid.DataKeys[row.RowIndex][priKeyName]; int? rowPriKeyValue = null; if (rowPriKey != null && !string.IsNullOrEmpty(rowPriKey.ToString())) { rowPriKeyValue = int.Parse(rowPriKey.ToString()); } // update/insert dirty rows if (grid.DirtyGridRows.Contains(row)) { BusinessObject biz = BusinessObjectFactory.BuildBusinessObject(table); // update if (rowPriKeyValue.HasValue) { biz.Get(rowPriKeyValue.Value); } // set values CICHelper.SetBOValues(row.Controls, biz, -1); // save/udpate biz.Save(); // udpate key rowPriKeyValue = (int)biz[priKeyName]; } // update child options only if parent updated/inserted if (grid == FieldAttributesGrid && rowPriKeyValue.HasValue) { int fieldAttributeId = rowPriKeyValue.Value; // update attribute options var attributeOptionsGrid = row.FindControl("FieldAttributeOptionsGrid") as ExtendedGridView; attributeOptionsGrid.Save(fieldAttributeId); } } } }
public virtual void SetDefaultMainObject() { try { VinaDbUtil vinaDbUtil = new VinaDbUtil(); string fromBusinessObject = VinaUtil.GetTableNameFromBusinessObject(this.MainObject); string str = fromBusinessObject.Substring(0, fromBusinessObject.Length - 1) + "ID"; this.MainObject = (BusinessObject)BusinessObjectFactory.GetBusinessObject(fromBusinessObject + "Info"); vinaDbUtil.SetPropertyValue(this.MainObject, str.Substring(0, str.Length - 2) + "No", (object)BusinessObject.DefaultObjectNo); vinaDbUtil.SetPropertyValue(this.MainObject, "AAStatus", (object)BusinessObject.DefaultAAStatus); this.UpdateMainObjectBindingSource(); } catch (Exception ex) { int num = (int)MessageBox.Show(ex.ToString()); } }
/// <summary> /// /// </summary> /// <param name="aTableName"></param> /// <param name="aFieldName"></param> /// <param name="attributeLookup"></param> protected static void PopulateAttributes(string aTableName, string aFieldName, IDictionary <string, ICaisisInputControl> attributeLookup) { // get a list of all attributes (i.e., MetadataFieldAttributes) IBusinessObject attributeBiz = BusinessObjectFactory.BuildBusinessObject(aTableName); string tableName = attributeBiz.TableName; string priKeyName = attributeBiz.PrimaryKeyName; IEnumerable <IBusinessObject> attributes = BusinessObject.GetAll(aTableName); var dbAttributes = (from biz in attributes let attributeId = (int)biz[priKeyName] let attributeName = biz[aFieldName].ToString() select new { Id = attributeId, Name = attributeName }).ToDictionary(a => a.Name, a => a.Id, StringComparer.OrdinalIgnoreCase); // for each attribute set pri key for assocaited hidden field foreach (var entry in attributeLookup) { string attributeName = entry.Key; ICaisisInputControl attributeIdField = entry.Value; // set attribute id if (dbAttributes.ContainsKey(attributeName)) { int attributeId = dbAttributes[attributeName]; attributeIdField.Value = attributeId.ToString(); } // create attribute id else { var biz = BusinessObjectFactory.BuildBusinessObject(aTableName); biz[aFieldName] = attributeName; biz.Save(); string priKey = biz[biz.PrimaryKeyName].ToString(); attributeIdField.Value = priKey; } } }
public void ReloadDatas( ) { foreach (Guid iD in lstGridControls.Keys) { List <BusinessObject> lstObjs = AlertProvider.GetAlertData(iD); ABCGridControl GridCtrl = lstGridControls[iD]; #region datasource BindingSource binding = new BindingSource(); GridCtrl.GridDataSource = binding; GridCtrl.RefreshDataSource(); object datasource = null; Type objType = BusinessObjectFactory.GetBusinessObjectType(GridCtrl.TableName); if (objType != null) { Type typeABCList = typeof(ABCList <>).MakeGenericType(objType); MethodInfo method; if (typeABCList != null) { datasource = ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(typeABCList); method = typeABCList.GetMethod("LoadData", new Type[] { typeof(List <BusinessObject>) }); method.Invoke(datasource, new object[] { lstObjs }); } } binding.DataSource = datasource; binding.ResetBindings(false); #endregion if (lstObjs.Count <= 0) { GridCtrl.Parent.Visible = false; } GridCtrl.GridDefaultView.BestFitColumns(); } }
/// <summary> /// Delete the data entry form and close /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DeleteClick(object sender, EventArgs e) { var biz = BusinessObjectFactory.BuildBusinessObject(QueryTableName); if (!string.IsNullOrEmpty(PriKeyField.Value)) { biz.Delete(int.Parse(PriKeyField.Value)); // update hidden field PriKeyField.Value = string.Empty; // delete associated record if (!string.IsNullOrEmpty(RelatedRecordId.Value)) { RelatedRecord relatedRecord = new RelatedRecord(); relatedRecord.Delete(int.Parse(RelatedRecordId.Value)); RelatedRecordId.Value = string.Empty; // register update script RegisterUpdateScript(true); } } BuildUnplannedEvent(); }