private void btnAdd_Click(object sender, EventArgs e) { if (numPickingCount.Value == 0) { MessageDialog.ShowPromptMessage("添加物品数量不能为0"); return; } else if (!m_serverStore.IsBatchNoOfGoodsExist(Convert.ToInt32(txtName.Tag), txtBatchNo.Text.ToString())) { MessageDialog.ShowPromptMessage("此批次在库房不存在,请重新选择"); return; } else if (numPickingCount.Value > (txtSpec.Tag == null ? 0 : Convert.ToDecimal(txtSpec.Tag))) { MessageDialog.ShowPromptMessage("领用数大于库存数【" + txtSpec.Tag + "】,请重新核对领用数量"); return; } DataTable dt = (DataTable)dataGridView1.DataSource; for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["物品ID"].ToString() == txtName.Tag.ToString() && dt.Rows[i]["批次号"].ToString() == txtBatchNo.Text) { MessageDialog.ShowPromptMessage("不能添加同一物品,同一批次号"); return; } } DataRow dr = dt.NewRow(); dr["图号型号"] = txtCode.Text; dr["物品名称"] = txtName.Text; dr["规格"] = txtSpec.Text; dr["批次号"] = txtBatchNo.Text; dr["领用数量"] = numPickingCount.Value; dr["单位"] = txtBatchNo.Tag.ToString(); dr["单价"] = 0; dr["金额"] = 0; dr["策略金额"] = 0; dr["备注"] = txtRemark.Text; dr["物品ID"] = (int)txtName.Tag; dr["单据号"] = m_lnqBill.Bill_ID; dr["是否为客户责任"] = false; dt.Rows.Add(dr); RefreshInfo(dt); ClearMessage(); SumPrice(); PositioningRecord(Convert.ToInt32(dr["物品ID"]), dr["批次号"].ToString()); }