Exemplo n.º 1
0
        public void ReloadFromConfig(DisplayConfig config)
        {
            if (Preference.PreferUnicode != config.PreferMetadataInOriginalLanguage.ToBool())
            {
                Preference.PreferUnicode = config.PreferMetadataInOriginalLanguage.ToBool();
                LogUtil.LogSuccess("Metadata In Original Language: " + (Preference.PreferUnicode ? "On" : "Off"));
            }

            if (Render.LimitFps != config.LimitFps.ToInt())
            {
                Render.LimitFps = config.LimitFps.ToInt();
                LogUtil.LogSuccess("Limit Fps: " + Render.LimitFps);
            }

            if (Render.WindowSize.Width != config.WindowWidth.ToInt() || Render.WindowSize.Height != config.WindowHeight.ToInt())
            {
                Render.WindowSize.Width  = config.WindowWidth.ToInt();
                Render.WindowSize.Height = config.WindowHeight.ToInt();
                FormController.CloseDirectXForm();
                LogUtil.LogSuccess("Widow Size: " + Render.WindowSize);
            }

            if (Render.UseVsync != config.Vsync.ToBool())
            {
                Render.UseVsync = config.Vsync.ToBool();
                FormController.CloseDirectXForm();
                LogUtil.LogSuccess("Vsync: " + (Render.UseVsync ? "On" : "Off"));
            }

            FormController.CreateDirectXForm(this, OrtdpController.OsuModel);
        }
Exemplo n.º 2
0
        // СГЕНЕРИРОВАТЬ WORD
        private void button1_Click(object sender, EventArgs e)
        {
            // Сделать стандратный массив значений полей для ввода с формы с ключами для autoit скрипта генерирующего word
            List <ValueControl> controlArrayToString = GeneratorWord.StandartListValueControl(Controls);


            //Явился или не явился
            string resultAppeared = FormController.AppearedOrNotExplanation(checkBoxAppearedOrNot.Checked, radioButtonSexWoomen.Checked);

            GeneratorWord.AddValueControl(ref controlArrayToString, resultAppeared, "#-1"); // в ручную добавляем новый ключ

            // Делаем инициалы ФИО
            string initials = FormController.GetInitials(textBoxFullNameNameIvana.Text, textBoxFullNamePatronymicIvanovicha.Text);

            GeneratorWord.AddValueControl(ref controlArrayToString, initials, "#-2"); // в ручную добавляем новый ключ

            // Указание если явился ,кроме признания своей вины,
            if (checkBoxAppearedOrNot.Checked)
            {
                GeneratorWord.AddValueControl(ref controlArrayToString, ", кроме признания своей вины,", "#-3"); // в ручную добавляем новый ключ
            }
            else
            {
                GeneratorWord.AddValueControl(ref controlArrayToString, "", "#-3"); // в ручную добавляем новый ключ
            }


            // Вставляем название в буфер обмена
            FormController.ClipPutNameWord(textBoxClipPutNum.Text, textBoxClipPutName.Text, this.Text);

            FormController.GenerateWord(controlArrayToString, radioButtonSexMen.Checked, "ст 15.33 Муж", "ст 15.33 Жен");
        }
        protected override void CompleteDialogExtention()
        {
            var aggregatedSettings = ApplicationController.ResolveType <SettingsAggregator>();

            var viewModels = new List <RecordEntryFormViewModel>();

            foreach (var type in aggregatedSettings.SettingTypes)
            {
                var mapper   = new ClassSelfMapper();
                var instance = mapper.Map(ApplicationController.ResolveType(type));

                var viewModel = new ObjectEntryViewModel(null, null, instance, FormController.CreateForObject(instance, ApplicationController, null));
                viewModel.DisplayRightEdgeButtons = false;
                viewModel.OnSave = () =>
                {
                    ApplicationController.ResolveType <ISettingsManager>().SaveSettingsObject(instance);
                    ApplicationController.RegisterInstance(instance);
                    viewModel.ValidationPrompt = "The Settings Have Been Saved";
                };
                viewModels.Add(viewModel);
            }
            var mainViewModel = new RecordEntryAggregatorViewModel(viewModels, ApplicationController);

            Controller.LoadToUi(mainViewModel);
        }
Exemplo n.º 4
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            string password        = this.password.Text;
            string confirmPassword = this.confirmPassword.Text;

            if (password != confirmPassword)
            {
                this.confirmPassword.Text = "";
                this.password.Text        = "";
                MessageBox.Show("Passwords did not matched.");
                return;
            }
            UserControllerInterface userController = new UserController();

            user.password = password;
            if (userController.updateUser(user) != null)
            {
                MessageBox.Show("Password successfully updated.");
                FormControllerInterface formController = new FormController();
                formController.showAdminDashBoard(adminDashboard, this);
            }
            else
            {
                MessageBox.Show("Something went wrong, please contact your administrator.");
            }
        }
Exemplo n.º 5
0
        private void UpdateUserForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            FormControllerInterface formController = new FormController();

            formController.showAdminDashBoard(adminDashboard, this);
            //indexForm.Show();
        }
Exemplo n.º 6
0
        /// <summary>
        /// Handles the Click event of the lbLeft control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void lbLeft_Click(object sender, EventArgs e)
        {
            string param = Request.Params.Get("__EVENTARGUMENT");
            Guid   uid   = Guid.Empty;

            try
            {
                uid = new Guid(param);
            }
            catch
            {
                return;
            }

            FormController fController = new FormController(FormDocumentData);
            FormSection    itemSection = fController.GetSectionByUid(uid);

            if (itemSection != null)
            {
                fController.MoveSectionLeft(uid);
            }
            else
            {
                FormItem item = fController.GetSTLItemByUid(uid);
                if (item != null)
                {
                    fController.MoveFormItemLeft(uid);
                }
            }

            BindRendererInner();
        }
        public void RecordEntryViewModelTestAllFieldTypes()
        {
            var applicationController = new FakeApplicationController();
            var settingsObject        = new SettingsTestAllFieldTypes
            {
                SavedInstances = new[]
                {
                    new TestAllFieldTypes()
                    {
                        StringField = "Foo"
                    }
                }
            };

            applicationController.RegisterInstance(typeof(SettingsTestAllFieldTypes), settingsObject);

            //create the form
            var testObject = new TestAllFieldTypes();

            var lookupService  = FakeRecordService.Get();
            var formController = FormController.CreateForObject(testObject, applicationController, lookupService);
            var entryViewModel = new ObjectEntryViewModel(() => { }, () => { }, testObject, formController);

            //populate all the fields
            entryViewModel.LoadFormSections();
            PopulateRecordEntry(entryViewModel, populateSubgrids: true);

            //save the record
            Assert.IsTrue(entryViewModel.Validate());
            entryViewModel.SaveButtonViewModel.Invoke();
        }
Exemplo n.º 8
0
        private void BindRenderer()
        {
            FormDocumentData = null;
            try
            {
                FormDocumentData = FormDocument.Load(MetaClassName, FormName);

                if (FormDocumentData == null)
                {
                    FormDocumentData = FormController.ReCreateFormDocument(MetaClassName, FormName);
                }

                if (MetaUIManager.MetaUITypeIsSystem(FormDocumentData.MetaClassName, FormDocumentData.MetaUITypeId) ||
                    FormName == FormDocumentData.MetaUITypeId)
                {
                    lblFormName.Text = CHelper.GetFormName(FormName);
                }
                else
                {
                    lblFormName.Text = String.Format("{0} ({1})", CHelper.GetFormName(FormName), CHelper.GetFormName(FormDocumentData.MetaUITypeId));
                }
            }
            catch { }
            BindRendererInner();
        }
Exemplo n.º 9
0
        private void viewPayslipButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (payrollListBox.SelectedIndex != -1)
                {
                    int payslipId = Convert.ToInt32(payrollListBox.SelectedItem.ToString().Split('.')[0]);
                    PayrollControllerInterface payrollController = new PayrollController();
                    Payslip payslip = payrollController.fetchPayslipById(payslipId);

                    EmployeeControllerInterface employeeController = new EmployeeController();
                    payslip.employee = employeeController.fetchEmployeeById(payslip.employee.id);

                    FormControllerInterface formController = new FormController();
                    formController.showUserPayroll(this, payslip);
                }
                else
                {
                    showErrorMessage("Please select a record to view.");
                }
            }
            catch (FormatException ex)
            {
                Console.WriteLine("No item selected: " + ex.Message);
            }
        }
Exemplo n.º 10
0
        // Загрузить сохраненные поля
        private void buttonLoad_Click(object sender, EventArgs e)
        {
            // получаем заполненные сейвом контролы
            var controls = FormController.GetControlsLoadForm(Controls, nameForm, ref comboBoxLoad);

            UpdateControls(controls);
        }
Exemplo n.º 11
0
        // For Creating Undergraduate Student
        private void btnCreateUndergrad_Click(object sender, EventArgs e)
        {
            btnCreate.Enabled        = true;
            selectedMember           = 1;
            btnCreateGrad.Enabled    = false;
            btnCreateFaculty.Enabled = false;
            btnCreateChair.Enabled   = false;

            //enable inputs:
            txtID.Enabled = true;
            txtID.Focus();
            txtID.Select();
            txtName.Enabled    = true;
            dtBday.Enabled     = true;
            txtMajor.Enabled   = true;
            txtGPA.Enabled     = true;
            menuYear.Enabled   = true;
            txtTuition.Enabled = true;
            txtCredits.Enabled = true;


            FormController.formAddMode(this);
            FormController.activateUndergraduateStudent(this);
            addMode = true;
        }
Exemplo n.º 12
0
 // Clears form and disables edit mode buttons
 private void btnClearForm_Click(object sender, EventArgs e)
 {
     FormController.clear(this);
     btnDisplay.Enabled = false;
     btnEdit.Enabled    = false;
     btnDelete.Enabled  = false;
 }
Exemplo n.º 13
0
 //startup:
 public frmMainForm()
 {
     InitializeComponent();
     FormController.resetForm(this);
     FormController.clear(this);
     db.createOwlMemberList();
 }
        /// <summary>
        /// 发送任务
        /// </summary>
        public int sendTask(TaskRecord tr)
        {
            int result = 0;

            Console.WriteLine("ready to send task: " + tr.singleTask.taskName + "forklist stat:" + getForkLift().taskStep + "forklift finished:" + getForkLift().finishStatus);

            string cmd = "cmd=set task by name;name=" + tr.taskRecordName;             //发送命令格式,如果有多个对应值用;隔开,如果后面没有命令了,不需要再加;号

            Console.WriteLine("send msg :" + cmd + "to " + getForkLift().forklift_number);

            lock (getAGVSocketClient().clientLock) {
                try {
                    getAGVSocketClient().SendMessage(cmd);                      //确保发送成功

                    tr.taskRecordStat      = TASKSTAT_T.TASK_SEND;
                    tr.singleTask.taskStat = TASKSTAT_T.TASK_SEND;
                    FormController.getFormController().getMainFrm().updateFrm();                     //设置更新界面
                    tr.forkLiftWrapper        = this;
                    getForkLift().taskStep    = TASK_STEP.TASK_SENDED;
                    getForkLift().currentTask = tr.singleTask.taskText;
                    DBDao.getDao().UpdateTaskRecord(tr);
                    DBDao.getDao().updateForkLift(this);                      //更新车子状态
                } catch (Exception ex) {
                    Console.WriteLine(ex.ToString());
                    AGVLog.WriteError("发送" + tr.singleTask.taskText +
                                      " 任务到" + getForkLift().forklift_number + "号车 失败",
                                      new StackFrame(true));
                    result = -1;
                }
                AGVLog.WriteError("发送" + tr.singleTask.taskText +
                                  " 任务到" + getForkLift().forklift_number + "号车 成功",
                                  new StackFrame(true));
                return(result);
            }
        }
Exemplo n.º 15
0
        public void Index_Post_Should_Return_Not_Found()
        {
            //arrange
            const string id = "123";
            //Controller needs a controller context
            var httpContext = new DefaultHttpContext();
            var controllerContext = new ControllerContext()
            {
                HttpContext = httpContext,
            };
            PageVM returnPage = null;
            var mockValidation = new Mock<IGdsValidation>();
            var mockSession = new Mock<ISessionService>();
            var mockLogger = new Mock<ILogger<FormController>>();
            var mockPageHelper = new Mock<IPageHelper>();
            mockPageHelper.Setup(x => x.CheckPageHistory(returnPage, It.IsAny<string>(), false, mockSession.Object, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>())).Returns(true);

            mockSession.Setup(x => x.GetPageById(id, false)).Returns(returnPage).Verifiable();
            var mockSettings = new Mock<IOptions<ApplicationSettings>>();
            var sut = new FormController(mockValidation.Object, mockSession.Object, mockSettings.Object, mockLogger.Object, mockPageHelper.Object) { ControllerContext = controllerContext };
            //act
            var result = sut.Index(new CurrentPageVM { PageId = id });
            //assert
            var statusResult = result as StatusResult;
            statusResult.StatusCode.Should().Be(564);
            mockSession.Verify();
        }
Exemplo n.º 16
0
        private async void Save_Clicked(object sender, EventArgs e)
        {
            //If entries are valid
            if (MasterModel.vd.FormEntriesValid(FormController.GetAllEntries(gridForm)) == true)
            {
                try
                {
                    //Save
                    SelectedType.Reps     = RepController.SaveRepsFromEntries(gridForm, repeatableLblText);
                    Exercise.Types[Index] = SelectedType;
                    await MasterModel.DAL.SaveSelectedExerciseAsync(Exercise);

                    await Navigation.PopAsync();
                }
                catch (Exception ex)
                {
                    //Display error
                    await DisplayAlert("Error", ex.Message, "OK");

                    throw;
                }
            }
            //Entries are invalid
            else
            {
                //Display error
                await DisplayAlert("Error", MasterModel.vd.error, "OK");
            }
        }
Exemplo n.º 17
0
 /// <summary>
 /// Lấy dữ liệu để phục vụ việc cấu hình
 /// </summary>
 private void LoadDataForConfig()
 {
     try
     {
         if (OneManyForm.formInfo == null)
         {
             OneManyForm.formInfo = FormController.GetInstance().GetForm(this.GridPanelName + "OneManyForm");
         }
         List <OneManyFormInfo> rs = OneManyFormController.GetInstance()
                                     .GetAll(this.GridPanelName + "OneManyForm", 1);
         List <string> table =
             (from t in SoftCore.Util.GetInstance().GetRelationTable(OneManyForm.formInfo.TableName)
              where rs.Where(p => p.TableName == t).Count() == 0
              select t).ToList();
         foreach (string item in table)
         {
             Ext.Net.ListItem list = new Ext.Net.ListItem(item, item);
             cbTable.Items.Add(list);
         }
     }
     catch (Exception ex)
     {
         Dialog.ShowNotification("OneManyForm / LoadDataForConfig() = " + ex.Message);
     }
 }
Exemplo n.º 18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="value">Giá trị của khóa chính</param>
        public void SetValue(object value)
        {
            try
            {
                if (value == null)
                {
                    return;
                }
                OneManyForm.formInfo = FormController.GetInstance().GetForm(this.GridPanelName + "OneManyForm");
                if (string.IsNullOrEmpty(hdfPrimaryColumnName.Text))
                {
                    hdfPrimaryColumnName.Text = Util.GetInstance().GetPrimaryKeyOfTable(OneManyForm.formInfo.TableName);
                }

                OneManyForm.PrimaryColumnName = hdfPrimaryColumnName.Text;
                OneManyForm.CommandButton     = Command.Update; //Xem xét sửa lại
                OneManyForm.SetValue(value);
                hdfCurrentRecordID.Text  = value.ToString();
                hdfCurrentTableName.Text = OneManyForm.formInfo.TableName;
                OneManyForm.ReloadTableDetail(value.ToString());
            }
            catch (Exception ex)
            {
                Dialog.ShowNotification("Function GetFirstRecord: = " + ex.Message);
            }
        }
Exemplo n.º 19
0
        public void Controller_PostIndex_RaisesBeforeAction()
        {
            bool beforeActionRisen = false;
            SitefinityEventHandler <BeforeFormActionEvent> beforeActionHandler = (BeforeFormActionEvent @event) =>
            {
                beforeActionRisen = true;
            };

            try
            {
                EventHub.Subscribe <BeforeFormActionEvent>(beforeActionHandler);

                var model = new FormModel();
                model.FormId = FormEventsTests.formId;

                var formController = new FormController();
                formController.Model = model;

                var values = new NameValueCollection();
                values.Add(FormEventsTests.FieldName, "text");
                formController.Index(new System.Web.Mvc.FormCollection(values));

                Assert.IsTrue(beforeActionRisen, "Before Form Action event was not risen.");
            }
            finally
            {
                EventHub.Unsubscribe <BeforeFormActionEvent>(beforeActionHandler);
            }
        }
Exemplo n.º 20
0
    static bool Generate()
    {
        if (CurrentLevel.Data != null)
        {
            int CountX = 40;
            int CountY = -40;

            foreach (LevelData ld in CurrentLevel.Data)
            {
                FormController Cache = instance.SpawnForm(ld.FormName);
                if (Cache != null && ld != null)
                {
                    Cache.xpos = ld.xinbottom * 2;
                    Cache.ypos = ld.yinbottom * 2;
                    instance.StartCoroutine(instance.waitForFormLoad(Cache, ld));
                }

                CountX += 100;
                if (CountX > 300)
                {
                    CountY -= 100;
                    CountX  = 40;
                }
            }

            return(true);
        }

        return(false);
    }
Exemplo n.º 21
0
 //search for an owl member using the 9 digit ID
 private void btnFind_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(txtEnterID.Text) || String.IsNullOrWhiteSpace(txtEnterID.Text) || (txtEnterID.Text.Length != 9))
     {
         MessageBox.Show("Please enter an extisting 9-Digit TUID. This Field cannot be blank");
         txtEnterID.Text = "";
         txtEnterID.Focus();
         txtEnterID.Select();
     }
     else
     {
         FormController.deactivateAddButtons(this);
         if (GlobalData.database.SelectOwlMember(Convert.ToInt32(txtEnterID.Text), this))
         {
             btnEdit.Enabled        = true;
             btnProcessEdit.Enabled = true;
             btnDelete.Enabled      = true;
             MessageBox.Show("Person found");
         }
         else
         {
             MessageBox.Show("No member exists with that TUID.", "Owl Member Not Found");
             txtEnterID.Text = "";
             txtEnterID.Focus();
             txtEnterID.Select();
         }
     }
 }
Exemplo n.º 22
0
        public void Index_Should_Return_566_Error()
        {
            const string id = "123";
            //arrange
            //Controller needs a controller context
            var httpContext       = new DefaultHttpContext();
            var controllerContext = new ControllerContext()
            {
                HttpContext = httpContext,
            };
            PageVM returnPage     = new PageVM();
            var    mockValidation = new Mock <IGdsValidation>();
            var    mockSession    = new Mock <ISessionService>();
            var    mockLogger     = new Mock <ILogger <FormController> >();

            mockSession.Setup(x => x.GetPageById(id, false)).Throws(new Exception());
            mockSession.Setup(x => x.GetUserSession()).Returns(new UserSessionVM {
                LocationName = ""
            }).Verifiable();

            var mockSettings = new Mock <IOptions <ApplicationSettings> >();
            var sut          = new FormController(mockValidation.Object, mockSession.Object, mockSettings.Object, mockLogger.Object)
            {
                ControllerContext = controllerContext
            };

            //act
            var result = sut.Index(id);

            //assert
            var statusResult = result as StatusResult;

            statusResult.StatusCode.Should().Be(566);
            mockSession.Verify();
        }
Exemplo n.º 23
0
        protected void AddObjectToUi(object objectToDisplay, Action nextAction = null, string nextActionLabel = null, Action cancelAction = null, Action backAction = null)
        {
            var vm = new ObjectDisplayViewModel(objectToDisplay, FormController.CreateForObject(objectToDisplay, ApplicationController, null)
                                                , nextAction: nextAction, nextActionLabel: nextActionLabel, cancelAction: cancelAction, backAction: backAction);

            Controller.LoadToUi(vm);
        }
Exemplo n.º 24
0
        public void Highlight(int id)
        {
            String action = string.Format("set TitleStyle='{0}'", strUtil.SqlClean(FormController.GetTitleStyle(ctx), 150));

            ForumTopic.updateBatch(action, "Id in (" + idList + ")");
            log(idList, ForumLogAction.Highlight);
        }
Exemplo n.º 25
0
        public void Index_Should_Return_561_Error()
        {
            const string id = "123";
            //arrange
            //Controller needs a controller context
            var httpContext = new DefaultHttpContext();
            var controllerContext = new ControllerContext()
            {
                HttpContext = httpContext,
            };

            var mockValidation = new Mock<IGdsValidation>();
            var mockSession = new Mock<ISessionService>();
            var mockLogger = new Mock<ILogger<FormController>>();
            var mockPageHelper = new Mock<IPageHelper>();

            mockSession.Setup(x => x.GetUserSession()).Returns(new UserSessionVM { LocationName = null }).Verifiable();

            ApplicationSettings appSettings = new ApplicationSettings() { FormStartPage = "123" };
            IOptions<ApplicationSettings> options = Options.Create(appSettings);

            var sut = new FormController(mockValidation.Object, mockSession.Object, options, mockLogger.Object, new Mock<IPageHelper>().Object) {ControllerContext = controllerContext};

            //act
            var result = sut.Index(id);

            //assert
            var statusResult = result as StatusResult;
            statusResult.StatusCode.Should().Be(561);
            mockSession.Verify();
        }
Exemplo n.º 26
0
        private void SetNewAction()
        {
            if (RecordEntryViewModel.AllowNewLookup && LookupFormService != null && LookupFormService.GetFormMetadata(RecordTypeToLookup, LookupService) != null && FormService != null && FormService.AllowAddNew(FieldName, GetRecordType()))
            {
                NewAction = () =>
                {
                    var formController = new FormController(LookupService, LookupFormService, ApplicationController);
                    var newRecord      = LookupService.NewRecord(RecordTypeToLookup);

                    Action onSave = () =>
                    {
                        Value = LookupService.ToLookup(newRecord);
                        if (UsePicklist)
                        {
                            var newPicklistItem = new ReferencePicklistItem(newRecord, Value.Name);
                            ItemsSource = ItemsSource
                                          .Union(new[] { newPicklistItem })
                                          .OrderBy(r => r.Name)
                                          .ToArray();
                            SelectedItem = newPicklistItem;
                        }
                        SetEnteredTestWithoutClearingValue(Value.Name);
                        RecordEntryViewModel.ClearChildForm();
                    };

                    var newForm = new CreateOrUpdateViewModel(newRecord, formController, onSave, RecordEntryViewModel.ClearChildForm);
                    RecordEntryViewModel.LoadChildForm(newForm);
                };
            }
            else
            {
                NewAction = null;
            }
        }
Exemplo n.º 27
0
        private void Initialize <TForm>(FormController controller, TForm form)
            where TForm : Form, new ()
        {
            var initializable = controller as IInitializableController;

            initializable.Initialize(form, EDBitorApp.Instance);
        }
Exemplo n.º 28
0
 private void InitUpdateForm()
 {
     try
     {
         if (_formInfo == null)
         {
             _formInfo = FormController.GetInstance().GetForm(_FormName);
         }
         txtTitle.Text      = _formInfo.Title;
         txtIcon.Text       = _formInfo.Icon;
         SpinnerHeight.Text = _formInfo.Height.ToString();
         SpinnerWidth.Text  = _formInfo.Width.ToString();
         TableList1.Visible = _AllowChangeTable;
         TableList1.SetValue(_formInfo.TableName);
         chkResizeable.Checked = _formInfo.Resizeable;
         cbCommandButton.SetValue(_formInfo.CommandButton);
         //load cột ngày tháng để config bắt lỗi ngày tháng
         List <FormElementInfo> FieldList = (from t in FormController.GetInstance().GetForm(_FormName).GetFormElements(-1)
                                             where t.Type.Equals("System.DateTime")
                                             select t).ToList();
         foreach (var item in FieldList)
         {
             cbStartDate.Items.Add(new Ext.Net.ListItem(item.ColumnName, item.ColumnName));
             cbEndDate.Items.Add(new Ext.Net.ListItem(item.ColumnName, item.ColumnName));
         }
     }
     catch (Exception ex)
     {
         Dialog.ShowError("ConfigLayout/InitUpdateForm() = " + ex.Message);
     }
 }
Exemplo n.º 29
0
        public void Index_Should_Return_566_Error()
        {
            const string id = "123";
            //arrange
            //Controller needs a controller context
            var httpContext = new DefaultHttpContext();
            var controllerContext = new ControllerContext()
            {
                HttpContext = httpContext,
            };
            PageVM returnPage = new PageVM();
            var mockValidation = new Mock<IGdsValidation>();
            var mockSession = new Mock<ISessionService>();
            var mockLogger = new Mock<ILogger<FormController>>();
            var mockPageHelper = new Mock<IPageHelper>();
            mockPageHelper.Setup(x => x.CheckPageHistory(returnPage, It.IsAny<string>(), false, mockSession.Object, It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<bool>())).Returns(true);

            mockSession.Setup(x => x.GetPageById(id, false)).Throws(new Exception());
            mockSession.Setup(x => x.GetUserSession()).Returns(new UserSessionVM { LocationName = "" }).Verifiable();

            ApplicationSettings appSettings = new ApplicationSettings() { SiteTextStrings = textStrings };
            IOptions<ApplicationSettings> mockSettings = Options.Create(appSettings);

            var sut = new FormController(mockValidation.Object, mockSession.Object, mockSettings, mockLogger.Object, mockPageHelper.Object) { ControllerContext = controllerContext };

            //act
            var result = sut.Index("", id);

            //assert
            var statusResult = result as StatusResult;
            statusResult.StatusCode.Should().Be(562);
            //mockSession.Verify();
        }
Exemplo n.º 30
0
 public CreateOrUpdateViewModel(IRecord record, FormController formController, Action postSave, Action onCancel, bool explicitIsCreate = false)
     : base(formController)
 {
     _record    = record;
     RecordType = record.Type;
     OnSave     = () =>
     {
         LoadingViewModel.IsLoading = true;
         try
         {
             if (GetRecord().Id == null || explicitIsCreate)
             {
                 GetRecord().Id = RecordService.Create(GetRecord());
             }
             else
             {
                 RecordService.Update(GetRecord(), ChangedPersistentFields);
             }
             if (postSave != null)
             {
                 postSave();
             }
             LoadingViewModel.IsLoading = true;
         }
         finally
         {
             LoadingViewModel.IsLoading = false;
         }
     };
     OnCancel = onCancel;
 }
Exemplo n.º 31
0
        protected void btnSave_ServerClick(object sender, EventArgs e)
        {
            Page.Validate();
            if (!Page.IsValid)
                return;

            FormController fc = new FormController(FormDocumentData);
            if (!String.IsNullOrEmpty(itemUid)) //edit
            {
                FormSectionData = fc.GetSectionByUid(new Guid(itemUid));

                FormSectionData.BorderType = (cbShowBorder.Checked ? 1 : 0);
                FormSectionData.ShowLabel = cbShowTitle.Checked;
                FormLabel lbl = null;
                foreach (FormLabel temp in FormSectionData.Labels)
                {
                    if (temp.Code.ToLower().Equals(Thread.CurrentThread.CurrentUICulture.Name.ToLower()))
                        lbl = temp;
                }
                if (lbl == null)
                {
                    lbl = new FormLabel();
                    lbl.Code = Thread.CurrentThread.CurrentUICulture.Name.ToLower();
                    FormSectionData.Labels.Add(lbl);
                }
                lbl.Title = txtTitle.Text;
                foreach (Control c in phProperties.Controls)
                {
                    if (c is SmartTableLayoutProperties)
                    {
                        SmartTableLayoutProperties sp = (SmartTableLayoutProperties)c;
                        FormSectionData.Control.CellPadding = sp.CellPadding;
                        if (!String.IsNullOrEmpty(sp.Columns))
                            FormSectionData.Control.Columns = sp.Columns;
                    }
                }
            }
            else //create
            {
                if (ddControl.SelectedValue.Equals(FormController.SmartTableLayoutType))
                {
                    int cellPadding = 5;
                    string columns = "50%;*";
                    foreach (Control c in phProperties.Controls)
                    {
                        if (c is SmartTableLayoutProperties)
                        {
                            SmartTableLayoutProperties sp = (SmartTableLayoutProperties)c;
                            cellPadding = sp.CellPadding;
                            if (!String.IsNullOrEmpty(sp.Columns))
                                columns = sp.Columns;
                        }
                    }
                    BorderType bType = (cbShowBorder.Checked ? BorderType.TemplateBorder : BorderType.None);
                    FormSection newSection = FormController.CreateSectionSTL(bType, cbShowBorder.Checked, txtTitle.Text, Unit.Percentage(100), columns, cellPadding);
                    fc.AddSection(newSection);
                }
            }

            string newUid = Guid.NewGuid().ToString("N");
            Session[newUid] = FormDocumentData;
            CloseAndRefresh(newUid);
        }
Exemplo n.º 32
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(_propertyPath))
            {
                Control control = this.Page.LoadControl(_propertyPath);
                control.ID = "propCtrl";
                phProperties.Controls.Add(control);
            }
            if (!Page.IsPostBack)
            {
                if (FormDocumentData == null)
                    FormDocumentData = ((FormDocument)Session[uid]).Copy();
                if (FormDocumentData == null)
                    throw new Exception("FormDocument is undefined!");

                int rowSpan = 3;

                if (!String.IsNullOrEmpty(itemUid) && itemUid != "0")
                {
                    FormController fc = new FormController(FormDocumentData);
                    FormItemData = fc.GetSTLItemByUid(new Guid(itemUid));
                    if (_add) // create
                    {
                        if (FormItemData != null)
                            FormSectionData = fc.GetSectionForFormItem(FormItemData);
                        else
                            FormSectionData = fc.GetSectionByUid(new Guid(itemUid));
                        if (FormSectionData == null)
                            throw new Exception("FormSection is not defined.");

                        #region Create
                        lblTitle.Text = GetGlobalResourceObject("IbnFramework.MetaForm", "AddField").ToString();
                        lblComments.Text = GetGlobalResourceObject("IbnFramework.MetaForm", "AddFieldComment").ToString();
                        txtTitle.Text = "";
                        txtLabelWidth.Text = "120";
                        TabIndexText.Text = "0";

                        rbDefault.Checked = true;
                        this.Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString("N"),
                            "ModifyTxt(0);", true);

                        lblControl.Visible = false;
                        ddControl.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.MetaForm", FormController.MetaPrimitiveControlType).ToString(), FormController.MetaPrimitiveControlType));

                        BindPropertiesControl(ddControl.SelectedValue);
                        #endregion
                    }
                    else	//edit
                    {
                        if (FormItemData != null)
                        {
                            #region Edit
                            lblTitle.Text = GetGlobalResourceObject("IbnFramework.MetaForm", "EditField").ToString();
                            lblComments.Text = GetGlobalResourceObject("IbnFramework.MetaForm", "EditFieldComment").ToString();

                            rowSpan = fc.GetMaxRowSpan(FormItemData);

                            ddControl.Visible = false;
                            #endregion
                        }
                        else
                            throw new Exception("FormItem is not defined.");
                    }
                }
                else
                    throw new Exception("There is no selected item on the form!");

                for (int i = 1; i <= rowSpan; i++)
                    ddRows.Items.Add(new ListItem(i.ToString(), i.ToString()));

                if (!_add && FormItemData != null)
                    BindValues();
            }
            btnSave.InnerText = GetGlobalResourceObject("IbnFramework.MetaForm", "Save").ToString();
            btnCancel.InnerText = GetGlobalResourceObject("IbnFramework.MetaForm", "Cancel").ToString();
            rbNone.Text = GetGlobalResourceObject("IbnFramework.MetaForm", "HideLabel").ToString();
            rbDefault.Text = GetGlobalResourceObject("IbnFramework.MetaForm", "SystemLabel").ToString();
            rbCustom.Text = GetGlobalResourceObject("IbnFramework.MetaForm", "CustomLabel").ToString();
            //TEMP/
            divSelector.Visible = false;
        }
Exemplo n.º 33
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(_propertyPath))
            {
                Control control = this.Page.LoadControl(_propertyPath);
                control.ID = "propCtrl";
                phProperties.Controls.Add(control);
            }
            if (!Page.IsPostBack)
            {
                if (FormDocumentData == null)
                    FormDocumentData = ((FormDocument)Session[uid]).Copy();
                if (FormDocumentData == null)
                    throw new Exception("FormDocument is undefined!");

                if (!String.IsNullOrEmpty(itemUid) && itemUid != "0")
                {
                    #region Edit
                    lblTitle.Text = GetGlobalResourceObject("IbnFramework.MetaForm", "EditSection").ToString();
                    lblComments.Text = GetGlobalResourceObject("IbnFramework.MetaForm", "EditSectionComment").ToString();

                    FormController fc = new FormController(FormDocumentData);
                    FormSectionData = fc.GetSectionByUid(new Guid(itemUid));
                    if (FormSectionData == null)
                        throw new Exception("FormSection is undefined!");
                    ddControl.Visible = false;
                    #endregion
                }
                else
                {
                    #region Create
                    lblTitle.Text = GetGlobalResourceObject("IbnFramework.MetaForm", "AddSection").ToString();
                    lblComments.Text = GetGlobalResourceObject("IbnFramework.MetaForm", "AddSectionComment").ToString();
                    txtTitle.Text = GetGlobalResourceObject("IbnFramework.MetaForm", "Section1").ToString();
                    cbShowBorder.Checked = true;
                    cbShowTitle.Checked = true;

                    lblControl.Visible = false;
                    ddControl.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.MetaForm", FormController.SmartTableLayoutType).ToString(), FormController.SmartTableLayoutType));

                    BindPropertiesControl(ddControl.SelectedValue);
                    #endregion
                }

                if (FormSectionData != null)
                    BindValues();

                cbShowBorder.Text = " " + GetGlobalResourceObject("IbnFramework.MetaForm", "ShowBorderSection").ToString();
                cbShowTitle.Text = " " + GetGlobalResourceObject("IbnFramework.MetaForm", "ShowNameSection").ToString();
            }

            btnSave.InnerText = GetGlobalResourceObject("IbnFramework.MetaForm", "Save").ToString();
            btnCancel.InnerText = GetGlobalResourceObject("IbnFramework.MetaForm", "Cancel").ToString();

            divControl.Visible = false;
        }
 public void TestSetup()
 {
     fRep = new Mock<IFormRepository>();
     dfdRep = new Mock<IDemographicFormDataRepository>();
     vfdRep = new Mock<IVitalsFormDataRepository>();
     hfdRep = new Mock<IHappinessFormDataRepository>();
     efdRep = new Mock<IElectrocardiogramFormDataRepository>();
     ifdRep = new Mock<IInventoryFormDataRepository>();
     afdRep = new Mock<IAdverseEventFormDataRepository>();
     attachmentRep = new Mock<IAttachmentRepository>();
     queryRep = new Mock<IQueryRepository>();
     changeNoteBuilder = new Mock<IChangeNoteBuilder>();
     formController = new FormController(fRep.Object, dfdRep.Object, vfdRep.Object, hfdRep.Object, efdRep.Object,
                                         ifdRep.Object, afdRep.Object, attachmentRep.Object, queryRep.Object, changeNoteBuilder.Object);
 }
Exemplo n.º 35
0
        private void BindValues()
        {
            FormLabel lbl = null;
            foreach (FormLabel temp in FormItemData.Labels)
                if (temp.Code.ToLower().Equals(Thread.CurrentThread.CurrentUICulture.Name.ToLower()))
                    lbl = temp;

            if (lbl != null)
            {
                if (lbl.Title == "[MC_DefaultLabel]" || !FormItemData.ShowLabel)
                {
                    #region Define Classes & Fields
                    string ownName = FormItemData.Control.Source;
                    string aggrName = String.Empty;
                    MetaField fieldOwn = null;
                    MetaClass classOwn = MetaDataWrapper.GetMetaClassByName(FormDocumentData.MetaClassName);
                    MetaField fieldAggr = null;
                    MetaClass classAggr = null;
                    if (ownName.Contains("."))	//aggregation
                    {
                        string[] mas = ownName.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
                        ownName = mas[0];
                        aggrName = mas[1];
                        if (!classOwn.Fields.Contains(ownName))
                            classOwn = classOwn.CardOwner;
                        fieldOwn = classOwn.Fields[ownName];
                        if (fieldOwn.IsAggregation)
                        {
                            string aggrClassName = fieldOwn.Attributes[McDataTypeAttribute.AggregationMetaClassName].ToString();
                            classAggr = MetaDataWrapper.GetMetaClassByName(aggrClassName);
                            if (!classAggr.Fields.Contains(aggrName))
                                classAggr = classAggr.CardOwner;
                            fieldAggr = classAggr.Fields[aggrName];
                        }
                    }
                    else
                    {
                        if (!classOwn.Fields.Contains(ownName))
                            classOwn = classOwn.CardOwner;
                        fieldOwn = classOwn.Fields[ownName];
                    }
                    #endregion

                    string text = String.Empty;
                    if (fieldAggr != null)
                        text = String.Format("{0} - {1}",
                                                CHelper.GetResFileString(fieldOwn.FriendlyName),
                                                CHelper.GetResFileString(fieldAggr.FriendlyName)
                                            );
                    else
                        text = CHelper.GetResFileString(fieldOwn.FriendlyName);

                    txtTitle.Text = CHelper.GetResFileString(text) + ":";
                }
                else
                    txtTitle.Text = lbl.Title;

                if (lbl.Title == "[MC_DefaultLabel]")
                    rbDefault.Checked = true;
            }
            if (!rbDefault.Checked)
            {
                if (FormItemData.ShowLabel)
                    rbCustom.Checked = true;
                else
                    rbNone.Checked = true;
            }
            this.Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString("N"),
                String.Format("ModifyTxt({0});", rbCustom.Checked ? "1" : "0"), true);

            txtLabelWidth.Text = Unit.Parse(FormItemData.LabelWidth).Value.ToString();
            TabIndexText.Text = FormItemData.TabIndex.ToString();

            ddRows.SelectedValue = FormItemData.RowSpan.ToString();
            switch (FormItemData.ColSpan)
            {
                case 1:
                    rb1.Checked = true;
                    break;
                case 2:
                    rb2.Checked = true;
                    break;
                default:
                    rb1.Disabled = true;
                    rb2.Disabled = true;

                    rb1.Checked = false;
                    break;
            }
            FormController fc = new FormController(FormDocumentData);
            if (!fc.CanChangeColspan(FormItemData))
            {
                rb1.Disabled = true;
                rb2.Disabled = true;
            }

            lblControl.Text = String.Format("&lt;{0}&gt;", GetGlobalResourceObject("IbnFramework.MetaForm", "NoControl").ToString());
            if (FormItemData.Control != null && !String.IsNullOrEmpty(FormItemData.Control.Type))
                lblControl.Text = CHelper.GetResFileString(String.Format("{{IbnFramework.MetaForm:{0}}}", FormItemData.Control.Type));

            BindPropertiesControl(FormItemData.Control == null ? "" : FormItemData.Control.Type);
        }
 public void TestSetup()
 {
     attachmentRep = new Mock<IAttachmentRepository>();
     formController = new FormController(null, null, null, null, null, null, null, attachmentRep.Object, null);
 }
 public void TestSetup()
 {
     formController = new FormController(fRep.Object, dfdRep.Object, vfdRep.Object, hfdRep.Object, efdRep.Object,
                                         ifdRep.Object, afdRep.Object, attachmentRep.Object, queryRep.Object);
 }
Exemplo n.º 38
0
        protected void lbRemoveSection_Click(object sender, EventArgs e)
        {
            string param = Request.Params.Get("__EVENTARGUMENT");
            Guid uid = Guid.Empty;
            try
            {
                uid = new Guid(param);
            }
            catch
            {
                return;
            }
            FormController fController = new FormController(FormDocumentData);
            fController.RemoveSection(uid);

            BindRendererInner();
        }
Exemplo n.º 39
0
        protected void lbTop_Click(object sender, EventArgs e)
        {
            string param = Request.Params.Get("__EVENTARGUMENT");
            Guid uid = Guid.Empty;
            try
            {
                uid = new Guid(param);
            }
            catch
            {
                return;
            }

            FormController fController = new FormController(FormDocumentData);
            FormSection itemSection = fController.GetSectionByUid(uid);
            if (itemSection != null)
                fController.MoveSectionUp(uid);
            else
            {
                FormItem item = fController.GetSTLItemByUid(uid);
                if (item != null)
                    fController.MoveFormItemUp(uid);
            }

            BindRendererInner();
        }
            public void TestSetup()
            {
                inventoryData = new InventoryFormData {
                    Id = 12,
                    Form =
                        new Form {
                            Id = 17,
                            Caption = "TestForm",
                            Visit = new Visit {Caption = "TstVisit", Patient = new Patient {PatientNumber = 978}}
                        },
                    BatchNumber = new Question {Value = "15"},
                    QuantityShipped = new Question {Value = "16"},
                    ReceiptDate =
                        new Question {Value = DateTime.Today.ToString(CultureInfo.InvariantCulture)},
                    ShipDate =
                        new Question
                        {Value = DateTime.Today.AddDays(-1).ToString(CultureInfo.InvariantCulture)},
                    MedicationUsage = new List<RepeatableInventoryData> {
                        new RepeatableInventoryData {
                            Id = 34,
                            DateUsed =
                                new Question {
                                    Value =
                                        DateTime.Today.
                                            AddDays(-2).ToString
                                            (CultureInfo.
                                             	InvariantCulture)
                                },
                            QuantityUsed =
                                new Question
                                {Value = "17"}
                        },
                        new RepeatableInventoryData {
                            Id = 35,
                            DateUsed =
                                new Question {
                                    Value =
                                        DateTime.Today.
                                            AddDays(-3).ToString
                                            (CultureInfo.
                                             	InvariantCulture)
                                },
                            QuantityUsed =
                                new Question
                                {Value = "18"}
                        }
                    }
                };

                repeatableInventoryViewModel = new List<RepeatableInventoryDataViewModel> {
                    new RepeatableInventoryDataViewModel {
                        Id = 134,
                        InnerId = 34,
                        DateUsed = DateTime.Today.AddDays(-2),
                        QuantityUsed = 17
                    },
                    new RepeatableInventoryDataViewModel {
                        Id = 135,
                        InnerId = 35,
                        DateUsed =DateTime.Today.AddDays(-3),
                        QuantityUsed = 18
                    }
                };

                newRepeatableInventoryViewModel = new RepeatableInventoryDataViewModel {
                    Id = 0,
                    InnerId = 0,
                    DateUsed = DateTime.Today.AddDays(8),
                    QuantityUsed = 27
                };

                ifdRep = new Mock<IInventoryFormDataRepository>();
                formController = new FormController(null, null, null, null, null, ifdRep.Object, null, null, null);

                session = new Mock<HttpSessionStateBase>();
            }
Exemplo n.º 41
0
        protected void btnSave_ServerClick(object sender, EventArgs e)
        {
            Page.Validate();
            if (!Page.IsValid)
                return;

            FormController fc = new FormController(FormDocumentData);
            if (!_add && FormItemData != null) //edit
            {
                FormItemData = fc.GetSTLItemByUid(new Guid(itemUid));

                FormItemData.ShowLabel = !rbNone.Checked;

                FormLabel lbl = null;
                foreach (FormLabel temp in FormItemData.Labels)
                {
                    if (temp.Code.ToLower().Equals(Thread.CurrentThread.CurrentUICulture.Name.ToLower()))
                        lbl = temp;
                }
                if (lbl == null)
                {
                    lbl = new FormLabel();
                    lbl.Code = Thread.CurrentThread.CurrentUICulture.Name.ToLower();
                    FormItemData.Labels.Add(lbl);
                }
                if (rbDefault.Checked)
                    lbl.Title = FormController.DefaultLabelValue;
                else
                    lbl.Title = txtTitle.Text;

                if (!String.IsNullOrEmpty(txtLabelWidth.Text))
                    FormItemData.LabelWidth = Unit.Pixel(int.Parse(txtLabelWidth.Text)).ToString();

                short tabIndex = 0;
                if (!String.IsNullOrEmpty(TabIndexText.Text.Trim()))
                    tabIndex = short.Parse(TabIndexText.Text.Trim());
                FormItemData.TabIndex = tabIndex;

                FormItemData.RowSpan = int.Parse(ddRows.SelectedValue);
                if (!rb1.Disabled && rb1.Checked)
                    FormItemData.ColSpan = 1;
                if (!rb2.Disabled && rb2.Checked)
                    FormItemData.ColSpan = 2;

                foreach (Control c in phProperties.Controls)
                {
                    if (c is SmartTableLayoutItemProperties)
                    {
                        SmartTableLayoutItemProperties sp = (SmartTableLayoutItemProperties)c;
                        //FormItemData.Control.Source = sp.Source;
                        FormItemData.Control.ReadOnly = sp.ReadOnly;
                    }
                }
            }
            else if (_add && FormSectionData != null)
            {
                FormSectionData = fc.GetSectionByUid(new Guid(FormSectionData.Uid));

                if (ddControl.SelectedValue.Equals(FormController.MetaPrimitiveControlType))
                {
                    string source = String.Empty;
                    bool readOnly = false;
                    foreach (Control c in phProperties.Controls)
                    {
                        if (c is SmartTableLayoutItemProperties)
                        {
                            SmartTableLayoutItemProperties sp = (SmartTableLayoutItemProperties)c;
                            source = sp.Source;
                            readOnly = sp.ReadOnly;
                        }
                    }
                    int colSpan = 1;
                    if (!rb1.Disabled && rb1.Checked)
                        colSpan = 1;
                    if (!rb2.Disabled && rb2.Checked)
                        colSpan = 2;

                    string label = String.Empty;
                    if (rbDefault.Checked)
                        label = FormController.DefaultLabelValue;
                    else if (rbCustom.Checked)
                        label = txtTitle.Text;

                    short tabIndex = 0;
                    if (!String.IsNullOrEmpty(TabIndexText.Text.Trim()))
                        tabIndex = short.Parse(TabIndexText.Text.Trim());

                    FormItem newItem = FormController.CreateFormItemPrimitive(-1, -1,
                        int.Parse(ddRows.SelectedValue), colSpan, !rbNone.Checked,
                        label, Unit.Pixel(int.Parse(txtLabelWidth.Text)), tabIndex, source, readOnly);

                    fc.AddFormItem(newItem, new Guid(FormSectionData.Uid));
                }
            }

            string newUid = Guid.NewGuid().ToString("N");
            Session[newUid] = FormDocumentData;
            CloseAndRefresh(newUid);
        }