public ApptLabel GetApptLabel(DataTable table) { if (table == null || SchedulerLabels == null) { return(null); } ApptLabel label = null; try { foreach (ApptLabel lbl in SchedulerLabels) { table.DefaultView.RowFilter = CriteriaToWhereClauseHelper.GetDataSetWhere(CriteriaOperator.Parse(lbl.LabelCriteria)); if (table.DefaultView.Count > 0 && lbl.LabelCriteria != "") { label = lbl; break; } if (lbl.LabelCriteria == "") { label = lbl; //default label } } } catch (Exception e) { } return(label); }
public override void OnSaveData() { ApptLabel saveObject = defaultBindingSource.Current as ApptLabel; saveObject.LabelCriteria = CriteriaToWhereClauseHelper.GetDataSetWhere(ctrl_FilterControl.FilterCriteria); var store = new StoreApptLabel() { Label = saveObject.ConvertTo <ApptLabelDto>() }; var resp = ServiceClient.Post(store); //if the response was good, then notify the others. if (resp.ResponseStatus == null) { saveObject = resp.Label.ConvertTo <ApptLabel>(); Context.ServiceClient.Post(new ApptLabelsNotification() { FromUserName = Context.LoggedInUser.UserName, Selector = SelectorTypes.store, Ids = new List <int>() { resp.Label.Id } }); } base.OnSaveData(); lblInfo.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; }
private void defaultBindingSource_AddingNew(object sender, AddingNewEventArgs e) { string currlbl = (defaultBindingSource.Current as ApptLabel).ViewName; string currIntfT = (defaultBindingSource.Current as ApptLabel).UseInterfaceType; ApptLabel newLabel = new ApptLabel(); newLabel.ViewName = currlbl; newLabel.LabelName = ""; newLabel.UseInterfaceType = currIntfT; e.NewObject = newLabel; }
private void gvBOSExternalEntity_RowStyle(object sender, RowStyleEventArgs e) { try { if (e.RowHandle > -1) { if (ActiveViewOption != null) { if (sender is GridView view) { if (view.IsRowSelected(e.RowHandle)) { return; } } //DataTable table1 = TempDataTableCreator.CreateDataTableFromEntity(gvExample.GetRow(e.RowHandle)); //to represent the entity as the one on the scheduler, see if it is already an appointment, so check the scheduler DataTable table = new DataTable(); var recInGrid = gvBOSExternalEntity.GetRow(e.RowHandle) as BOSEntity; //look for the appointments with the ext ref as subject, and then extract the entity within the appointment with that reference var appts = schedulerDataStorage.Appointments.Items.FindAll(a => (a.CustomFields["ENTITY"] is BOSEntity bosEnt) && bosEnt.ExtRefId == recInGrid.ExtRefId); if (appts.Any()) { Appointment appt = appts.FirstOrDefault(a => a.Start.Date == dateNavigator.SelectionStart.Date); if (appt == null) { appt = appts.FirstOrDefault(); } table = appt.CustomFields["ENTITY"].ConvertToDataTable(); } else { table = recInGrid.ConvertToDataTable(); } ApptLabel label = ActiveViewOption.GetApptLabel(table); if (label != null) { e.Appearance.BackColor = Color.FromArgb(label.ColourRGB); e.Appearance.ForeColor = Color.FromArgb(label.ForeColourRGB); } } } } catch (Exception ex) { Logger.Error(ex.Message, ex); #if DEBUG throw ex; #endif } }
public override bool OnDeleteData() { if (base.OnDeleteData(true)) { ApptLabel delLabel = defaultBindingSource.Current as ApptLabel; var delReq = new DeleteApptLabel { Id = delLabel.Id }; ServiceClient.Delete(delReq); defaultBindingSource.RemoveCurrent(); defaultBindingSource.ResetBindings(false); lblInfo.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; } return(base.OnDeleteData()); }
/// <summary> /// Store the label to the database and sets the default criteria string only if the id is 0. /// Otherwise just return a the record. /// </summary> /// <param name="labels">The label check if its new.</param> /// <param name="modifyUser">the user to log as the created or modified user</param> /// <param name="_repository">repository used for saving info</param> /// <returns></returns> private ApptLabelDto StoreLabel(ApptLabelDto label, string modifyUser, IDataRepositoryCrudBase <ApptLabel> _repository) { ApptLabel lbl = label.ConvertTo <ApptLabel>(); if (label.Id == 0) { //then save the label, to get an ID, lbl = _repository.CreateUpdate(lbl, modifyUser); //then but also set the criteria to the correct value and save it again.. if (Type.GetType(lbl.UseInterfaceType) == typeof(IEntityWithStatusLabels)) { lbl.LabelCriteria = $"([LabelKey] = '{lbl.Id}')"; } } return(_repository.CreateUpdate(lbl, modifyUser).ConvertTo <ApptLabelDto>()); }
public void AppointmentViewInfoCustomizing(object sender, AppointmentViewInfoCustomizingEventArgs e, AppointmentStatusDataStorage statuses) { try { //apply the colours according to the value of the location. //e.ViewInfo.Appearance.BackColor <-- this is label colour //e.ViewInfo.Status <-- this is status strip colour (we set it on the appointment, not on the entity in "ENTITY" custom field. if (e.ViewInfo.Appointment.CustomFields != null) { if (e.ViewInfo.Appointment.CustomFields["ENTITY"] is IEntityWithProgressStatus) { Appointment appt = e.ViewInfo.Appointment; DataTable table = appt.CustomFields["ENTITY"].ConvertToDataTable();//TempDataTableCreator.CreateDataTableFromEntity(appt.CustomFields["ENTITY"]); ApptLabel label = GetApptLabel(table); ApptStatus status = GetApptStatus(table); if (label != null) { e.ViewInfo.Appearance.BackColor = Color.FromArgb(label.ColourRGB); } else { e.ViewInfo.Appearance.BackColor = Color.FromArgb(SchedulerLabels.First(l => l.SortIndex == 99).ColourRGB); } if (status != null) { e.ViewInfo.Status = statuses.Items.Find(s => s.Id.ToString() == status.Id.ToString()); } else { e.ViewInfo.Status = statuses.Items.CreateNewStatus(Guid.NewGuid(), "", "", new SolidBrush(Color.FromArgb(SchedulerStatuses.First(s => s.SortIndex == 99).ColourRGB))); } } } } catch (Exception ex) { Logger.Error(ex.Message, ex); #if DEBUG throw ex; #endif } }
void CreateDefaultRecord(FindApptLabels request, IGenericEntityRepositoryBase <ApptLabel, IDataContextNhJars> repository) { ApptLabel lbl = new ApptLabel() { UseInterfaceType = request.InterfaceTypeName, ViewName = request.ViewType, LabelCriteria = "" }; lbl = repository.CreateUpdate(lbl, "SYSTEM"); Type t = Type.GetType(request.InterfaceTypeName); if (t == typeof(IEntityWithStatusLabels)) { lbl.LabelCriteria = $"([LabelKey] = '{lbl.Id}')"; lbl = repository.CreateUpdate(lbl, "SYSTEM"); } }
public void AppointmentViewInfoCustomizing(object sender, AppointmentViewInfoCustomizingEventArgs e, AppointmentStatusDataStorage statuses) { try { if (e.ViewInfo.Appointment.CustomFields != null) { if (e.ViewInfo.Appointment.CustomFields["ENTITY"] is IEntityWithStatusLabels) { Appointment appt = e.ViewInfo.Appointment; DataTable table = appt.CustomFields["ENTITY"].ConvertToDataTable(); ApptLabel label = GetApptLabel(table); ApptStatus status = GetApptStatus(table); if (label != null) { e.ViewInfo.Appearance.BackColor = Color.FromArgb(label.ColourRGB); } else { e.ViewInfo.Appearance.BackColor = Color.FromArgb(SchedulerLabels.First(l => l.SortIndex == 99).ColourRGB); } if (status != null) { e.ViewInfo.Status = statuses.Items.Find(s => s.Id.ToString() == status.Id.ToString()); } else { e.ViewInfo.Status = statuses.Items.CreateNewStatus(Guid.NewGuid(), "", "", new SolidBrush(Color.FromArgb(SchedulerStatuses.First(s => s.SortIndex == 99).ColourRGB))); } } } } catch (Exception ex) { Logger.Error(ex.Message, ex); #if DEBUG throw ex; #endif } }
public override void OnAddData() { base.OnAddData(); ApptLabel newLabel = defaultBindingSource.AddNew() as ApptLabel; Type newLabelInterfaceType = Type.GetType(newLabel.UseInterfaceType); if (newLabelInterfaceType == typeof(IEntityWithStatusLabels)) { newLabel.LabelCriteria = "([LabelKey] = '0')"; lblInfo.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; ctrl_FilterControl.Enabled = false; } else { lblInfo.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; } defaultBindingSource.Position = defaultBindingSource.IndexOf(newLabel); defaultBindingSource.ResetCurrentItem(); }
/// <summary> /// Store the label to the database and sets the default criteria string only if the id is 0. /// Otherwise just return a the record. /// </summary> /// <param name="labels">The label check if its new.</param> /// <param name="modifyUser">the user to log as the created or modified user</param> /// <param name="_repository">repository used for saving info</param> /// <returns></returns> private List <ApptLabelDto> StoreLabels(List <ApptLabelDto> labels, string modifyUser, IDataRepositoryCrudBase <ApptLabel> _repository) { List <ApptLabel> saveList = new List <ApptLabel>(); foreach (var label in labels) { ApptLabel lbl = label.ConvertTo <ApptLabel>(); if (label.Id == 0) { //then save the label, to get an ID, lbl = _repository.CreateUpdate(lbl, modifyUser); //then but also set the criteria to the correct value and save it again.. if (Type.GetType(lbl.UseInterfaceType) == typeof(IEntityWithStatusLabels)) { lbl.LabelCriteria = $"([LabelKey] = '{lbl.Id}')"; } } saveList.Add(lbl); } return(_repository.CreateUpdateList(saveList, modifyUser).ConvertAllTo <ApptLabelDto>().ToList()); }