StrataFrame Forum

Populate Comboboxwith dependency of code product

http://forum.strataframe.net/Topic19335.aspx

By Rafael - 9/11/2008

How population combobox with dependency of code product.

Select * from Produto where code_product = textbox_code_product
By Dustin Taylor - 9/11/2008

I'm not sure I understand the question... but I'll give it a shot Wink.



Are you trying to pull back all the records that match the selected value of your combo box?



MyBO.FillDataTable("SELECT * FROM Table WHERE code_product = " & cbo_Product.SelectedValue)


(I wouldn't recommend hard coding it in the FillDataTable like that, but it gives you a start)



Or are you trying to populate the combo box itself with all the records associated with a given code? If so, then just add a fill method to your BO that corresponds to your select statement, and call that method in your combo's PopulationDataSourceSettings.
By Rafael - 9/11/2008

I tried to use the code below
private void prj_cod_Leave(object sender, EventArgs e)

{

sysProjetoEquipamentoBO1.FillDataTable("SELECT * FROM tabproj_equipamento WHERE prj_nrow = " + sysProjetoBO1.prj_nrow);

}

but he did not give certain. I have a field sysProjetoBO1.prj_cod and sysProjetoBO1.prj_nrow in the same table. I need to show prj_cod and populate combobox for the code sysProjetoBO1.prj_nrow. Combobox populated is sysProjetoEquipamentoBO1.prj_nrow!

By Trent L. Taylor - 9/12/2008

Well I am not totally certain what you are trying to do.  But let's back up and start here.  First, all SF lists allow you to populate via a BO.  You will not want to just slap in SELECT code.  You will want to create a Fill command that accepts whatever parms that you need for population.

Second, you will want to set the combo being populated to populate Manual instead of FormLoad because you are going to want to first ensure that your dependent code is set.

Third, once you have created a Fill method and setup the PopulationDataSourceSettings to use that fill method on the Combo, then you will want to handle the ListPopulating event to provide the value from the dependent code.

Finally, there are a TON of samples on this.  This is an extremely common task done within the framework.  There are samples that come with the framework showing how to do this, you can look at the StrataFlix sample, or just search on the ListPopulating event within the forum and you will find a LOT of samples.

By Rafael - 9/12/2008

I searched in the forum but I did not obtain to develop. It could send me example code?
By Ivan George Borges - 9/12/2008

Rafael, these are only some links about ListPopulating event:

http://forum.strataframe.net/FindPost14556.aspx

http://forum.strataframe.net/FindPost12211.aspx

http://forum.strataframe.net/FindPost14538.aspx

http://forum.strataframe.net/FindPost16492.aspx

Cool

By Rafael - 9/12/2008

I tried to make equal in it I finish topic passed for the Ivan but he did not give certain

In BO

public void FillByProjetoEquipamentoGL(string nRowProjeto)
{
this.FillDataTable("SELECT * FROM "+ this.TableName);
}

in Form

private void proj_eqp_nrow_ListPopulating(MicroFour.StrataFrame.UI.ListPopulatingEventArgs e)
{
e.Parameters[0].Value = prj_cod.Text;
}
private void proj_eqp_nrow_Leave(object sender, EventArgs e)
{
this.proj_eqp_nrow.Requery();
}

What it is made a mistake?

By Rafael - 9/12/2008

I forgot myself to place the image of the configuration of combobox
By Rafael - 9/12/2008

These images are of the same component combobox
I need value sysProjetoBO1.prj_nrow in Value Member for sysProjetoEquipamentoBO of the propierty PopulationDataSourceSettings. How make this ?

In Portuguese

Eu preciso do valor sysProjetoBO1.prj_nrow na Value member do  sysProjetoEquipamentoBO  da propriedade PopulationDataSourceSettings. Como eu faço isso ?

By Edhy Rijo - 9/12/2008

Hi Rafael,

I noticed you have this code:

private void proj_eqp_nrow_ListPopulating(MicroFour.StrataFrame.UI.ListPopulatingEventArgs e)
{
e.Parameters[0].Value = prj_cod.Text;
}

But, your FillByProjetoEquipamentoGL(Int32) is expecting an Integer and the prj_cod.Text is string, so you have to make sure the value of the prj_cod.Text is an Integer, so you need to convert it using cint() or the equivalent C## function.

By Rafael - 9/12/2008

yes, but my probleman is no this.

I modified my code for

        private void btnProjeto_Click(object sender, EventArgs e)
        {
            if (this.bdProjeto.ShowDialog() == DialogResult.OK)
            {
                prj_cod.Text = Convert.ToString(sysProjetoBO1.prj_cod);
                proj_eqp_nrow.Requery();
            }
        }
        private void proj_eqp_nrow_ListPopulating(MicroFour.StrataFrame.UI.ListPopulatingEventArgs e)
        {
            e.Parameters[0].Value = sysProjetoEquipamentoBO1.proj_eqp_nrow;
        }

In BO
        public void FillByProjetoEquipamentoGL(int nRowProjeto)
        {
            GoLiveGlobals.infoMessageBox(nRowProjeto.ToString());
            //this.FillDataTable("select * from tabproj_equipamento where prj_nrow = " + nRowProjeto);
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = String.Format("select * from tabproj_equipamento where prj_nrow = " + nRowProjeto, this.TableName);
            this.FillDataTable(cmd);
        }

In GoLiveGlobals.infoMessageBox(nRowProjeto.ToString()); return 0 ! Why ?

By Trent L. Taylor - 9/13/2008

Rafael,

I think that you are inadvertantly making a very simple task very complex.  As mentioned in previous posts, there are a lot of samples that show how to do this...and I know that other developers have tried to help you understand as well.  Maybe at this point you should just create a simple sample illustrating your problem and post it out here instead of all of these posts as this doesn't really seem to be going anywhere.  Maybe a real sample from YOUR perspective and then a correction via the forum posters will help you better undertstand where you are going wrong.

By Rafael - 9/14/2008

I have a Example !

Eu preciso population a comboBox1 com o valor da  textbox1. O Meu problema é que eu preciso fazer um Select * from ProjetoEquipamento where prj_nrow = value of textbox1         . Como population combobox whith Select ?