/// <summary> /// 单击单元格内容时发生 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == dataGridView1.Columns["cDetail"].Index) { object v = dataGridView1.Rows[e.RowIndex].Cells["cSupplyID"].Value; if (v != null) { string supplyID = v.ToString(); //frmSupplyDetail f = new frmSupplyDetail(supplyID); frmSupplyReport f = new frmSupplyReport(supplyID); // 本项目的 frmSupplyReport 窗体 f.ShowDialog(); } } else if (e.ColumnIndex == dataGridView1.Columns["cDel"].Index) { if (MessageBox.Show(this, "删除后数据不能恢复,是否继续删除?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { object v = dataGridView1.Rows[e.RowIndex].Cells["cSupplyID"].Value; if (v != null) { Supply no = new Supply(); int re = no.Delete(v.ToString()); if (re > 0) { MessageBox.Show("删除成功!"); BindDGV(); } else { MessageBox.Show("删除失败!"); } } } } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == dataGridView1.Columns["cDetail"].Index) { object v = dataGridView1.Rows[e.RowIndex].Cells["cSupplyID"].Value; if (v != null) { string supplyID = v.ToString(); //frmSupplyDetail f = new frmSupplyDetail(supplyID); frmSupplyReport f = new frmSupplyReport(supplyID); f.ShowDialog(); } } else if (e.ColumnIndex == dataGridView1.Columns["cDel"].Index) { if (MessageBox.Show(this, "删除后数据不能恢复,是否继续删除?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { object v = dataGridView1.Rows[e.RowIndex].Cells["cSupplyID"].Value; if (v != null) { Supply no = new Supply(); int re = no.Delete(v.ToString()); if (re > 0) { MessageBox.Show("删除成功!"); BindDGV(); } else { MessageBox.Show("删除失败!"); } } } } }
private void button1_Click(object sender, EventArgs e) { if (cbx_Agent.SelectedValue == null) { MessageBox.Show("请先选择客户!"); cbx_Agent.Focus(); return; } if (cbx_Level.SelectedValue == null) { MessageBox.Show("请先选择级别!"); cbx_Level.Focus(); return; } if (allOut.Count <= 0) { MessageBox.Show("没有要出货的成品!"); return; } if (MessageBox.Show("确定要生成供货单吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.No) { return; } List <SupplyDetail> list = new List <SupplyDetail>(); foreach (InW i in allOut) { SupplyDetail s = new SupplyDetail(); s.Barcode = i.Barcode; s.NormName = i.NormName; s.SumMoney = i.SumPrice; s.Length = i.Length; s.Model = i.Model; list.Add(s); } Supply m = new Supply(); m.SupplyID = GenSupplyID(); m.AgentName = cbx_Agent.SelectedValue.ToString(); m.Price = _price; m.Operator = Global.userName; m.SumPrice = decimal.Parse(lab_Sum.Text.Replace("元", "").Trim()); int re = m.Add(list); if (re > 0) { //MessageBox.Show("生成供应单成功!"); _price = 0; cbx_Agent.SelectedIndex = -1; cbx_Level.SelectedIndex = -1; txt_Price.Text = ""; txt_Barcode.Text = ""; allOut = new List <InW>(); BindDGV(); frmSupplyReport ff = new frmSupplyReport(m.SupplyID); ff.Text = "生成供应单成功"; ff.ShowDialog(); } else { MessageBox.Show("生成供应单失败!"); } }