Exemple #1
0
        //List of available bookings
        private void lookUpEdit2_EditValueChanged(object sender, EventArgs e)
        {
            this.CreateMeeting.Enabled = true;
            var obj = sender as LookUpEdit;
            var listSubQ = Questionnaire.Form.Settings.AnswerOptions;
            if (obj != null) {
                if (obj.EditValue != null && !string.IsNullOrEmpty(obj.EditValue.ToString())) {
                    PreviewBooking.Enabled = true;
                    //DeleteMeeting.Enabled = true;
                    var row = obj.GetSelectedDataRow() as CTBookingSchedule;
                    if (row != null) {
                        SalesPerson person = new SalesPerson() {
                            Id = row.resource_id,
                            Name = row.resource_name
                        };
                        //lookUpEdit1.Properties.DataSource = new List<SalesPerson> { person };
                        lookUpEdit1.Properties.DataSource = listBookingSalesPerson;
                        lookUpEdit1.EditValue = person.Id;
                        //listBookingSchedules
                        lookUpEdit1_SelectedIndexChanged(lookUpEdit1, null);

                        if (obj.Tag != null) {
                            var data = (ScheduleData)obj.Tag;
                            var tag = data.PositionIndex.ToString();
                            tag = tag.Replace("IndexPosition", "");
                            var oSubQ = listSubQ[int.Parse(tag)];
                            oSubQ.ScheduleValue = new ScheduleValue() {
                                ScheduleId = row.id.ToString(),
                                Description = row.title
                            };
                            Questionnaire.Form.Settings.DataBindings.schedule_id = row.id.ToString();
                            data.HasValue = row.id > 0;

                            /**
                             * if not from the same company,
                             * dont allow edit.
                             */
                            int _id = Convert.ToInt32(obj.EditValue);
                            using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(UserSession.EntityConnection)) {
                                answer _data = _efDbContext.answers.FirstOrDefault(i => i.schedule_id == _id);
                                if (_data != null) {
                                    _efDbContext.Detach(_data);
                                    if (_data.accounts_id != AccountId)
                                        this.CreateMeeting.Enabled = false;
                                }
                                else
                                    this.CreateMeeting.Enabled = false;
                            }
                        }
                    }
                } else {
                    PreviewBooking.Enabled = false;
                    //DeleteMeeting.Enabled = false;
                }

            }

            if (!IsInitializing) {
                if (isLoaded)
                    m_bHasChanged = true;

                if (OnComponentNotifyChanged != null)
                    OnComponentNotifyChanged(this, new ComponentNotifyChangedArgs(isLoaded));
            }

            if (ControlGroup != null)
                ControlGroup.Tag = this;
        }
Exemple #2
0
        private void lookUpEdit1SelectedIndexChanged(SalesPerson person)
        {
            var objSender = lookUpEdit1;
            var listSubQ = Questionnaire.Form.Settings.AnswerOptions;
            if (objSender.Tag != null)
            {
                var data = (ScheduleData)objSender.Tag;
                var tag = data.PositionIndex.ToString();
                tag = tag.Replace("IndexPosition", "");
                var oSubQ = listSubQ[int.Parse(tag)];
                //var person = objSender.GetSelectedDataRow() as SalesPerson;
                if (oSubQ.ScheduleSalesPerson == null)
                    oSubQ.ScheduleSalesPerson = new ScheduleSalesPerson();
                oSubQ.ScheduleSalesPerson.SalesPersonSelectedValue = person;
                data.HasValue = person != null;
            }

            if (!IsInitializing)
            {
                if (isLoaded)
                    m_bHasChanged = true;

                if (OnComponentNotifyChanged != null)
                    OnComponentNotifyChanged(this, new ComponentNotifyChangedArgs(isLoaded));
            }

            if (ControlGroup != null)
                ControlGroup.Tag = this;
        }