public Form1() { InitializeComponent(); usrc_pass = new Password.usrc_Password(); }
public void CreateInputControls(SQLTable pParentTbl, Type myType) { m_eDBType = Globals.Get_eDBType(m_col.obj); usrc_lbl.ReadOnly = bReadOnly; switch (m_eDBType) { case Globals.eDBType.DB_bit: switch (m_col.Style) { case Column.eStyle.none: case Column.eStyle.CheckBox: case Column.eStyle.CheckBox_default_true: case Column.eStyle.ReadOnly_CheckBox_default_true: chkBox = new usrc_CheckBox(); chkBox.ReadOnly = bReadOnly; chkBox.Left = usrc_lbl.Left + usrc_lbl.Width + dist; chkBox.Top = usrc_lbl.Top; this.Controls.Add(chkBox); chkBox.Text = ""; chkBox.AutoSize = false; chkBox.Width = chkBoxWidth; chkBox.Height = usrc_InputControl_Height; chkBox.Visible = true; chkBox.BackColor = Color.Transparent; m_active_ctrl_List.Add(chkBox); if ((m_col.Style == Column.eStyle.CheckBox_default_true) || (m_col.Style == Column.eStyle.ReadOnly_CheckBox_default_true)) { chkBox.Checked = true; m_Defined = true; if (m_col.Style == Column.eStyle.ReadOnly_CheckBox_default_true) { chkBox.ReadOnly = true; } } break; case Column.eStyle.RadioButtons: rdbButton1 = new usrc_RadioButton(); rdbButton1.ReadOnly = bReadOnly; rdbButton2 = new usrc_RadioButton(); rdbButton2.ReadOnly = bReadOnly; rdbButton1.Left = usrc_lbl.Left + usrc_lbl.Width + dist; rdbButton1.Top = usrc_lbl.Top; rdbButton2.Left = rdbButton1.Left + rdbButton1.Width + dist; rdbButton2.Top = usrc_lbl.Top; this.Controls.Add(rdbButton1); this.Controls.Add(rdbButton2); usrc_lbl.Text = SetRadioButtonText(rdbButton1, rdbButton2); rdbButton1.AutoSize = false; rdbButton1.Width = rdbButtonWidth; rdbButton1.Height = usrc_InputControl_Height; rdbButton1.Visible = true; rdbButton1.BackColor = Color.Transparent; rdbButton2.AutoSize = false; rdbButton2.Width = rdbButtonWidth; rdbButton2.Height = usrc_InputControl_Height; rdbButton2.Visible = true; rdbButton2.BackColor = Color.Transparent; m_active_ctrl_List.Add(rdbButton1); m_active_ctrl_List.Add(rdbButton2); break; default: break; } break; case Globals.eDBType.DB_smallInt: case Globals.eDBType.DB_Int32: case Globals.eDBType.DB_Int64: nmUpDown = new usrc_NumericUpDown(bReadOnly); nmUpDown.ReadOnly = bReadOnly; nmUpDown.Left = usrc_lbl.Left + usrc_lbl.Width + dist; nmUpDown.Top = usrc_lbl.Top; if (bReadOnly||(m_col.Style == Column.eStyle.TextBox_ReadOnly)) { nmUpDown.ReadOnly = true; nmUpDown.BackColor = Color.LightGray; } this.Controls.Add(nmUpDown); nmUpDown.Type = usrc_NumericUpDown.eType.INTEGER; nmUpDown.ValueMultiplier = 1; nmUpDown.Visible = true; nmUpDown.Tag = this; nmUpDown.Maximum = int.MaxValue; nmUpDown.Minimum = 0; nmUpDown.Value = nmUpDown.Minimum; switch (m_eDBType) { case Globals.eDBType.DB_smallInt: ObjectInitialValue = Convert.ToInt16(nmUpDown.Value); break; case Globals.eDBType.DB_Int32: ObjectInitialValue = Convert.ToInt32(nmUpDown.Value); break; case Globals.eDBType.DB_Int64: ObjectInitialValue = Convert.ToInt64(nmUpDown.Value); break; } nmUpDown.Increment = 1; this.Width = usrc_lbl.Width + dist + nmUpDown.Width; this.Height = nmUpDown.Height; m_active_ctrl_List.Add(nmUpDown); break; case Globals.eDBType.DB_Money: MoneyUpDown = new usrc_NumericUpDown(bReadOnly); MoneyUpDown.ValueMultiplier = 1; MoneyUpDown.Type = usrc_NumericUpDown.eType.CURRENCY; MoneyUpDown.Left = usrc_lbl.Left + usrc_lbl.Width + dist; MoneyUpDown.Top = usrc_lbl.Top; if (bReadOnly || (m_col.Style == Column.eStyle.TextBox_ReadOnly)) { MoneyUpDown.ReadOnly = true; MoneyUpDown.BackColor = Color.LightGray; } MoneyUpDown.DecimalPlaces = 3; this.Controls.Add(MoneyUpDown); MoneyUpDown.Visible = true; MoneyUpDown.Tag = this; MoneyUpDown.Maximum = 1000000000; MoneyUpDown.Minimum = 0; MoneyUpDown.Value = MoneyUpDown.Minimum; ObjectInitialValue = MoneyUpDown.Value; MoneyUpDown.Increment = 0.01M; this.Width = usrc_lbl.Width + dist + MoneyUpDown.Width; this.Height = MoneyUpDown.Height; m_active_ctrl_List.Add(MoneyUpDown); break; case Globals.eDBType.DB_decimal2: nmUpDown = new usrc_NumericUpDown(bReadOnly); nmUpDown.Left = usrc_lbl.Left + usrc_lbl.Width + dist; nmUpDown.Top = usrc_lbl.Top; if (bReadOnly || (m_col.Style == Column.eStyle.TextBox_ReadOnly)) { nmUpDown.ReadOnly = true; nmUpDown.BackColor = Color.LightGray; } nmUpDown.Type = usrc_NumericUpDown.eType.INTEGER; nmUpDown.ValueMultiplier = 1; nmUpDown.DecimalPlaces = 2; this.Controls.Add(nmUpDown); nmUpDown.Visible = true; nmUpDown.Tag = this; nmUpDown.Maximum = 1000000; nmUpDown.Minimum = 0; nmUpDown.Value = nmUpDown.Minimum; ObjectInitialValue = nmUpDown.Value; nmUpDown.Increment = 0.01M; this.Width = usrc_lbl.Width + dist + nmUpDown.Width; this.Height = nmUpDown.Height; m_active_ctrl_List.Add(nmUpDown); break; case Globals.eDBType.DB_Percent: PercentUpDown = new usrc_NumericUpDown(bReadOnly); PercentUpDown.ValueMultiplier = 100; PercentUpDown.Unit = " %"; PercentUpDown.Type = usrc_NumericUpDown.eType.PERCENT; PercentUpDown.Left = usrc_lbl.Left + usrc_lbl.Width + dist; PercentUpDown.Top = usrc_lbl.Top; if (bReadOnly || (m_col.Style == Column.eStyle.TextBox_ReadOnly)) { PercentUpDown.ReadOnly = true; PercentUpDown.BackColor = Color.LightGray; } PercentUpDown.DecimalPlaces = 1; this.Controls.Add(PercentUpDown); PercentUpDown.Visible = true; PercentUpDown.Tag = this; PercentUpDown.Maximum = 1; PercentUpDown.Minimum = 0; PercentUpDown.Value = PercentUpDown.Minimum; ObjectInitialValue = PercentUpDown.Value; PercentUpDown.Increment = 0.005M; this.Width = usrc_lbl.Width + dist + PercentUpDown.Width; this.Height = PercentUpDown.Height; m_active_ctrl_List.Add(PercentUpDown); break; case Globals.eDBType.DB_DateTime: DateTimeInput = new usrc_InputControl_DateTimePicker(bReadOnly); DateTimeInput.Left = usrc_lbl.Left + usrc_lbl.Width + dist; DateTimeInput.Top = usrc_lbl.Top; this.Controls.Add(DateTimeInput); DateTimeInput.Visible = true; switch (m_col.Style) { case Column.eStyle.DateTimePicker_ReadOnly: DateTimeInput.Enabled = false; break; case Column.eStyle.DateTimePicker_MinDate: DateTimeInput.Value = DateTimeInput.MinDate; ObjectInitialValue = DateTimeInput.Value; break; case Column.eStyle.DateTimePicker_Now: DateTime DateToday = new DateTime(DateTime.Now.Year,DateTime.Now.Month,DateTime.Now.Day); DateTimeInput.Value = DateToday; ObjectInitialValue = DateTimeInput.Value; Defined = true; break; default: ObjectInitialValue = DateTimeInput.Value; break; } DateTimeInput.Tag = this; this.Width = usrc_lbl.Width + dist + DateTimeInput.Width; this.Height = DateTimeInput.Height; m_active_ctrl_List.Add(DateTimeInput); break; case Globals.eDBType.DB_varbinary_max: DataBox = new InputControl_DataBox(); DataBox.Left = usrc_lbl.Left + usrc_lbl.Width + dist; DataBox.Top = usrc_lbl.Top; this.Controls.Add(DataBox); DataBox.Width = DataBoxWidth; DataBox.Height = DataBoxHeight; DataBox.Visible = true; DataBox.Data = null; DataBox.Tag = this; this.Width = usrc_lbl.Width + dist + DataBoxWidth; this.Height = DataBoxHeight; m_active_ctrl_List.Add(DataBox); break; case Globals.eDBType.DB_Image: Picture_Box = new Picture_Box(this, pParentTbl, PictureBoxWidth, PictureBoxHeight,bReadOnly); Picture_Box.Left = usrc_lbl.Left + usrc_lbl.Width + dist; Picture_Box.Top = usrc_lbl.Top; if (Picture_Box.btnFolderSelect!=null) { Picture_Box.btnFolderSelect.Left = usrc_lbl.Left + usrc_lbl.Width - 32; Picture_Box.btnFolderSelect.Top = usrc_lbl.Top + usrc_lbl.Height + 5; } //Picture_Box.Width = PictureBoxWidth; //Picture_Box.Height = 400; this.Controls.Add(Picture_Box); Picture_Box.Visible = true; Picture_Box.Picture.Image = Properties.Resources.DefPictureImage; Picture_Box.Tag = this; if (Picture_Box.btnFolderSelect != null) { this.Width = usrc_lbl.Width + dist + Picture_Box.Width + dist + Picture_Box.btnFolderSelect.Width; } else { this.Width = usrc_lbl.Width + dist + Picture_Box.Width + dist; } this.Height = Picture_Box.Top + Picture_Box.Height + 2; m_active_ctrl_List.Add(Picture_Box); break; case Globals.eDBType.DB_Document: Document_Box = new InputControl_DocumentBox(this); Document_Box.Left = usrc_lbl.Left + usrc_lbl.Width + dist; Document_Box.Top = usrc_lbl.Top; if (btnFolderSelect!=null) { btnFolderSelect.Left = Document_Box.Left + Document_Box.Width + dist; btnFolderSelect.Top = usrc_lbl.Top; } this.Controls.Add(Document_Box); Document_Box.Width = DocumentBoxWidth; Document_Box.Height = DocumentBoxHeight; Document_Box.Visible = true; //Document_Box.Picture.Image = Properties.Resources.DefPictureImage; Document_Box.Tag = this; //Document_Box.FileInfo_Box.btnFileSelect.Click += new EventHandler(this.OnButtonClick_DocumentSelect); this.Width = Document_Box.Width + dist + PictureBoxWidth; this.Height = Document_Box.Height; m_active_ctrl_List.Add(Document_Box); break; case Globals.eDBType.DB_varchar_264: case Globals.eDBType.DB_varchar_250: case Globals.eDBType.DB_varchar_64: case Globals.eDBType.DB_varchar_50: case Globals.eDBType.DB_varchar_45: case Globals.eDBType.DB_varchar_32: case Globals.eDBType.DB_varchar_25: case Globals.eDBType.DB_varchar_10: case Globals.eDBType.DB_varchar_5: if (m_col.Style == Column.eStyle.Password) { txtPassword = new Password.usrc_Password(); txtPassword.PasswordLocked = true; txtPassword.Width = txtBox_Width; txtPassword.Left = usrc_lbl.Left + usrc_lbl.Width + dist; txtPassword.Top = usrc_lbl.Top; this.Controls.Add(txtPassword); txtPassword.Visible = true; txtPassword.Tag = this; m_active_ctrl_List.Add(txtPassword); int iMaxLength = Func.GetMaxStringLength(myType); if (iMaxLength > 0) { txtPassword.MaxLength = iMaxLength; } this.Width = usrc_lbl.Width + dist + txtPassword.Width; this.Height = txtPassword.Height; m_col.Style = Column.eStyle.Password; } else { txtBox = new TextBox(); txtBox.Width = txtBox_Width; if (bReadOnly || (m_col.Style == Column.eStyle.TextBox_ReadOnly)) { txtBox.ReadOnly = true; txtBox.BackColor = Color.LightGray; txtBox.BorderStyle = System.Windows.Forms.BorderStyle.None; txtBox.Cursor = Cursors.No; } else { txtBox.Cursor = Cursors.IBeam; } txtBox.Left = usrc_lbl.Left + usrc_lbl.Width + dist; txtBox.Top = usrc_lbl.Top; this.Controls.Add(txtBox); txtBox.Visible = true; txtBox.Tag = this; m_active_ctrl_List.Add(txtBox); int iMaxLength = Func.GetMaxStringLength(myType); if (iMaxLength > 0) { txtBox.MaxLength = iMaxLength; } if (m_col.Style == Column.eStyle.FileSelection) { if (!bReadOnly) { btnFolderSelect = new Button(); btnFolderSelect.Left = txtBox.Left + txtBox.Width + dist; btnFolderSelect.Top = usrc_lbl.Top; this.Controls.Add(btnFolderSelect); btnFolderSelect.Width = BtnFileSelectWidth; btnFolderSelect.Height = btnFolderSelect_Height; btnFolderSelect.Image = Properties.Resources.SmallFolderIcon.ToBitmap(); btnFolderSelect.Text = ""; btnFolderSelect.Visible = true; btnFolderSelect.Tag = txtBox; this.Width = usrc_lbl.Width + dist + txtBox.Width + dist + btnFolderSelect.Width; this.Height = txtBox.Height; } } else { this.Width = usrc_lbl.Width + dist + txtBox.Width; this.Height = txtBox.Height; m_col.Style = Column.eStyle.TextBox; } } break; case Globals.eDBType.DB_varchar_2000: case Globals.eDBType.DB_varchar_max: m_col.Style = Column.eStyle.RichTextBox; RichtxtBox = new RichTextBox(); RichtxtBox.Left = usrc_lbl.Left + usrc_lbl.Width + dist; RichtxtBox.Top = usrc_lbl.Top; if (bReadOnly || (m_col.Style == Column.eStyle.TextBox_ReadOnly)) { RichtxtBox.ReadOnly = true; RichtxtBox.BorderStyle = System.Windows.Forms.BorderStyle.None; RichtxtBox.Cursor = Cursors.No; } else { RichtxtBox.Cursor = Cursors.IBeam; } this.Controls.Add(RichtxtBox); RichtxtBox.Width = RichTextBoxWidth; RichtxtBox.Height = RichTextBoxHeight; RichtxtBox.Visible = true; RichtxtBox.Multiline = true; RichtxtBox.Tag = this; m_active_ctrl_List.Add(RichtxtBox); this.Width = RichtxtBox.Left + RichtxtBox.Width + 2; this.Height = RichtxtBox.Height; break; case Globals.eDBType.DB_UNKNOWN: LogFile.Error.Show("ERROR in public InputControl(..) Can not find Globals.Get_eDBType(m_col.obj) from object:" + m_col.obj.GetType().ToString()); break; } }