Ejemplo n.º 1
0
        private void CreateObject(string TabPageName, Model.Archive.ArchiveField CurrentField, int XLabel, int YLabel, int XText, int YText)
        {
            try
            {
                switch (CurrentField.BoxTypeCode)
                {
                case (int)Enums.BoxTypes.کادر_متن:
                    Njit.Program.Controls.TextBoxExtended textBoxExtended = DossierFormHelper.CreateTextBox(CurrentField.Label, CurrentField.FieldName, CurrentField.FieldTypeCode, CurrentField.MinLength, CurrentField.MaxLength, CurrentField.MinValue, CurrentField.MaxValue, CurrentField.DefaultValue, XText, YText);
                    textBoxExtended.Size        = new Size(200, 20);
                    textBoxExtended.RightToLeft = RightToLeft.Yes;
                    pnlInfo.Controls.Add(textBoxExtended);
                    break;

                case (int)Enums.BoxTypes.کادر_ورود_تاریخ:

                    Njit.Program.Controls.DateControl dateControl = DossierFormHelper.CreateDateBox(CurrentField, XText, YText);
                    dateControl.Size = new Size(200, 20);
                    pnlInfo.Controls.Add(dateControl);
                    break;

                case (int)Enums.BoxTypes.کادر_بازشو:
                    Njit.Program.Controls.ComboBoxExtended comboBoxExtended = DossierFormHelper.CreateComboBox(CurrentField, XText, YText);
                    comboBoxExtended.Size        = new Size(200, 20);
                    comboBoxExtended.RightToLeft = RightToLeft.Yes;
                    pnlInfo.Controls.Add(comboBoxExtended);
                    break;

                case (int)Enums.BoxTypes.کادر_انتخاب:
                    CheckBox checkBox = DossierFormHelper.CreateChekBox(CurrentField, XLabel, YLabel);
                    checkBox.Size        = new Size(200, 20);
                    checkBox.RightToLeft = RightToLeft.Yes;
                    pnlInfo.Controls.Add(checkBox);
                    break;

                case (int)Enums.FieldTypes.ساعت:
                    Njit.Program.Controls.TimeControl timeControl = DossierFormHelper.CreateTimeBox(CurrentField, XText, YText);
                    timeControl.Size        = new Size(200, 20);
                    timeControl.RightToLeft = RightToLeft.Yes;
                    pnlInfo.Controls.Add(timeControl);
                    break;
                }
            }
            catch (Exception ex)
            {
                PersianMessageBox.Show("خطا در بارگذاری اطلاعات" + "\r\n\r\n" + ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void CreateObject(string tabPageName, Model.Archive.ArchiveField field, int xLabel, int yLabel, int xControl, int yControl)
        {
            try
            {
                if (field.BoxTypeCode != (int)Enums.BoxTypes.کادر_ورود_اطلاعات_گروهی && field.BoxTypeCode != (int)Enums.BoxTypes.کادر_انتخاب)
                {
                    Label label = DossierFormHelper.CreateLabel(field.Label, xLabel, yLabel);
                    tabControlExtended.TabPages[tabPageName].Controls.Add(label);
                }

                if (field.StatusCode == (int)Enums.StatusOfFields.مقدار_نتواند_تهی_باشد)
                {
                    Label labelStar = DossierFormHelper.CreateLabelStar(xLabel, yLabel);
                    tabControlExtended.TabPages[tabPageName].Controls.Add(labelStar);
                }
                else if (field.StatusCode == (int)Enums.StatusOfFields.مقدار_یکتا_باشد_و_نتواند_تهی_باشد)
                {
                    Label labelStar = DossierFormHelper.CreateLabelStar(xLabel, yLabel);
                    labelStar.ForeColor = Color.Green;
                    tabControlExtended.TabPages[tabPageName].Controls.Add(labelStar);
                }
                switch (field.BoxTypeCode)
                {
                case (int)Enums.BoxTypes.کادر_متن:
                    Njit.Program.Controls.TextBoxExtended textBox = DossierFormHelper.CreateTextBox(field, xControl, yControl);
                    if (field.FieldTypeCode != (int)Enums.FieldTypes.متن_طولانی)
                    {
                        textBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Controls_KeyDown);
                    }
                    textBox.TextChanged += new EventHandler(Controls_TextChanged);
                    tabControlExtended.TabPages[tabPageName].Controls.Add(textBox);
                    if (field.AutoComplete)
                    {
                        textBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
                        textBox.AutoCompleteMode   = AutoCompleteMode.Append;
                        textBox.AutoCompleteCustomSource.AddRange(SqlHelper.GetAllFieldValues(tabPageName, field.FieldName));
                    }
                    if (field.FieldTypeCode == (int)Enums.FieldTypes.شمارنده)
                    {
                        textBox.ReadOnly = true;
                        Model.Archive.CounterFieldSetting counterFieldSetting = Controller.Archive.ArchiveFieldController.GetCounterFieldProperties(field.ID);
                        string newValue = SqlHelper.GetNewValueOfCounterFiled(field, counterFieldSetting);
                        textBox.Text = newValue;
                    }
                    break;

                case (int)Enums.BoxTypes.کادر_ورود_تاریخ:
                    Njit.Program.Controls.DateControl dateControl = DossierFormHelper.CreateDateBox(field, xControl, yControl);
                    dateControl.KeyDown     += new System.Windows.Forms.KeyEventHandler(this.Controls_KeyDown);
                    dateControl.TextChanged += new EventHandler(Controls_TextChanged);
                    tabControlExtended.TabPages[tabPageName].Controls.Add(dateControl);
                    break;

                case (int)Enums.BoxTypes.کادر_بازشو:
                    Njit.Program.Controls.ComboBoxExtended comboBoxExtended = DossierFormHelper.CreateComboBox(field, xControl, yControl);
                    comboBoxExtended.TextChanged += new EventHandler(Controls_TextChanged);
                    comboBoxExtended.KeyDown     += new System.Windows.Forms.KeyEventHandler(this.Controls_KeyDown);
                    tabControlExtended.TabPages[tabPageName].Controls.Add(comboBoxExtended);
                    break;

                case (int)Enums.BoxTypes.کادر_انتخاب:
                    CheckBox checkBox = DossierFormHelper.CreateChekBox(field, xLabel, yLabel);
                    checkBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Controls_KeyDown);
                    tabControlExtended.TabPages[tabPageName].Controls.Add(checkBox);
                    break;

                case (int)Enums.BoxTypes.کادر_ورود_ساعت:
                    Njit.Program.Controls.TimeControl timeControl = DossierFormHelper.CreateTimeBox(field, xControl, yControl);
                    timeControl.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Controls_KeyDown);
                    tabControlExtended.TabPages[tabPageName].Controls.Add(timeControl);
                    break;

                case (int)Enums.BoxTypes.کادر_ورود_اطلاعات_گروهی:
                    Njit.Program.Controls.DataGridViewExtended dataGridViewExtended = DossierFormHelper.CreateDataGridView(field);
                    dataGridViewExtended.Rows.CollectionChanged += Rows_CollectionChanged;
                    dataGridViewExtended.CurrentCellChanged     += DataGridView_CurrentCellChanged;
                    GroupBox groupBox = DossierFormHelper.CreateGroupBox(field, yControl);
                    groupBox.Controls.Add(dataGridViewExtended);
                    tabControlExtended.TabPages[tabPageName].Controls.Add(groupBox);
                    break;

                case (int)Enums.BoxTypes.کادر_انتخاب_اشخاص:
                    Njit.Program.Controls.ComboBoxExtended personComboBoxExtended = DossierFormHelper.CreatePersonComboBox(field, xControl, yControl);
                    personComboBoxExtended.TextChanged          += new EventHandler(Controls_TextChanged);
                    personComboBoxExtended.KeyDown              += new System.Windows.Forms.KeyEventHandler(this.Controls_KeyDown);
                    personComboBoxExtended.SelectedIndexChanged += personComboBoxExtended_SelectedIndexChanged;
                    tabControlExtended.TabPages[tabPageName].Controls.Add(personComboBoxExtended);
                    break;
                }
            }
            catch (Exception ex)
            {
                PersianMessageBox.Show(ex.Message);
            }
        }