i have table like(items and price)
ITEMS
Sno Items Rate
1 Chips 4.5
2 Cake 10
3 Samosa 5
i have front end like below
Items Qunty Amount
label1 4 label4
label2 5 label5
label3 3 label6
label1,label2,label3 load data ITEMS COLOUM from ITEMS TABLE
when i enter qunty in textbox .. LABEL4 DISPLAY qunty multiply rate in Items Table ( 4.5 * 2=9)
i want o/p like
Items Qunty Amount
Chips 2 9
Cake 5 50
Samosa 3 15 PLZ WRITE CSHARP CODE..................
Ranjit PowarPosted Apr 20, 2014, 2:33 AM
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace CCornerItemDemo
{
public partial class Form1 : Form
{
SqlConnection conn;
SqlDataAdapter da;
DataSet ds;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
conn = new SqlConnection("data source=.;initial catalog=ranjit;integrated security=true");
da = new SqlDataAdapter("select Items from Items",conn );
ds = new DataSet();
da.Fill(ds);
label1.Text = ds.Tables[0].Rows[0]["Items"].ToString();
label2.Text = ds.Tables[0].Rows[1]["Items"].ToString();
label3.Text = ds.Tables[0].Rows[2]["Items"].ToString();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
da = new SqlDataAdapter("select Rate from Items Where sno=1", conn);
ds = new DataSet();
da.Fill(ds);
double rate = Convert.ToDouble(ds.Tables[0].Rows[0]["Rate"].ToString());
double qty;
if (string.IsNullOrEmpty(textBox1.Text))
{
qty = 0;
}
else
qty = Convert.ToDouble(textBox1.Text );
label6.Text = (rate * qty).ToString();
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
da = new SqlDataAdapter("select Rate from Items Where sno=2", conn);
ds = new DataSet();
da.Fill(ds);
double rate = Convert.ToDouble(ds.Tables[0].Rows[0]["Rate"].ToString());
double qty;
if (string.IsNullOrEmpty(textBox2.Text))
{
qty = 0;
}
else
qty = Convert.ToDouble(textBox2.Text);
label5.Text = (rate * qty).ToString();
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
da = new SqlDataAdapter("select Rate from Items Where sno=3", conn);
ds = new DataSet();
da.Fill(ds);
double rate = Convert.ToDouble(ds.Tables[0].Rows[0]["Rate"].ToString());
double qty;
if (string.IsNullOrEmpty(textBox3.Text))
{
qty = 0;
}
else
qty = Convert.ToDouble(textBox3.Text);
label4.Text = (rate * qty).ToString();
}
}
}