/// <summary> /// 刷新控件 /// </summary> void RefreshControl() { ClearControl(); if (dataGridView1.CurrentRow != null) { View_S_MaterialDetainList goods = GetGoodsInfo(dataGridView1.CurrentRow); txtCode.Text = goods.图号型号; txtName.Tag = goods.物品ID; txtName.Text = goods.物品名称; txtSpec.Text = goods.规格; txtProvider.Text = goods.供应商; txtAssociateID.Text = goods.关联订单号; if (!GlobalObject.GeneralFunction.IsNullOrEmpty(goods.批次号)) { txtBatchNo.Text = goods.批次号; } numAmount.Value = (decimal)goods.扣货数; txtUnit.Text = goods.单位; txtRemark.Text = goods.备注; } }
/// <summary> /// 从行记录中提取物品对象信息 /// </summary> /// <param name="row">行记录</param> /// <returns>提取的物品信息</returns> View_S_MaterialDetainList GetGoodsInfo(DataGridViewRow row) { if (row == null) { return(null); } View_S_MaterialDetainList goods = new View_S_MaterialDetainList(); goods.序号 = (int)row.Cells["序号"].Value; goods.扣货单号 = (string)row.Cells["扣货单号"].Value; goods.物品ID = (int)row.Cells["物品ID"].Value; goods.图号型号 = (string)row.Cells["图号型号"].Value; goods.物品名称 = (string)row.Cells["物品名称"].Value; goods.规格 = (string)row.Cells["规格"].Value; goods.供应商 = (string)row.Cells["供应商"].Value; goods.批次号 = (string)row.Cells["批次号"].Value; goods.扣货数 = (decimal)row.Cells["扣货数"].Value; goods.备注 = (string)row.Cells["备注"].Value; goods.单位 = row.Cells["单位"].Value.ToString(); goods.关联订单号 = (string)row.Cells["关联订单号"].Value.ToString(); View_F_GoodsPlanCost basicGoodsInfo = null; IBasicGoodsServer basicGoodsServer = ServerModuleFactory.GetServerModule <IBasicGoodsServer>(); basicGoodsInfo = basicGoodsServer.GetGoodsInfo(goods.图号型号, goods.物品名称, goods.规格, out m_strErr); if (!GlobalObject.GeneralFunction.IsNullOrEmpty(m_strErr)) { MessageDialog.ShowErrorMessage(m_strErr); return(null); } return(goods); }
private void btnUpdate_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count == 0) { MessageDialog.ShowPromptMessage("请选择一条记录后再进行此操作"); return; } if (dataGridView1.SelectedRows.Count > 1) { MessageDialog.ShowPromptMessage("只允许选择一条记录进行处理!"); return; } if (BasicInfo.ListRoles.Contains(CE_RoleEnum.采购员.ToString()) && m_operateMode == CE_BusinessOperateMode.采购确认) { if (txtAssociateID.Text.Trim() != "") { if (!m_goodsServer.UpdateList(m_strBillID, txtName.Tag.ToString(), txtAssociateID.Text, txtBatchNo.Text.Trim(), out m_strErr)) { MessageDialog.ShowErrorMessage(m_strErr); return; } } else { MessageDialog.ShowPromptMessage("请选择关联订单号!"); } } else if (m_strBillStatus.Equals("新建单据")) { S_MaterialDetainList goods = new S_MaterialDetainList(); View_S_MaterialDetainList viewGoods = GetGoodsInfo(dataGridView1.SelectedRows[0]); goods.ID = viewGoods.序号; goods.Bill_ID = m_strBillID; if (txtName.Tag != null && (int)txtName.Tag != 0) { goods.GoodsID = (int)txtName.Tag; } else { goods.GoodsID = viewGoods.物品ID; } goods.Provider = txtProvider.Text; goods.BatchNo = txtBatchNo.Text; goods.Amount = numAmount.Value; goods.Remark = txtRemark.Text; if (!m_goodsServer.UpdateList(goods, m_strStorageID, out m_strErr)) { MessageDialog.ShowErrorMessage(m_strErr); return; } } RefreshDataGridView(m_goodsServer.GetList(m_strBillID, out m_strErr)); PositioningRecord(m_strBillID); ClearControl(); }