예제 #1
0
파일: Form2.cs 프로젝트: itzsahabuddin/rcs
        private void Form2_Load(object sender, EventArgs e)
        {
            PName.Text = "Select-an-option";
            Qty.Clear();
            Rate.Clear();
            SqlDataAdapter da = new SqlDataAdapter("select Product_Name from Add_Product ", con);
            DataSet        ds = new DataSet();

            da.Fill(ds, "login");
            int index = 0;

            for (index = 0; index < ds.Tables[0].Rows.Count; index++)
            {
                PName.Items.Add(ds.Tables[0].Rows[index][0]);
            }
        }
예제 #2
0
        private void PName_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                SqlConnection con = new SqlConnection(G_Class.constr);
                con.Open();

                SqlDataAdapter adp = new SqlDataAdapter("select Qty, Rate from Stock_Details where Product_Name='" + PName.Text.Trim() + "'", con);
                DataSet        ds  = new DataSet();
                adp.Fill(ds);
                TextQ.Text = ds.Tables[0].Rows[0][0].ToString().Trim();
                Rate.Text  = ds.Tables[0].Rows[0][1].ToString().Trim();
                //con.Close();
            }
            catch
            {
                TextQ.Clear();
                Rate.Clear();
            }
        }