/// <summary>
        /// 刷新控件
        /// </summary>
        void RefreshControl()
        {
            ClearControl();

            if (dataGridView1.CurrentRow != null)
            {
                View_S_MaterialListRejectBill goods = GetGoodsInfo(dataGridView1.CurrentRow);

                txtCode.Text        = goods.图号型号;
                txtCode.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 = 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_MaterialListRejectBill      goods     = new S_MaterialListRejectBill();
            View_S_MaterialListRejectBill viewGoods = GetGoodsInfo(dataGridView1.SelectedRows[0]);

            goods.ID      = viewGoods.序号;
            goods.Bill_ID = m_billNo;

            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(txtAssociateID.Text, goods, m_strStorage, out m_error))
            {
                MessageDialog.ShowErrorMessage(m_error);
                return;
            }

            GetCodeInfoFromForm();
            m_queryGoodsInfo = m_goodsServer.GetGoods(m_billNo);
            RefreshDataGridView(m_queryGoodsInfo);
            PositioningRecord(m_strGoodsCode, m_strGoodsName, m_strSpec);
        }
        /// <summary>
        /// 从行记录中提取物品对象信息
        /// </summary>
        /// <param name="row">行记录</param>
        /// <returns>提取的物品信息</returns>
        View_S_MaterialListRejectBill GetGoodsInfo(DataGridViewRow row)
        {
            if (row == null)
            {
                return(null);
            }

            View_S_MaterialListRejectBill goods = new View_S_MaterialListRejectBill();

            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;
            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.货架   = (string)row.Cells["货架"].Value;
                goods.列    = (string)row.Cells["列"].Value;
                goods.层    = (string)row.Cells["层"].Value;
            }
            else
            {
                IBasicGoodsServer basicGoodsServer = ServerModuleFactory.GetServerModule <IBasicGoodsServer>();
                basicGoodsInfo = basicGoodsServer.GetGoodsInfo(goods.图号型号, goods.物品名称, goods.规格, out m_error);

                if (!GlobalObject.GeneralFunction.IsNullOrEmpty(m_error))
                {
                    MessageDialog.ShowErrorMessage(m_error);
                    return(null);
                }

                goods.单位 = basicGoodsInfo.单位;
            }

            return(goods);
        }
        private void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                View_S_MaterialListRejectBill curGoods = GetGoodsInfo(dataGridView1.Rows[i]);

                if (i != dataGridView1.Rows.Count - 1)
                {
                    View_S_MaterialListRejectBill nextGoods = GetGoodsInfo(dataGridView1.Rows[i + 1]);

                    if (curGoods.图号型号 == nextGoods.图号型号 && curGoods.物品名称 == nextGoods.物品名称)
                    {
                        dataGridView1.Rows[i].DefaultCellStyle.ForeColor     = Color.Blue;
                        dataGridView1.Rows[i + 1].DefaultCellStyle.ForeColor = Color.Blue;
                    }
                }
            }
        }