/// <summary>
/// 单元格改变事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void grvShowList_CellValueChanged(object sender, CellValueChangedEventArgs e)
{
if (grvShowList.RowCount > 0 && e.RowHandle >= 0)
{
if (grvShowList.FocusedColumn.FieldName == "PrimaxQty" || grvShowList.FocusedColumn.FieldName == "PACKRATE")
{
try
{
int handle = e.RowHandle;
decimal i = 0;
decimal PrimaxQty = 0;
//decimal PACKRATE = 0;
if (decimal.TryParse(grvShowList.GetRowCellValue(grvShowList.FocusedRowHandle, "PrimaxQty").ToString(), out i))
{
PrimaxQty = Convert.ToDecimal(grvShowList.GetRowCellValue(grvShowList.FocusedRowHandle, "PrimaxQty").ToString());
}
SearchCondition con = new SearchCondition();
con.AddCondition("PO", grvShowList.GetRowCellValue(grvShowList.FocusedRowHandle, "PO").ToString(),SqlOperator.Equal);
con.AddCondition("Item", grvShowList.GetRowCellValue(grvShowList.FocusedRowHandle, "Item").ToString(), SqlOperator.Equal);
MST_ASN_PRINTDATAInfo info = BLLFactory<MST_ASN_PRINTDATA>.Instance.FindSingle(con.BuildConditionSql());
if (info==null)
{
return;
}
//if (decimal.TryParse(grvShowList.GetRowCellValue(grvShowList.FocusedRowHandle, "PACKRATE").ToString(), out i))
//{
// PACKRATE = Convert.ToDecimal(grvShowList.GetRowCellValue(grvShowList.FocusedRowHandle, "PACKRATE").ToString());
//}
decimal SulQty = PrimaxQty - (info.PrimaxQty - info.DoneQty);
if (SulQty >= 0)
{
if (grvShowList.GetRowCellValue(grvShowList.FocusedRowHandle, "SulQty").ToString() == "" || SulQty != Convert.ToDecimal(grvShowList.GetRowCellValue(grvShowList.FocusedRowHandle, "SulQty").ToString()))
{
grvShowList.SetRowCellValue(grvShowList.FocusedRowHandle, "SulQty", SulQty);
}//此处判断很重要
}
else {
SulQty = 0;
if (grvShowList.GetRowCellValue(grvShowList.FocusedRowHandle, "SulQty").ToString() == "" || SulQty != Convert.ToDecimal(grvShowList.GetRowCellValue(grvShowList.FocusedRowHandle, "SulQty").ToString()))
{
grvShowList.SetRowCellValue(grvShowList.FocusedRowHandle, "SulQty", SulQty);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}