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); } }
private void CreateObjectsForTab(Model.Archive.ArchiveTab archiveTab) { try { if (archiveTab.Name != InfoTabPage.Name) { List <Model.Archive.ArchiveField> fields = Controller.Archive.DossierCacheController.GetArchiveFields(archiveTab.ID); if (fields.Count == 0) { return; } tabControlExtended.TabPages.Add(archiveTab.Name, archiveTab.Title); tabControlExtended.TabPages[archiveTab.Name].Tag = archiveTab.ID; tabControlExtended.TabPages[archiveTab.Name].BackColor = Color.White; int labelPoint_x = 650; int labelPoint_y = 26; int controlPoint_x = 460; int controlPoint_y = 25; int distance = -1; if (archiveTab.Index == 1) { Label lblPersonnelNumber = DossierFormHelper.CreateLabel(Setting.Archive.ThisProgram.LoadedArchiveSettings.PersonnelNumber_Label, 0, 0); lblPersonnelNumber.Name = "PersonnelNumberLabel"; lblPersonnelNumber.Size = new Size(160, 20); lblPersonnelNumber.Location = new Point(labelPoint_x, labelPoint_y); lblPersonnelNumber.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); PersonnelNumberTextBox.Size = new Size(160, 20); PersonnelNumberTextBox.Location = new Point(controlPoint_x, controlPoint_y); PersonnelNumberTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); //PersonnelNumberTextBox.GetType = Njit.Program.InputBoxValidationHelper.InputTypes.AllCharacters; PersonnelNumberTextBox.Tag = Setting.Archive.ThisProgram.LoadedArchiveSettings.PersonnelNumber_Label; Label lblStar = DossierFormHelper.CreateLabelStar(labelPoint_x, labelPoint_y); lblStar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); tabControlExtended.TabPages[archiveTab.Name].Controls.Add(lblStar); tabControlExtended.TabPages[archiveTab.Name].Controls.Add(lblPersonnelNumber); tabControlExtended.TabPages[archiveTab.Name].Controls.Add(PersonnelNumberTextBox); distance++; } int place = 0; foreach (Model.Archive.ArchiveField archiveField in fields) { if ((((float)place) % 2) == 0 || archiveField.BoxTypeCode == (int)Enums.BoxTypes.کادر_ورود_اطلاعات_گروهی || archiveField.FieldTypeCode == (int)Enums.FieldTypes.متن_طولانی || archiveField.FieldTypeCode == (int)Enums.FieldTypes.متن_طولانی_تک_خطی) { distance++; CreateObject(archiveTab.Name, archiveField, labelPoint_x, labelPoint_y + distance * 28, controlPoint_x, controlPoint_y + distance * 28); } else { CreateObject(archiveTab.Name, archiveField, labelPoint_x - 400, labelPoint_y + distance * 28, controlPoint_x - 400, controlPoint_y + distance * 28); } place++; if (archiveField.BoxTypeCode == (int)Enums.BoxTypes.کادر_ورود_اطلاعات_گروهی) { distance += 7; place = 0; } if (archiveField.FieldTypeCode == (int)Enums.FieldTypes.متن_طولانی) { distance += 1; place = 0; } if (archiveField.FieldTypeCode == (int)Enums.FieldTypes.متن_طولانی_تک_خطی) { place = 0; } } } else { InfoTabPage.Text = archiveTab.Title; } tabControlExtended.TabPages[archiveTab.Name].AutoScroll = true; } catch (Exception ex) { PersianMessageBox.Show("خطا در بازگذاری اطلاعات" + "\r\n" + ex.Message); } }