如何获取每一行的详情信息

public void flight()
{
string num = dgvlist.SelectedRows[0].Cells[0].Value.ToString();
string name = dgvlist.SelectedRows[0].Cells[1].Value.ToString();
string fromtime = dgvlist.SelectedRows[0].Cells[2].Value.ToString();
string totime = dgvlist.SelectedRows[0].Cells[3].Value.ToString();
double price = Convert.ToDouble(dgvlist.SelectedRows[0].Cells[4].Value);
string chu = comboBox1.Text;
string mu = comboBox2.Text;

textBox1.Text = num;
textBox2.Text = chu;
textBox3.Text = fromtime;
textBox4.Text = price.ToString();
textBox5.Text = name;
textBox6.Text = mu;
textBox7.Text = totime;
}

 

随机数的方法

Random rd = new Random(); //随机数
int num = rd.Next(100000,10000000);
try
{
conn.Open();

if (DateTime.Now < dtptime.Value)
{
string sql = "insert into OrderInfo values('" + num + "','" + textBox1.Text + "','" + dtptime.Text.ToString() + "','" + nudshul.Value.ToString() + "')";
SqlCommand comm = new SqlCommand(sql, conn);
int aa = comm.ExecuteNonQuery();
if (aa > 1)
{
}
MessageBox.Show("预定成功!订单编号为:" + num);
}
else
{
MessageBox.Show("失败");
}
}
catch (Exception e)
{
MessageBox.Show("异常"+ e);

}
finally
{
conn.Close();
}
}

posted @ 2018-03-08 14:46  空想sir  阅读(257)  评论(0编辑  收藏  举报