Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RunSecurity(CRM.Code.Models.Admin.AllowedSections.NotSet);
            Task = db.CRM_Tasks.FirstOrDefault(f => f.Reference == Entity.TargetReference && Entity.TargetReference != CRM_Calendar.DefaultTargetReference);

            btnSubmitChanges.Visible = PermissionManager.CanUpdate;
            if (!PermissionManager.CanAdd && Entity == null)
            {
                Response.Redirect("list.aspx");
            }

            ucNavCal.Entity   = Entity;
            ucLogNotes.INotes = Entity;

            CRMContext = Entity;
            // buttons //

            btnSubmit.EventHandler        = btnSubmit_Click;
            btnSubmitChanges.EventHandler = btnSubmitChanges_Click;

            // Security //

            btnSubmitChanges.Visible = PermissionManager.CanUpdate;
            if (!PermissionManager.CanAdd && Entity == null)
            {
                Response.Redirect("list.aspx");
            }

            ucListView.Type         = typeof(CRM_TaskParticipant);
            ucListView.ItemsPerPage = 100;
            ucListView.ShowExport   = false;

            if (Task != null)
            {
                ucListView.DataSet = db.CRM_TaskParticipants.Where(t => t.CRM_TaskID == Task.ID).Select(p => (object)p);
            }

            // process //

            if (!IsPostBack)
            {
                if (Task != null)
                {
                    PopulateFields();
                }
                else
                {
                    txtDueDate.Value          = Entity.StartDateTime;
                    txtName.Text              = Entity.DisplayName;
                    lblOwner.Text             = AdminUser.DisplayName;
                    pnlAddParticipant.Visible = false;
                }
            }
        }
Ejemplo n.º 2
0
        protected void SaveRecord(bool newRecord)
        {
            // new record / exiting record //

            object oldEntity = null;

            if (newRecord)
            {
                Task = new CRM_Task();
                Task.OwnerAdminID   = AdminUser.ID;
                Task.CRM_CalendarID = Entity.ID;
                db.CRM_Tasks.InsertOnSubmit(Task);
            }
            else
            {
                oldEntity = Task.ShallowCopy();
            }

            Task.Name        = txtName.Text;
            Task.IsCancelled = chkIsCancelled.Checked;
            Task.IsPublic    = chkIsPublic.Checked;
            Task.DueDate     = txtDueDate.Value;
            Task.Description = txtDescription.Text;
            Task.IsComplete  = chkIsCompleted.Checked;
            db.SubmitChanges();

            if (oldEntity != null)
            {
                CRM.Code.History.History.RecordLinqUpdate(db, AdminUser, oldEntity, Task);
                db.SubmitChanges();
            }
            else
            {
                Entity.TargetReference = Task.Reference;
                db.SubmitChanges();

                AddAdminToTask(AdminUser.ID);

                CRM.Code.History.History.RecordLinqInsert(AdminUser, Task);
            }
        }