private void button1_Click(object sender, EventArgs e) { if (dgv_area.SelectedRows.Count <= 0) { MessageBox.Show("请选择货区!", "信息!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (dgv_place.SelectedRows.Count <= 0) { MessageBox.Show("请选择需要设置的货位!", "信息!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } List <string> collection = new List <string>(); foreach (DataGridViewRow row in dgv_place.SelectedRows) { collection.Add(row.Cells[0].Value.ToString()); } try { if (bll.UpdateArea(collection, dgv_area.SelectedRows[0].Cells[0].Value.ToString())) { MessageBox.Show("货区分配成功!", "信息!", MessageBoxButtons.OK, MessageBoxIcon.Information); Log.saveLog("货区分配成功!"); checkBox1.Checked = false; setPlaceData(); } } catch (Exception) { MessageBox.Show("与数据库连接失败,请查看网络连接是否正常。如不能解决请与网络管理员联系!", "严重错误:", MessageBoxButtons.OK, MessageBoxIcon.Error); } }