private void DisplayEntityForEdit(int index) { ITimeZoneService service = null; try { //Create a Instance Tks.Entities.TimeZone entity = mTimeZoneList[index]; // Assign to controls. this.hdnTimeZoneId.Value = entity.Id.ToString(); this.txtName.Value = entity.Name; this.txtShortName.Value = entity.ShortName; this.txtDescription.InnerText = entity.Description; this.chkIsActive.Checked = entity.IsActive; // Show/Hide the controls. this.ShowHideEditControls(true); } catch { throw; } finally { if (service != null) { service.Dispose(); } } }
private void FillTimeZones() { ITimeZoneService service = null; try { // Create the service. service = AppService.Create <ITimeZoneService>(); service.AppManager = this.AppManager; List <Tks.Entities.TimeZone> timeZones = service.RetrieveAll(); // Filter valid time zones. IEnumerable <Tks.Entities.TimeZone> validList = from item in timeZones where item.IsActive = true select item; // Bind. this.ddlMiscActivityTimeZoneList.Items.Clear(); this.ddlMiscActivityTimeZoneList.DataTextField = "Name"; this.ddlMiscActivityTimeZoneList.DataValueField = "Id"; this.ddlMiscActivityTimeZoneList.DataSource = validList; this.ddlMiscActivityTimeZoneList.DataBind(); // Add default item. this.ddlMiscActivityTimeZoneList.Items.Insert(0, new ListItem("-- Select --", "0")); // Select first item as default. if (this.ddlMiscActivityTimeZoneList.Items.Count > 0) { this.ddlMiscActivityTimeZoneList.SelectedIndex = 0; } if (this.ddlMiscActivityTimeZoneList.Items.Count == 2) { this.ddlMiscActivityTimeZoneList.SelectedIndex = 1; } } catch { throw; } finally { if (service != null) { service.Dispose(); } } }
public string GetTimeZonesByName(string name) { ITimeZoneService service = null; try { // Create search criteria. TimeZoneSearchCriteria criteria = new TimeZoneSearchCriteria(); criteria.Name = name; // Create the service. service = AppService.Create <ITimeZoneService>(); // TODO: Need to change. UserAuthentication authentication = new UserAuthentication(); service.AppManager = authentication.AppManager; // Call service method. List <Tks.Entities.TimeZone> timeZones = service.Search(criteria); var resultList = from item in timeZones where item.IsActive = true select new { Id = item.Id, Name = item.Name, ShortName = item.ShortName }; // Serialize. JavaScriptSerializer serializer = new JavaScriptSerializer(); string timeZonesJson = serializer.Serialize(resultList); // Return the value. return(timeZonesJson); } catch { throw; } finally { // Dispose. if (service != null) { service.Dispose(); } } }
private void FillTimeZoneList() { ITimeZoneService service = null; try { // Create the service. service = AppService.Create <ITimeZoneService>(); service.AppManager = this.AppManager; // Call method. mTimeZones = service.RetrieveAll(); // Filter active time zones. IEnumerable <Tks.Entities.TimeZone> validTimeZones = from item in mTimeZones where item.IsActive = true select item; // Fill in control. this.ddlTimeZoneList.Items.Clear(); this.ddlTimeZoneList.DataTextField = "Name"; this.ddlTimeZoneList.DataValueField = "Id"; this.ddlTimeZoneList.DataSource = validTimeZones; this.ddlTimeZoneList.DataBind(); // Add default item. this.ddlTimeZoneList.Items.Insert(0, new ListItem("-- Select --", "0")); // Select first item as default. //if (this.ddlTimeZoneList.Items.Count > 0) this.ddlTimeZoneList.Items.FindByValue("0").Selected=true; } catch { throw; } finally { if (service != null) { service.Dispose(); } } }
private void SearchTimeZones() { ITimeZoneService service = null; try { // Get the values. string name = txtSearchName.Value; string shortName = txtSearchShortName.Value; // Validate. this.ValidateSearchEntity(); // Create the service. service = AppService.Create <ITimeZoneService>(); service.AppManager = this.mAppManager; // Build search criteria. TimeZoneSearchCriteria criteria = new TimeZoneSearchCriteria(); criteria.Name = name; criteria.ShortName = shortName; // Invoke service method. mTimeZoneList = service.Search(criteria); if (mTimeZoneList.Count == 0) { this.ShowHideValidationMessage(true); this.HideIntialView(true); //Display a message when Data is Empty. this.divEmptyRow.InnerText = "No Data Found"; } else { this.ShowHideValidationMessage(false); this.HideIntialView(false); this.hdrGridHeader.InnerText = "List of TimeZones: (" + mTimeZoneList.Count + " found)"; } // Display the list. this.divSuccessMessage.InnerText = string.Empty; this.DisplayList(mTimeZoneList); this.DisableRefershControl(); } catch (ValidationException ex) { //Display the validation errors. StringBuilder ErrorMessage = new StringBuilder(); ErrorMessage.Append(string.Format("<table><tr><td>{0}</td></tr>", ex.Message)); foreach (string s in ex.Data.Values) { ErrorMessage.Append(string.Format("<tr><td>{0}</td></tr></table>", s.ToString())); } //Hide the Error message this.divSuccessMessage.Style.Add("display", "block"); this.divSuccessMessage.InnerHtml = ErrorMessage.ToString(); this.HideIntialView(true); //Hide List Found. this.hdrGridHeader.InnerText = string.Empty; //Disable the Refersh control this.LnkRefersh.Enabled = false; } catch { throw; } finally { //Dispose the instance. if (service != null) { service.Dispose(); } } }
public bool UpdateEntity() { ITimeZoneService service = null; bool validateupdate = false; try { // Validate the entity values. if (hdnTimeZoneId.Value != "0") { this.ValidateEntity("Update"); } else { this.ValidateEntity(string.Empty); } // Build entity. Tks.Entities.TimeZone entity = new Tks.Entities.TimeZone(); entity.Id = Int32.Parse(this.hdnTimeZoneId.Value); entity.Name = this.txtName.Value; entity.ShortName = this.txtShortName.Value; entity.Description = this.txtDescription.InnerText.ToString().Replace("<", ""); if (hdnTimeZoneId.Value != "0") { entity.IsActive = this.chkIsActive.Checked; } else { entity.IsActive = true; } entity.Reason = this.txtReason.Value; entity.LastUpdateUserId = 1; entity.LastUpdateDate = DateTime.Now; // Create service and call method. service = AppService.Create <ITimeZoneService>(); service.AppManager = mAppManager; service.Update(entity); // Display succeed message. } catch (ValidationException ve) { // Display validation erros. this.DisplayValidationMessage(ve); validateupdate = true; } catch (Exception ex) { validateupdate = true; throw ex; } finally { if (service != null) { service.Dispose(); } } return(validateupdate); }