/// <summary> /// 新增物料 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { int clientOid = 0; ExtractInventoryTool_Material material = null; DataGridViewSelectedRowCollection rowCollection = dataGridView1.SelectedRows; DataGridViewRow row = null; if (rowCollection.Count != 1) { MessageBox.Show("请选中一条客户进行添加物料备案", "Warning"); return; } row = rowCollection[0]; if (row != null && row.Cells[0].Value != null) { material = new ExtractInventoryTool_Material(); material.Oid = 0; material.Client = int.TryParse(row.Cells[0].Value.ToString().Trim(), out clientOid) ? clientOid : 0; } Form_MaterialEditor editor = new Form_MaterialEditor(material); editor.ShowDialog(this); if (editor.DialogResult == DialogResult.OK) { Task.Run(() => QueryMaterialByClientID(clientOid.ToString())); } return; }
/// <summary> /// 更新物料 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button3_Click(object sender, EventArgs e) { int clientOid = 0; ExtractInventoryTool_Material material = null; DataGridViewSelectedRowCollection clientRowCollection = dataGridView1.SelectedRows; DataGridViewSelectedRowCollection materialRowCollection = dataGridView2.SelectedRows; DataGridViewRow clientRow = null; DataGridViewRow materialRow = null; if (clientRowCollection.Count != 1) { MessageBox.Show("请选中一条客户进行更新物料备案", "Warning"); return; } if (materialRowCollection.Count != 1) { MessageBox.Show("请选中一条物料进行更新", "Warning"); return; } clientRow = clientRowCollection[0]; materialRow = materialRowCollection[0]; if (clientRow != null && clientRow.Cells[0].Value != null && materialRow != null && materialRow.Cells[0].Value != null) { material = new ExtractInventoryTool_Material(); int oid = 0; material.Oid = int.TryParse(materialRow.Cells[0].Value.ToString().Trim(), out oid) ? oid : 0; material.Name = materialRow.Cells[1].Value.ToString().Trim(); material.Code = materialRow.Cells[2].Value.ToString().Trim(); material.Supplier = materialRow.Cells[3].Value.ToString().Trim(); material.SupplierCode = materialRow.Cells[4].Value.ToString().Trim(); material.Client = int.TryParse(clientRow.Cells[0].Value.ToString().Trim(), out clientOid) ? clientOid : 0; } Form_MaterialEditor editor = new Form_MaterialEditor(material); editor.ShowDialog(this); if (editor.DialogResult == DialogResult.OK) { Task.Run(() => QueryMaterialByClientID(clientOid.ToString())); } return; }