Example #1
0
        public override void SetContainer <S, V>(FormSelector <S, V> container)
        {
            if (container != null && !(container is FormSelect))
            {
                throw new ArgumentException();
            }

            this.formSelect = container as FormSelect;
        }
Example #2
0
        public void AKR_CopyDictionary()
        {
            CommandStart.Start(doc =>
            {
                Database db = doc.Database;
                Editor ed   = doc.Editor;
                using (var DocLock = doc.LockDocument())
                {
                    // Запрос имени открытого чертежа в который нужно скопировать словарь
                    //var res = doc.Editor.GetString("Имя чертежа в который копировать словарь АКР");
                    List <SelectObject> docs = new List <SelectObject>();
                    foreach (Document item in Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager)
                    {
                        if (item == doc)
                        {
                            continue;
                        }
                        docs.Add(new SelectObject(item, item.Name));
                    }

                    FormSelect formSelectDoc = new FormSelect(docs);
                    var res = Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(formSelectDoc);
                    if (res == DialogResult.OK)
                    {
                        var docSelected = (Document)((SelectObject)formSelectDoc.SelectedItem).Object;
                        if (doc == docSelected)
                        {
                            MessageBox.Show("Выбран текущий чертеж!");
                        }
                        else
                        {
                            using (var lockItemDoc = docSelected.LockDocument())
                            {
                                Lib.DictNOD.CopyDict(docSelected.Database);
                                doc.Editor.WriteMessage("Словарь скопирован успешно.");
                            }
                        }
                        // Поиск чертежа среди открытых документов
                        //foreach (Document itemDoc in Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager)
                        //{
                        //    if (string.Equals(Path.GetFileName(itemDoc.Name), res.StringResult, System.StringComparison.OrdinalIgnoreCase))
                        //    {
                        //        using (var lockItemDoc = itemDoc.LockDocument())
                        //        {
                        //            Lib.DictNOD.CopyDict(itemDoc.Database);
                        //        }
                        //    }
                        //}
                    }
                    else
                    {
                        return;
                    }
                }
            });
        }
Example #3
0
 private void UserTasksListToolStripMenuItem_Click(object sender, EventArgs e)
 {
     flag = "";
     using (var fs = new FormSelect(this, flag))
     {
         if (fs.ShowDialog() == DialogResult.OK)
         {
             return;
         }
     }
 }
Example #4
0
    private void SelectSubject()
    {
        FormSelect formSelect = new FormSelect(SubjectsTable);

        formSelect.ItemSelected += (sender, e) => Subject =
            e.SelectedRows[0] as CollegeDataSet.SubjectsRow;
        formSelect.DataGrid.Columns[0].Visible    = false;
        formSelect.DataGrid.Columns[1].HeaderText = "Наименование дисциплины";

        formSelect.ShowDialog();
    }
Example #5
0
        private void buttonAddProperty_Click(object sender, EventArgs e)
        {
            FormSelect <Property> form = new FormSelect <Property>("Property", possibleProperties, p => p.Name);

            var      result   = form.ShowDialog(this);
            Property property = form.SelectedColumn;

            if (result == DialogResult.OK && property != null)
            {
                AddNewProperty.RaiseEventEx(this, new GenericEventArgs <Property>(property));
            }
        }
Example #6
0
        public virtual void Visit(FormSelect formSelect)
        {
            int previousIndex = 0;

            var content = formSelect.Content.ToList();

            for (int i = 0; i < content.Count; i++)
            {
                content[i].IsSelected = false;
            }

            if (values[formSelect.Path] == null)
            {
                return;
            }

            foreach (var o in values[formSelect.Path].Split(','))
            {
                for (int i = previousIndex; i < content.Count; i++)
                {
                    if (formSelect.Header != null && content[i] == formSelect.Header)
                    {
                        continue;
                    }

                    if (content[i].IsHidden)
                    {
                        continue;
                    }

                    if (content[i].IsDisabled)
                    {
                        continue;
                    }

                    if (content[i].Value == o)
                    {
                        content[i].IsSelected = true;
                        previousIndex         = i + 1;

                        break;
                    }
                }
            }
        }
Example #7
0
        public virtual void Visit(FormSelect formSelect)
        {
            StringBuilder sbValues = new StringBuilder();

            foreach (var v in formSelect.Value)
            {
                sbValues.Append(string.Format("{0}, ", v.Text));
            }

            string value = sbValues.ToString();

            if (value.EndsWith(", "))
            {
                value = value.Substring(0, value.Length - 2);
            }

            sb.AppendLine(string.Format("{0}{1}: {2}", formSelect.Label, Mark(formSelect), value));
        }
Example #8
0
    private void ButtonChangeGroupClickHandler(object sender, EventArgs e)
    {
        if (College == null || GroupTypeId == -1)
        {
            return;
        }

        var form = new FormSelect(College.GetGroupsByGroupTypeId(GroupTypeId));

        form.DataGrid.MultiSelect                       = false;
        form.ItemSelected                              += (sender2, e2) =>
                                              GroupInfo = e2.SelectedRows[0] as CollegeDataSet.GroupsRow;
        form.DataGrid.Columns[0].Visible                = false;
        form.DataGrid.Columns[2].Visible                = false;
        form.DataGrid.Columns[1].HeaderText             = "Наименование группы";

        form.ShowDialog();
    }
Example #9
0
            protected override void AddRules(List <FormRule> rules)
            {
                rules.Add((isPostBack, formItem, argument) =>
                {
                    FormSelect selCity          = GetItem <FormSelect>("City");
                    FormSelect selMunicipality  = GetItem <FormSelect>("MunicipalitySelect");
                    FormTextBox txtMunicipality = GetItem <FormTextBox>("MunicipalityTextBox");

                    selMunicipality.Hidden = true;
                    txtMunicipality.Hidden = true;

                    if (!selCity.Value.Any())
                    {
                        return;
                    }

                    long cityId = Convert.ToInt64(selCity.Value.Single().Value);

                    tblMunicipality[] municipalities = tblMunicipality.ListForcityId(cityId).ToArray();

                    if (municipalities.Length == 0)
                    {
                        txtMunicipality.Hidden = false;
                        return;
                    }

                    selMunicipality.Hidden = false;

                    FormOption prevMunicipality = selMunicipality.Value.SingleOrDefault();

                    selMunicipality.Content = municipalities.Select(m => new FormOption((int)m.id, m.name));

                    if (prevMunicipality == null)
                    {
                        return;
                    }

                    foreach (var o in selMunicipality.Content)
                    {
                        o.IsSelected = o.Equals(prevMunicipality);
                    }
                });
            }
        /// <summary>
        /// 档案类型未勾选文件类型列表
        /// </summary>
        /// <param name="Id">档案类型编号</param>
        /// <returns>文件类型列表</returns>
        public ActionResult FileTypeListOfUnselected(int Id)
        {
            var list = RecordFileTypeService
                       .GetByWhere($" where ID not in (select FileType from SelectType where SelectTypeNum = {Id})").ToList();

            var temp = new List <FormSelect>();

            foreach (var item in list)
            {
                var formSelect = new FormSelect()
                {
                    name  = item.RecordTypeName,
                    value = item.ID
                };
                temp.Add(formSelect);
            }

            return(Json(temp, JsonRequestBehavior.AllowGet));
        }
Example #11
0
        private void ButtonOKClickHandler(object sender, EventArgs e)
        {
            var groupsTable = m_radioGroupPlan.Checked ?
                              m_college.GetGroupsByGroupTypeId(m_groupTypeId) :
                              m_college.GetPlanNamesByGroupTypeId(m_groupTypeId);
            var form = new FormSelect(groupsTable);

            form.DataGrid.MultiSelect = false;
            form.ItemSelected        += (sender2, e2) =>
            {
                GroupIdForCopy = ((CollegeDataSet.GroupsRow)e2.SelectedRows[0]).group_id;
                Close();
            };
            form.DataGrid.Columns[0].Visible    = false;
            form.DataGrid.Columns[2].Visible    = false;
            form.DataGrid.Columns[1].HeaderText = m_radioGroupPlan.Checked ?
                                                  "Наименование группы" : "Наименование плана";
            form.ShowDialog();
        }
Example #12
0
        private void buttonAddProperty_Click(object sender, EventArgs e)
        {
            FormSelect<Property> form = new FormSelect<Property>("Property", possibleProperties, p => p.Name);

            var result = form.ShowDialog(this);
            Property property = form.SelectedColumn;

            if(result == DialogResult.OK && property != null)
            {
                AddNewProperty.RaiseEventEx(this, new GenericEventArgs<Property>(property));
            }
        }
Example #13
0
        public virtual void Visit(FormSelect formSelect, HtmlContainer htmlContainer)
        {
            HtmlDiv htmlDiv = verbose ? new HtmlDiv(formSelect.Path) : new HtmlDiv();

            htmlDiv.Class.Add("formSelect");

            if (!string.IsNullOrWhiteSpace(formSelect.CssClass))
            {
                htmlDiv.Class.AddRange(formSelect.CssClass.Split(' ').Where(s => s != string.Empty));
            }

            if (!string.IsNullOrWhiteSpace(formSelect.Path))
            {
                htmlDiv.Class.Add(string.Format("{0}{1}", "formId", formSelect.Path));
            }

            htmlDiv.Class.Add("formField");

            if (initialize)
            {
                htmlDiv.Class.Add(formSelect.IsRequired ? "formRequired" : "formOptional");
            }
            else
            {
                if (!formSelect.IsRequired || formSelect.HasValue)
                {
                    htmlDiv.Class.Add("formValid");
                }
                else
                {
                    htmlDiv.Class.Add(formSelect.IsRequired ? "formNotEntered" : "formOptional");
                }
            }

            htmlDiv.Hidden.Value = formSelect.IsHidden;

            htmlContainer.Add(htmlDiv);

            HtmlSelect htmlSelect = formSelect.Size.HasValue ?
                                    new HtmlSelect(formSelect.Path, formSelect.Size.Value, formSelect.Update) :
                                    new HtmlSelect(formSelect.Path, formSelect.IsMultiSelect, formSelect.Update);

            htmlSelect.Disabled.Value = formSelect.IsDisabled;

            if (!initialize && firstInvalidId == null)
            {
                if (formSelect.IsRequired && !formSelect.HasValue || !formSelect.IsValid)
                {
                    firstInvalidId = htmlSelect.Id.Value;
                }
            }

            switch (formSelect.OrderElements)
            {
            case OrderElements.LabelMarkInput:

                AddLabelMark(formSelect, htmlSelect, htmlDiv);
                htmlDiv.Add(htmlSelect);

                break;

            case OrderElements.MarkLabelInput:

                AddMarkLabel(formSelect, htmlSelect, htmlDiv);
                htmlDiv.Add(htmlSelect);

                break;

            case OrderElements.InputLabelMark:

                htmlDiv.Add(htmlSelect);
                AddLabelMark(formSelect, htmlSelect, htmlDiv);

                break;

            case OrderElements.InputMarkLabel:

                htmlDiv.Add(htmlSelect);
                AddMarkLabel(formSelect, htmlSelect, htmlDiv);

                break;

            case OrderElements.LabelInputMark:

                AddLabel(formSelect, htmlSelect, htmlDiv);
                htmlDiv.Add(htmlSelect);
                AddMark(formSelect, htmlSelect, htmlDiv);

                break;

            case OrderElements.MarkInputLabel:

                AddMark(formSelect, htmlSelect, htmlDiv);
                htmlDiv.Add(htmlSelect);
                AddLabel(formSelect, htmlSelect, htmlDiv);

                break;

            default:
            case OrderElements.NotSet:

                break;
            }

            foreach (var formOption in formSelect.Content)
            {
                Visit(formOption, htmlSelect);
            }

            if (initialize)
            {
                return;
            }

            string message = null;

            if (formSelect.UseLastMessage)
            {
                if (!string.IsNullOrEmpty(formSelect.LastMessage))
                {
                    message = formSelect.LastMessage;
                }
            }
            else if (formSelect.IsRequired && !formSelect.HasValue)
            {
                message = formSelect.RequiredMessage;
            }
            else if (!formSelect.IsValid)
            {
                message = formSelect.ValidationMessage;
            }

            if (message == null)
            {
                return;
            }

            HtmlLabel htmlLabelMessage = new HtmlLabel(verbose ? string.Format("{0}{1}", formSelect.Path, "Message") : "");

            htmlLabelMessage.Class.Add("formValidationMessage");
            htmlLabelMessage.For.Value = htmlSelect.Id.Value;
            htmlLabelMessage.Add(new HtmlText(message));
            htmlDiv.Add(htmlLabelMessage);
        }
Example #14
0
    private void RenderForm()
    {
        var grantToWrite       = this.ApplicationUser.HasGrantToWrite(ApplicationGrant.Objetivo);
        var defaultComboOption = FormSelectOption.DefaultOption(this.Dictionary);

        this.TxtRecursos = new FormTextArea
        {
            Value        = this.Objetivo.Resources,
            Label        = this.Dictionary["Item_Objetivo_FieldLabel_Resources"],
            Name         = "TxtResources",
            Rows         = 3,
            GrantToWrite = grantToWrite
        };

        this.TxtMetodologia = new FormTextArea
        {
            Value        = this.Objetivo.Methodology,
            Label        = this.Dictionary["Item_Objetivo_FieldLabel_Methodology"],
            Name         = "TxtMethodology",
            Rows         = 3,
            GrantToWrite = grantToWrite
        };

        this.TxtNotes = new FormTextArea
        {
            Value        = this.Objetivo.Notes,
            Label        = this.Dictionary["Item_Objetivo_FieldLabel_Notes"],
            Name         = "TxtNotes",
            Rows         = 3,
            GrantToWrite = grantToWrite
        };

        this.CmbResponsible = new FormSelect
        {
            ColumnsSpanLabel = 1,
            Label            = this.Dictionary["Item_Objetivo_FieldLabel_Responsible"],
            ColumnsSpan      = 3,
            Name             = "CmbResponsible",
            GrantToWrite     = grantToWrite,
            Required         = true,
            RequiredMessage  = this.Dictionary["Common_Required"],
            DefaultOption    = defaultComboOption
        };

        this.CmbResponsibleClose = new FormSelect
        {
            ColumnsSpanLabel = 3,
            Label            = this.Dictionary["Item_Objetivo_FieldLabel_CloseResponsible"],
            ColumnsSpan      = 9,
            Name             = "CmbEndResponsible",
            GrantToWrite     = grantToWrite,
            DefaultOption    = defaultComboOption,
            RequiredMessage  = this.Dictionary["Common_Required"],
            Required         = true
        };

        this.CmbResponsibleRecord = new FormSelect
        {
            ColumnsSpanLabel = 3,
            Label            = this.Dictionary["Item_IndicatorRecord_FieldLabel_Responsible"],
            ColumnsSpan      = 9,
            Name             = "CmbResponsibleRecord",
            GrantToWrite     = grantToWrite,
            DefaultOption    = defaultComboOption,
            Required         = true,
            RequiredMessage  = this.Dictionary["Common_Required"]
        };

        this.CmbIndicador = new FormSelect
        {
            ColumnsSpanLabel = 1,
            Label            = this.Dictionary["Item_Objetivo_FieldLabel_Indicator"],
            ColumnsSpan      = 3,
            Name             = "CmbIndicador",
            GrantToWrite     = grantToWrite,
            Required         = true,
            RequiredMessage  = this.Dictionary["Common_Required"],
            DefaultOption    = defaultComboOption
        };

        foreach (var indicador in Indicador.ByCompany(this.Company.Id))
        {
            if (indicador.Active || indicador.Id == this.Objetivo.IndicatorId)
            {
                this.CmbIndicador.AddOption(new FormSelectOption
                {
                    Value    = indicador.Id.ToString(),
                    Text     = indicador.Description,
                    Selected = indicador.Id == this.Objetivo.IndicatorId
                });
            }
        }

        foreach (var e in this.Company.Employees)
        {
            if (e.Active && e.DisabledDate == null)
            {
                this.CmbResponsible.AddOption(new FormSelectOption
                {
                    Value    = e.Id.ToString(),
                    Text     = e.FullName,
                    Selected = e.Id == this.Objetivo.Responsible.Id
                });

                this.CmbResponsibleClose.AddOption(new FormSelectOption
                {
                    Value    = e.Id.ToString(),
                    Text     = e.FullName,
                    Selected = e.Id == this.Objetivo.EndResponsible.Id
                });

                this.CmbResponsibleRecord.AddOption(new FormSelectOption
                {
                    Value    = e.Id.ToString(),
                    Text     = e.FullName,
                    Selected = false
                });
            }
        }

        this.TxtFechaCierrePrevista = new FormDatePicker
        {
            Id               = "TxtFechaCierrePrevista",
            Value            = this.Objetivo.PreviewEndDate,
            ColumnsSpan      = Constant.ColumnSpan4,
            ColumnsSpanLabel = Constant.ColumnSpan2,
            Label            = this.Dictionary["Item_Objetivo_FieldLabel_ClosePreviewDate"]
        };

        this.TxtFechaCierreReal = new FormDatePicker
        {
            Id               = "TxtFechaCierreReal",
            Value            = this.Objetivo.EndDate,
            ColumnsSpan      = Constant.ColumnSpan4,
            ColumnsSpanLabel = Constant.ColumnSpan2,
            Label            = this.Dictionary["Item_Objetivo_FieldLabel_CloseRealDate"]
        };
    }
Example #15
0
            protected override void CreateForm()
            {
                OpenGroup("Container");

                #region Defaults

                OrderElements = OrderElements.LabelMarkInput;

                Required = true;

                RequiredMessage = resFieldRequired;

                #endregion


                #region Title

                AddItem(new FormTitle("Title")
                {
                    Content = resAdults,
                });

                #endregion


                #region DateOfBirth

                AddItem(dtpDateOfBirth = new FormDatePicker("DateOfBirth", "dd/mm/yyyy")
                {
                    Label = resDateOfBirth,

                    Placeholder = resDateOfBirth,

                    Validator = (v) =>
                    {
                        if (v > DateTime.Now)
                        {
                            return(resDateInvalid);
                        }

                        return(null);
                    }
                });

                #endregion


                #region EmploymentStatus

                AddItem(rdgEmploymentStatus = new FormRadioGroup("EmploymentStatus")
                {
                    Label = resEmploymentStatus,

                    Required = true,

                    Update = true,

                    Content = tblEmploymentStatus.ListAll().Select(s => new FormRadioButton(s.id, s.descr))
                });

                #endregion


                #region EmploymentDuration

                AddItem(selEmploymentDuration = new FormSelect("EmploymentDuration", false)
                {
                    Label = resEmploymentDuration,

                    Header = new FormOption(resChoose),

                    Hidden = true,

                    Content = tblEmploymentDuration.ListAll().Select(d => new FormOption(d.id, d.descr))
                });

                #endregion


                #region EducationalLevel

                AddItem(selEducationalLevel = new FormSelect("EducationalLevel", false)
                {
                    Label = resEducationalLevel,

                    Header = new FormOption(resChoose),

                    Content = tblEducationalLevel.ListAll().Select(l => new FormOption(l.id, l.name))
                });

                #endregion


                #region Population

                AddItem(selPopulation = new FormSelect("Population", false)
                {
                    Label = resCity,

                    Header = new FormOption(resChoose),

                    Content = tblPopulation.ListAll().Select(p => new FormOption(p.id, p.descr))
                });

                #endregion


                #region City

                AddItem(selCity = new FormSelect("City", false)
                {
                    Label = resAreaOfResidence,

                    Header = new FormOption(resChoose),

                    Update = true,

                    Content = tblCity.ListAll().OrderBy(c => c.name).Select(c => new FormOption(c.id, c.name))
                });

                #endregion


                #region Municipality

                AddItem(selMunicipality = new FormSelect("MunicipalitySelect", false)
                {
                    Label = resMunicipality,

                    Header = new FormOption(resChoose),

                    Hidden = true,
                });


                AddItem(txtMunicipality = new FormTextBox("MunicipalityTextBox")
                {
                    Label = resMunicipality,

                    Hidden = true,
                });

                #endregion


                #region Submit

                AddItem(new FormButton("Submit")
                {
                    Content = resSend,

                    Submit = true
                });

                #endregion

                CloseGroup("Container");
            }
            protected override void CreateForm()
            {
                OpenGroup("Container");

                #region Defaults

                OrderElements = OrderElements.LabelMarkInput;

                Required = true;

                RequiredMessage = resFieldRequired;

                #endregion


                #region Title

                AddItem(new FormTitle("Title")
                {
                    Content = resStudents,
                });

                #endregion


                #region DateOfBirth

                AddItem(dtpDateOfBirth = new FormDatePicker("DateOfBirth", "dd/mm/yyyy")
                {
                    Label = resDateOfBirth,

                    Placeholder = resDateOfBirth,

                    Validator = (v) =>
                    {
                        if (v > DateTime.Now)
                        {
                            return(resDateInvalid);
                        }

                        return(null);
                    }
                });

                #endregion


                #region Population

                AddItem(selPopulation = new FormSelect("Population", false)
                {
                    Label = resCity,

                    Header = new FormOption(resChoose),

                    Content = tblPopulation.ListAll().Select(p => new FormOption(p.id, p.descr))
                });

                #endregion


                #region City

                AddItem(selCity = new FormSelect("City", false)
                {
                    Label = resAreaOfResidence,

                    Header = new FormOption(resChoose),

                    Update = true,

                    Content = tblCity.ListAll().OrderBy(c => c.name).Select(c => new FormOption(c.id, c.name))
                });

                #endregion


                #region Municipality

                AddItem(selMunicipality = new FormSelect("MunicipalitySelect", false)
                {
                    Label = resMunicipality,

                    Header = new FormOption(resChoose),

                    Hidden = true,
                });


                AddItem(txtMunicipality = new FormTextBox("MunicipalityTextBox")
                {
                    Label = resMunicipality,

                    Hidden = true,
                });

                #endregion


                #region Email

                AddItem(txtEmail = new FormTextBox("Email")
                {
                    Label = resEmail.ToLower(),

                    Validator = (v) =>
                    {
                        if (!new Regex(@"^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]*$").IsMatch(v.Trim()))
                        {
                            return(resEmailInvalid);
                        }

                        return(null);
                    },
                });

                #endregion


                #region EducationalStage

                AddItem(selEducationalStage = new FormSelect("EducationalStage", false)
                {
                    Label = resEducationalStage,

                    Header = new FormOption(resChoose),

                    Update = true,

                    Content = tblEducationalStage.ListAll().Select(s => new FormOption(s.id, s.name))
                });

                #endregion


                #region EducationalGrade

                AddItem(selEducationalGrade = new FormSelect("EducationalGrade", false)
                {
                    Label = resEducationalGrade,

                    Header = new FormOption(resChoose),

                    Hidden = true,

                    Update = true,
                });

                #endregion


                #region OrientationGroup

                AddItem(selOrientationGroup = new FormSelect("OrientationGroup", false)
                {
                    Label = resOrientationGroup,

                    Header = new FormOption(resChoose),

                    Hidden = true,

                    Content = tblOrientationGroup.ListAll().Select(o => new FormOption(o.id, o.name))
                });

                #endregion


                #region CoachingSchool

                AddItem(txtCoachingSchool = new FormTextBox("CoachingSchool")
                {
                    Label = resCoachingSchool,

                    Required = false,
                });

                #endregion


                #region PrivateLessons

                AddItem(rdgPrivateLessons = new FormRadioGroup("PrivateLessons")
                {
                    Label = resPrivateLessons,

                    Required = false,

                    Content = new FormRadioButton[]
                    {
                        new FormRadioButton(0, resYes)
                        {
                            IsSelected = false
                        },
                        new FormRadioButton(1, resNo)
                        {
                            IsSelected = false
                        },
                    }
                });

                #endregion

                AddItem(new FormNumberSpinner("NumberSpinner")
                {
                    Label = "Number",

                    OrderNumberSpinner = OrderNumberSpinner.DecrIncrNumber,

                    Content = "0",

                    DirectInput = false,

                    Min = 0,
                });

                #region Submit

                AddItem(new FormButton("Submit")
                {
                    Content = resSend,

                    Submit = true
                });

                #endregion

                CloseGroup("Container");
            }