/// <summary> /// 刷新控件 /// </summary> void RefreshControl() { ClearControl(); if (dataGridView1.CurrentRow != null) { View_S_HomemadeRejectList goods = GetGoodsInfo(dataGridView1.CurrentRow); txtCode.Text = goods.图号型号; txtCode.Tag = goods.物品ID; txtName.Text = goods.物品名称; txtSpec.Text = goods.规格; txtProvider.Text = goods.供应商; txtProviderBatchNo.Text = goods.供方批次; if (!string.IsNullOrEmpty(goods.批次号)) { txtBatchNo.Text = goods.批次号; } numAmount.Value = goods.退货数; txtUnit.Text = goods.单位; txtDepot.Text = goods.物品类别; txtShelf.Text = goods.货架; txtColumn.Text = goods.列; txtLayer.Text = goods.层; txtRemark.Text = goods.备注; } }
private void btnUpdate_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count == 0) { MessageDialog.ShowPromptMessage("请选择要修改的记录后再进行此操作"); return; } else if (dataGridView1.SelectedRows.Count > 1) { MessageDialog.ShowPromptMessage("只能选择要修改的一条记录后再进行此操作"); return; } if (!CheckDataItem()) { return; } S_HomemadeRejectList goods = new S_HomemadeRejectList(); View_S_HomemadeRejectList viewGoods = GetGoodsInfo(dataGridView1.SelectedRows[0]); goods.ID = viewGoods.序号; goods.Bill_ID = m_strBillID; if (txtCode.Tag != null && (int)txtCode.Tag != 0) { goods.GoodsID = (int)txtCode.Tag; } else { goods.GoodsID = viewGoods.物品ID; } goods.Provider = txtProvider.Text; goods.ProviderBatchNo = txtProviderBatchNo.Text; goods.BatchNo = txtBatchNo.Text; goods.Amount = numAmount.Value; goods.Remark = txtRemark.Text; if (!m_goodsServer.UpdateGoods(goods, m_strStorage, out m_strErr)) { MessageDialog.ShowErrorMessage(m_strErr); return; } GetCodeInfoFromForm(); m_queryGoodsInfo = m_goodsServer.GetBillView(m_strBillID);//.GetGoods(BillNo); RefreshDataGridView(m_queryGoodsInfo); PositioningRecord(m_strGoodsCode, m_strGoodsName, m_strSpec); }
/// <summary> /// 从行记录中提取物品对象信息 /// </summary> /// <param name="row">行记录</param> /// <returns>提取的物品信息</returns> View_S_HomemadeRejectList GetGoodsInfo(DataGridViewRow row) { if (row == null) { return(null); } View_S_HomemadeRejectList goods = new View_S_HomemadeRejectList(); goods.序号 = (long)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.供方批次 = (string)row.Cells["供方批次"].Value; goods.退货数 = (decimal)row.Cells["退货数"].Value; goods.备注 = (string)row.Cells["备注"].Value; View_F_GoodsPlanCost basicGoodsInfo = null; if (row.Cells["单位"].Value != System.DBNull.Value) { goods.单位 = (string)row.Cells["单位"].Value; goods.物品类别 = (string)row.Cells["物品类别"].Value; goods.货架 = Convert.ToString(row.Cells["货架"].Value); goods.列 = Convert.ToString(row.Cells["列"].Value); goods.层 = Convert.ToString(row.Cells["层"].Value); } else { IBasicGoodsServer basicGoodsServer = ServerModuleFactory.GetServerModule <IBasicGoodsServer>(); basicGoodsInfo = basicGoodsServer.GetGoodsInfo(goods.图号型号, goods.物品名称, goods.规格, out m_strErr); if (!string.IsNullOrEmpty(m_strErr)) { MessageDialog.ShowErrorMessage(m_strErr); return(null); } goods.单位 = basicGoodsInfo.单位; } return(goods); }