async private void UpdateData() { this.radGridViewBind.CurrentRow = this.radGridViewBind.Rows[this.radGridViewBind.Rows.Count - 1]; int rowCount = CalRowCount(); MesService.ProductMaterial[] productMaterialList = new MesService.ProductMaterial[rowCount]; int row = 0; foreach (var rowInfo in this.radGridViewBind.Rows) { MesService.ProductMaterial productMaterial = new MesService.ProductMaterial(); if (rowInfo.Cells[1].Value != null) { productMaterial.TypeNo = rowInfo.Cells[1].Value.ToString(); } if (rowInfo.Cells[2].Value != null) { var materialPn = rowInfo.Cells[2].Value.ToString(); if (materialPn.Contains("(")) { materialPn = materialPn.Substring(0, materialPn.IndexOf('(')); } productMaterial.MaterialCode = materialPn; //更新编码库存 if (productMaterial.MaterialCode.Contains("&")) { productMaterial.Stock = AnalysisMaterialCode.GetMaterialDetail(productMaterial.MaterialCode).MaterialQTY; } } if (rowInfo.Cells[3].Value != null) { productMaterial.MaterialName = rowInfo.Cells[3].Value.ToString(); } if (rowInfo.Cells[4].Value != null) { productMaterial.Describle = rowInfo.Cells[4].Value.ToString(); } productMaterial.UserName = MESMainForm.currentUser; if (rowInfo.Cells[1].Value != null && rowInfo.Cells[2].Value != null) { productMaterialList[row] = productMaterial; } row++; } //delete修改数据 foreach (var item in pmListTemp) { MesService.ProductMaterial productMaterial = new MesService.ProductMaterial(); productMaterial.MaterialCode = item.keyMaterialCode; productMaterial.TypeNo = item.keyTypeNo; int del = await serviceClient.DeleteProductMaterialAsync(productMaterial); } pmListTemp.Clear(); MesService.ProductMaterial[] materialList = await serviceClient.CommitProductMaterialAsync(productMaterialList); foreach (var material in materialList) { if (material.Result != 1) { MessageBox.Show("更新失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } MessageBox.Show("更新成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); SelectData(); }