Example #1
0
        private void InButton_Click(object sender, EventArgs e)
        {
            frmDGVGridRefVal frmDGVGridRefVal = new frmDGVGridRefVal();
            //DataSource
            if (this.RefVal.SelectCommand != null && this.RefVal.SelectCommand != "" )
            {
                string strwhere = this.RefVal.WhereString(this.RefVal.SelectCommand);
                if (this.RefVal.AlwaysClose || strwhere.Length > 0)
                {
                    this.RefVal.InnerDs.RemoteName = "GLModule.cmdRefValUse";
                    this.RefVal.InnerDs.Execute(CliUtils.InsertWhere(this.RefVal.SelectCommand, strwhere), true);
                }
                frmDGVGridRefVal.DataSource = this.RefVal.InnerBs;
            }
            else if (this.RefVal.DataSource is InfoBindingSource)
            {
                InfoDataSet ids = ((InfoBindingSource)this.RefVal.DataSource).GetDataSource() as InfoDataSet;
                string sql = DBUtils.GetCommandText((InfoBindingSource)this.RefVal.DataSource);
                string strwhere = this.RefVal.WhereString(sql);
                if (ids.AlwaysClose || strwhere.Length > 0)
                {
                    ids.SetWhere(strwhere);
                }
                InfoBindingSource refBinding = (InfoBindingSource)this.RefVal.DataSource;
                frmDGVGridRefVal.DataSource = refBinding;
            }
            else
            {
                return;
            }
            //DataMember
            frmDGVGridRefVal.DataMember = this.RefVal.GetDataMember();
            //ValueField
            frmDGVGridRefVal.ValueField = this.RefVal.GetValueMember();
            //Ctrl
            frmDGVGridRefVal.GridCtrl = this;
            //InitValue
            frmDGVGridRefVal.InitValue = this.InnerTextBox.Text;
            //RefVal
            frmDGVGridRefVal.RefVal = this.RefVal;
            //AllowAddData
            frmDGVGridRefVal.AllowAddData = this.RefVal.AllowAddData;

            this.RefVal.Active(new OnActiveEventArgs());

            frmDGVGridRefVal.ShowDialog();

            if (this.Parent != null)
            {
                Control ctrl = this.Parent.Parent;
                if (ctrl is InfoDataGridView)
                {
                    ((InfoDataGridView)ctrl).bHasFocused = true;
                }
            }
        }
Example #2
0
        private void InButton_Click(object sender, EventArgs e)
        {
            if (this.TextBoxBindingSource != null && this.TextBoxBindingSource is InfoBindingSource)
            {
                if (((InfoBindingSource)this.TextBoxBindingSource).BeginEdit() == false)
                {
                    return;
                }
            }
            frmDGVGridRefVal frmDGVGridRefVal = new frmDGVGridRefVal();
            //DataSource
            if (this.RefVal.SelectCommand != null && this.RefVal.SelectCommand != "")
            {
                string strwhere = this.RefVal.WhereString(this.RefVal.SelectCommand);
                if (this.RefVal.AlwaysClose || strwhere.Length > 0)
                {
                    this.RefVal.InnerDs.RemoteName = "GLModule.cmdRefValUse";
                    this.RefVal.InnerDs.Execute(CliUtils.InsertWhere(this.RefVal.SelectCommand, strwhere), true);
                }
                frmDGVGridRefVal.DataSource = this.RefVal.InnerBs;
            }
            else if (this.InTextBox.RefVal.DataSource is InfoBindingSource)
            {
                InfoDataSet ids = (this.RefVal.DataSource as InfoBindingSource).GetDataSource() as InfoDataSet;
                string sql = DBUtils.GetCommandText((this.RefVal.DataSource as InfoBindingSource));
                string strwhere = this.RefVal.WhereString(sql);
                if (ids.AlwaysClose || strwhere.Length > 0)
                {
                    ids.SetWhere(strwhere);
                }
                InfoBindingSource refBinding = (InfoBindingSource)this.InTextBox.RefVal.DataSource;
                frmDGVGridRefVal.DataSource = refBinding;
            }
            else
            {
                return;
            }
            //DataMember
            frmDGVGridRefVal.DataMember = this.InTextBox.RefVal.GetDataMember();
            //ValueField
            frmDGVGridRefVal.ValueField = this.InTextBox.RefVal.GetValueMember();
            //Ctrl
            frmDGVGridRefVal.BoxCtrl = this;
            //InitValue
            frmDGVGridRefVal.InitValue = this.InTextBox.Text;
            //RefVal
            frmDGVGridRefVal.RefVal = this.RefVal;
            //AllowAddData
            frmDGVGridRefVal.AllowAddData = this.RefVal.AllowAddData;

            this.RefVal.Active(new OnActiveEventArgs());

            frmDGVGridRefVal.ShowDialog(this.RefVal.OwnerComp as InfoForm);

            if (this.DisableValueMember)
            {
                this.InTextBox.SelectedValue = this.TextBoxLeaveText;
                String sSelectedValue = this.InTextBox.SelectedValue;
                object[] obj = this.InTextBox.RefVal.CheckValid_And_ReturnDisplayValue(ref sSelectedValue, this.InTextBox.RefVal.CheckData, true);
                if (!(bool)obj[0] && this.RefVal.CheckData)
                {
                    this.InTextBox.Text = "";
                    this.InTextBox.Focus();
                }
                else if ((bool)obj[0])
                {
                    this.InTextBox.Text = obj[1].ToString();
                }
            }
        }