Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RunSecurity(CRM.Code.Models.Admin.AllowedSections.NotSet);

            CRM_CalendarCPD = Entity.CRM_CalendarCPDs.FirstOrDefault();

            ucLogHistory.IHistory = CRM_CalendarCPD;
            ucLogNotes.INotes     = Entity;
            ucNavCal.Entity       = Entity;


            CRMContext = Entity;

            // buttons //

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

            // Security //

            btnSubmitChanges.Visible = PermissionManager.CanUpdate;

            ucACSchoolOrganisation.EventHandler = lnkSelectOrganisation_Click;
            ucACSchoolOrganisation.Config       = new AutoCompleteConfig(JSONSet.DataSets.schoolorgs);

            if (!PermissionManager.CanAdd && CRM_CalendarCPD == null)
            {
                Response.Redirect(Entity.DetailsURL);
            }

            if (!Page.IsPostBack)
            {
                ddlLength.DataSource = CRM_CalendarCPD.GetDurationLengths();
                ddlLength.DataBind();

                if (CRM_CalendarCPD != null)
                {
                    ddlPackage.DataSource = from p in db.CRM_Packages
                                            where p.IsActive || CRM_CalendarCPD.CRM_PackageID == p.ID
                                            orderby p.Name
                                            select p;

                    ddlPackage.DataBind();

                    PopulateFields();
                }
                else
                {
                    ddlPackage.DataSource = from p in db.CRM_Packages
                                            where p.IsActive
                                            orderby p.Name
                                            select p;

                    ddlPackage.DataBind();
                }
            }
        }
Example #2
0
        protected void SaveRecord(bool newRecord)
        {
            // new record / exiting record //

            object oldEntity = null;

            if (newRecord)
            {
                CRM_CalendarCPD = new CRM_CalendarCPD();
                CRM_CalendarCPD.CRM_CalendarID = Entity.ID;
                db.CRM_CalendarCPDs.InsertOnSubmit(CRM_CalendarCPD);
            }
            else
            {
                oldEntity = CRM_CalendarCPD.ShallowCopy();
            }


            CRM_CalendarCPD.Attendees = Convert.ToInt32(txtAttendees.Text);

            if (txtConfirmationSent.Text.Length != 0)
            {
                CRM_CalendarCPD.ConfirmationSent = txtConfirmationSent.Value;
            }
            else
            {
                CRM_CalendarCPD.ConfirmationSent = null;
            }

            CRM_CalendarCPD.SchoolOrganisationReference = ucACSchoolOrganisation.SelectedID;
            CRM_CalendarCPD.Length               = Convert.ToByte(ddlLength.SelectedValue);
            CRM_CalendarCPD.CRM_PackageID        = Convert.ToInt32(ddlPackage.SelectedValue);
            CRM_CalendarCPD.ConfirmationInitials = txtInitials.Text;
            db.SubmitChanges();

            if (oldEntity != null)
            {
                CRM.Code.History.History.RecordLinqUpdate(AdminUser, oldEntity, CRM_CalendarCPD);
                db.SubmitChanges();
            }
            else
            {
                CRM.Code.History.History.RecordLinqInsert(AdminUser, CRM_CalendarCPD);
            }
        }