我把代码修改了下,核对是可以了,但是提示还不行.只要点"核对"按钮就报错.主要是获取物资的名称,现在无法获取.
Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a correct format.
Source Error:
Line 208:MinCount[i] = int.Parse(this.gv_Massage.Rows[i].Cells[4].Text.Trim()); //获取最低数量值
Line 209: SaveCount[i] = int.Parse(this.gv_TakesInventoryMessage.Rows[i].Cells[2].Text.Trim());//获取库存数量
Line 210: m_MaterailCaption[i] = int.Parse(this.gv_Massage.Rows[i].Cells[3].Text.Trim());//获取物资名称
Line 211: if (MinCount[i] < SaveCount[i]) //当最低数量小于库存数量
Line 212: {
Source File: d:\Csharp\MaterialMIS\MaterialMIS\MaterialInfo\TakesInventory.aspx.cs Line: 210
代码如下(红色为相关的代码):
protected void btn_DataCheckup_Click(object sender, EventArgs e)
{
int row = this.gv_Massage.Rows.Count; //取物资盘存信息清单的行数
int rows = this.gv_TakesInventoryMessage.Rows.Count; //取物资库存信息表的行数
//比较行数
if (row != rows)
{
ScriptUtils.AlertAndFocus("数据表中的行数不一致,不能进行核对!", "txt_ID", this);
return;
}
else
{
//定义数组w
int[] MinCount = new int[20];
int[] SaveCount = new int[20];
int[] m_MaterailCaption = new int[20];
for (int i = 0; i < rows; i++)
{
//获取列的值
MinCount[i] = int.Parse(this.gv_Massage.Rows[i].Cells[4].Text.Trim());//获取最低数量值
SaveCount[i] = int.Parse(this.gv_TakesInventoryMessage.Rows[i].Cells[2].Text.Trim());//获取库存数量
m_MaterailCaption[i] = int.Parse(this.gv_Massage.Rows[i].Cells[3].Text.Trim()); //获取物资名称
if (MinCount[i] < SaveCount[i]) //当最低数量小于库存数量
{
lb_ErrorMessage.Text += "<font color='#ff0000'>";
lb_ErrorMessage.Text += "物资名称为:['"+ m_MaterailCaption +"'],数据不一致,表现为盘亏,请修改.";
lb_ErrorMessage.Text += "</font>";
}
else
{
if (MinCount[i] > SaveCount[i]) //当最低数量大于库存数量
{
lb_ErrorMessage.Text += "<font color='#ff0000'>";
lb_ErrorMessage.Text += "物资名称为:['"+ m_MaterailCaption +"'],数据不一致,表现为盘溢,请修改.";
lb_ErrorMessage.Text += "</font>";
}
else { }
}
}
}
[此贴子已经被作者于2007-2-26 15:56:32编辑过]