Display paid/unpaid by using combobox selection? [Resolved]

Posted by Sudheep.grandhe under C# on 12/12/2011 | Points: 10 | Views : 1163 | Status : [Member] | Replies : 16
Hi,

I am having a combobox .if i selected any value from the combobox.based on that value radiobutton should display their values.please do the needful.

Best,
Sudheep.



Responses

Posted by: Sksingh on: 12/12/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi,

Fine, but why did u use nvarchar(max) instead of it u would have used as bit so if paid then put as true else false anyway its ok. based on your existing datastructure below is code to bind.

private void cmb_customername_SelectedIndexChanged(object sender, EventArgs e) 

{
int invoiceno = 0;
if (cmb_customername.SelectedValue.ToString() != "System.data.datarowview" && cmb_customername.SelectedValue.ToString() != "" && cmb_customername.SelectedValue.ToString() != string.Empty)
{
invoiceno = Convert.ToInt32(cmb_customername.SelectedValue);
}
SqlConnection con = new SqlConnection("data source=mars-104;initial catalog=Sudheeptest;integrated security=true");
con.Open();
SqlCommand cmd=new SqlCommand ("select t2.compname,t2.compaddress,t2.invoiceno,t2.orderno,t2.ondate,t2.invoicedate,t2.amountstatus,t2.netamount,t2.netvat,t2.tamount,t1.particulars,t1.quantity,t1.perprice,t1.amount from tbl_report2 t2 left join tbl_report1 t1 on t1.invoiceno=t2.invoiceno where t2.invoiceno ="+ invoiceno +"",con );
SqlDataAdapter da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds );
if (ds.Tables.Count > 0)
{
txt_customeraddress.Text = ds.Tables[0].Rows[0]["compaddress"].ToString();
txt_invoiceno.Text = ds.Tables[0].Rows[0]["invoiceno"].ToString();
txt_orderno.Text = ds.Tables[0].Rows[0]["orderno"].ToString();
txt_ondate.Text = ds.Tables[0].Rows[0]["ondate"].ToString();
txt_invoicedate.Text = ds.Tables[0].Rows[0]["invoicedate"].ToString();
cmb_particulars.Text = ds.Tables[0].Rows[0]["particulars"].ToString();
txt_quantity.Text = ds.Tables[0].Rows[0]["Quantity"].ToString();
txt_perprice.Text = ds.Tables[0].Rows[0]["perprice"].ToString();
txt_amount.Text = ds.Tables[0].Rows[0]["amount"].ToString();
txt_netamount.Text = ds.Tables[0].Rows[0]["netamount"].ToString();
txt_netvat.Text = ds.Tables[0].Rows[0]["netvat"].ToString();
txt_tamount.Text = ds.Tables[0].Rows[0]["tamount"].ToString();
if(Convert.ToString(ds.Tables[0].Rows[0][" amountstatus "]) != null && Convert.ToString(ds.Tables[0].Rows[0][" amountstatus "]) != "")
{
if(ds.Tables[0].Rows[0]["amountstatus"].ToString().ToUpper() =="PAID")
{
rb_paid.Checked=true;
rb_unpaid.Checked=false;
}
else
{
rb_unpaid.Checked=true;
rb_paid.Checked=false;
}
}
}

}


Regards,
Sunil

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksingh on: 12/12/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

Very simple, write radio button binding login inside comboboxSelectedindexchanged event so whenever item get selected from combobox corresponding radio button source will be bind.

Only thing u have to write logic in such way that when u pass a combobox value to binding radio button function it will take care which items to be bind.

Regards,
Sunil

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 12/12/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

Thanks for replying to me.I am not getting can you please send some sample code.it will be helpful.please do the needful.

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 12/12/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

this is my code.can you please give me the sample code.in database for the radiobutton column as amountstatus from db itself it has to show whether it is paid/unpaid.

private void cmb_customername_SelectedIndexChanged(object sender, EventArgs e)
{
int invoiceno = 0;
if (cmb_customername.SelectedValue.ToString() != "System.data.datarowview" && cmb_customername.SelectedValue.ToString() != "" && cmb_customername.SelectedValue.ToString() != string.Empty)
{
invoiceno = Convert.ToInt32(cmb_customername.SelectedValue);
}
SqlConnection con = new SqlConnection("data source=mars-104;initial catalog=Sudheeptest;integrated security=true");
con.Open();
SqlCommand cmd=new SqlCommand ("select t2.compname,t2.compaddress,t2.invoiceno,t2.orderno,t2.ondate,t2.invoicedate,t2.amountstatus,t2.netamount,t2.netvat,t2.tamount,t1.particulars,t1.quantity,t1.perprice,t1.amount from tbl_report2 t2 left join tbl_report1 t1 on t1.invoiceno=t2.invoiceno where t2.invoiceno ="+ invoiceno +"",con );
SqlDataAdapter da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds );
if (ds.Tables.Count > 0)
{
txt_customeraddress.Text = ds.Tables[0].Rows[0]["compaddress"].ToString();
txt_invoiceno.Text = ds.Tables[0].Rows[0]["invoiceno"].ToString();
txt_orderno.Text = ds.Tables[0].Rows[0]["orderno"].ToString();
txt_ondate.Text = ds.Tables[0].Rows[0]["ondate"].ToString();
txt_invoicedate.Text = ds.Tables[0].Rows[0]["invoicedate"].ToString();
cmb_particulars.Text = ds.Tables[0].Rows[0]["particulars"].ToString();
txt_quantity.Text = ds.Tables[0].Rows[0]["Quantity"].ToString();
txt_perprice.Text = ds.Tables[0].Rows[0]["perprice"].ToString();
txt_amount.Text = ds.Tables[0].Rows[0]["amount"].ToString();
txt_netamount.Text = ds.Tables[0].Rows[0]["netamount"].ToString();
txt_netvat.Text = ds.Tables[0].Rows[0]["netvat"].ToString();
txt_tamount.Text = ds.Tables[0].Rows[0]["tamount"].ToString();
}

}


Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksingh on: 12/12/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Sudheep,

What type of data contains in your amountstatus column and what is its data type.
Plz tell me your radio buttons name to be bound for that columns and how do u identify that amount has been paid or unpaid.



Regards,
Sunil

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 12/12/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

radiobutton names are rb_paid,rb_unpaid and the datatype is nvarchar(max).the column amountstatus contains the data is paid and unpaid

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksingh on: 12/12/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,
You mean amountstatus columns contains text data either "paid" or "unpaid" ??
If i understand it clearly then i guess if that column data as "paid" then u have to check rb_paid radio button else rb_unpaid is it ?

Regards,
Sunil

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 12/12/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

yes,in amountstatus column it contains the data as paid or unpaid.Your absolutely correct sir.i need column data as "paid" then u have to check rb_paid radio button else rb_unpaid is it ?

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blessyjees on: 12/12/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

Try this

if(ds.Tables[0].Rows[0]["amountstatus"].ToString()=="paid")
{
rb_paid.Checked=true;
rb_unpaid.Checked=false;
}
else
{
rb_unpaid.Checked=true;
rb_paid.Checked=false;
}


Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 12/12/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

Thanks for replying to me.for every value it shows unpaid only.

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksingh on: 12/12/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

Debut it and check it out what value it returns for ds.Tables[0].Rows[0]["amountstatus"].ToString().ToUpper() column and parallely check it out your table data as well.

Regards,
Sunil

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 12/12/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

Thanks for replying to me.if your helping me a lot .issue was over it's show's the values.keep doing.have a nice day.

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksingh on: 12/12/2011 [Member] Starter | Points: 25

Up
0
Down
Thanks and most welcome any time..

Regards,
Sunil

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 12/12/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

If you dont mine can you give your personal id.

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksingh on: 12/12/2011 [Member] Starter | Points: 25

Up
0
Down
Ya sure,
sunil.08singh@gmail.com

Regards,
Sunil

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sudheep.grandhe on: 12/12/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

I am sending the friend request to you.please accept the same.

Best,
Sudheep.

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response