protected void Page_Load(object sender, EventArgs e)
        {
            var clientGroupContext = new GroupBuilder.ClientGroupContextService();

            Page.Form.Controls.Add(clientGroupContext);
            if (!ApplicationContext.Current.Services.Contains(clientGroupContext.GetType()))
            {
                ApplicationContext.Current.Services.Add(clientGroupContext);
            }

            Timeless.CheckedChanged += Timeless_ChangeAction;
            btnOk.Click             += BtnOk_ClickAction;
            btnCancel.Click         += BtnCancelClick;

            _mainTable = Request.Params["maintable"];
            if (!string.IsNullOrEmpty(_mainTable))
            {
                if (_mainTable.ToUpper() == "LEAD")
                {
                    IsLead = true;
                }
            }

            if (!IsPostBack)
            {
                History hist = GetHistoryRecord();
                Completed.DateTimeValue = hist.CompletedDate;
                Scheduled.DateTimeValue = hist.StartDate;
                Duration.Value          = ((hist.Duration == 0) ? 1 : hist.Duration);
                Timeless.Checked        = hist.Timeless;
                if (!IsLead)
                {
                    luContact.LookupResultValue     = hist.ContactId;
                    luContact.SeedValue             = hist.AccountId;
                    luOpportunity.LookupResultValue = hist.OpportunityId;
                    luOpportunity.SeedValue         = hist.AccountId;
                    luTicket.LookupResultValue      = hist.TicketId;
                    luTicket.SeedValue          = hist.AccountId;
                    luAccount.LookupResultValue = hist.AccountName;
                }
                else
                {
                    ContactIdDiv.Style.Value     = "display:none";
                    OpportunityIdDiv.Style.Value = "display:none";
                    TicketIdDiv.Style.Value      = "display:none";
                    AccountIdDiv.Style.Value     = "display:none";
                    LeadIdDiv.Style.Value        = "";
                    luLead.LookupResultValue     = hist.LeadId;
                    FollowUp.Enabled             = false;
                    CarryOverNotes.Enabled       = false;
                }
                Description.PickListValue = hist.Description;
                Notes.Text                   = hist.LongNotes;
                Priority.PickListValue       = hist.Priority;
                Category.PickListValue       = hist.Category;
                CreateUser.LookupResultValue = hist.CreateUser;
                Result.PickListValue         = string.IsNullOrEmpty(hist.Result) ? "Complete" : hist.Result;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var clientGroupContext = new GroupBuilder.ClientGroupContextService();
            Page.Form.Controls.Add(clientGroupContext);
            if (!ApplicationContext.Current.Services.Contains(clientGroupContext.GetType()))
                ApplicationContext.Current.Services.Add(clientGroupContext);

            Timeless.CheckedChanged += Timeless_ChangeAction;
            btnOk.Click += BtnOk_ClickAction;
            btnCancel.Click += BtnCancelClick;

            _mainTable = Request.Params["maintable"];
            if (!string.IsNullOrEmpty(_mainTable))
            {
                if (_mainTable.ToUpper() == "LEAD")
                {
                    IsLead = true;
                }
            }

            if (!IsPostBack)
            {
                History hist = GetHistoryRecord();
                Completed.DateTimeValue = hist.CompletedDate;
                Scheduled.DateTimeValue = hist.StartDate;
                Duration.Value = ((hist.Duration == 0) ? 1 : hist.Duration);
                Timeless.Checked = hist.Timeless;
                if (!IsLead)
                {
                    luContact.LookupResultValue = hist.ContactId;
                    luContact.SeedValue = hist.AccountId;
                    luOpportunity.LookupResultValue = hist.OpportunityId;
                    luOpportunity.SeedValue = hist.AccountId;
                    luTicket.LookupResultValue = hist.TicketId;
                    luTicket.SeedValue = hist.AccountId;
                    luAccount.LookupResultValue = hist.AccountName;
                }
                else
                {
                    ContactIdDiv.Style.Value = "display:none";
                    OpportunityIdDiv.Style.Value = "display:none";
                    TicketIdDiv.Style.Value = "display:none";
                    AccountIdDiv.Style.Value = "display:none";
                    LeadIdDiv.Style.Value = "";
                    luLead.LookupResultValue = hist.LeadId;
                    FollowUp.Enabled = false;
                    CarryOverNotes.Enabled = false;
                }
                Description.PickListValue = hist.Description;
                Notes.Text = hist.LongNotes;
                Priority.PickListValue = hist.Priority;
                Category.PickListValue = hist.Category;
                CreateUser.LookupResultValue = hist.CreateUser;
                Result.PickListValue = string.IsNullOrEmpty(hist.Result) ? "Complete" : hist.Result;
            }
        }