private void button5_Click(object sender, EventArgs e) { double summ = 0; var d = from price in allDataSet.Tovar.AsEnumerable() where price.Field <int>("id") == Convert.ToInt32(listBox1.SelectedValue) select price; foreach (var obj in d) { summ = Convert.ToDouble(obj.price) * Convert.ToInt32(textBox2.Text); SqlCeConnection conn = new SqlCeConnection(@"Data Source=C:\Users\Андрей свали с компа\Desktop\myDB.sdf"); conn.Open(); using (SqlCeCommand c = new SqlCeCommand(@"update Tovar set kolvo=" + (obj.kolvo - Convert.ToInt32(textBox2.Text)).ToString() + " where id=" + obj.id)) { c.Connection = conn; c.ExecuteNonQuery(); } conn.Close(); } kursOOPpart2.Skidka sk = new kursOOPpart2.Skidka(summ); sk.ShowDialog(); label9.Text = (sk.met() / 100).ToString(); label10.Text = Math.Round((summ - summ * Convert.ToDouble(label9.Text)), 2).ToString(); }
private void button5_Click(object sender, EventArgs e) { double summ=0; var d = from price in allDataSet.Tovar.AsEnumerable() where price.Field<int>("id") == Convert.ToInt32(listBox1.SelectedValue) select price; foreach (var obj in d) { summ = Convert.ToDouble(obj.price) * Convert.ToInt32(textBox2.Text); SqlCeConnection conn = new SqlCeConnection(@"Data Source=C:\Users\Андрей свали с компа\Desktop\myDB.sdf"); conn.Open(); using (SqlCeCommand c = new SqlCeCommand(@"update Tovar set kolvo=" + (obj.kolvo - Convert.ToInt32(textBox2.Text)).ToString() + " where id="+obj.id)) { c.Connection = conn; c.ExecuteNonQuery(); } conn.Close(); } kursOOPpart2.Skidka sk = new kursOOPpart2.Skidka(summ); sk.ShowDialog(); label9.Text = (sk.met()/100).ToString(); label10.Text = Math.Round((summ-summ*Convert.ToDouble(label9.Text)),2).ToString(); }