110,538
社区成员
发帖
与我相关
我的任务
分享
private void grid_Main_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
int row = e.RowIndex;
int col = e.ColumnIndex;
string str = grid_Main.Rows[row].Cells[col].EditedFormattedValue.ToString();
if (grid_Main.Rows[row].Cells[col].Value != null &&
str == grid_Main.Rows[row].Cells[col].Value.ToString())
{
return;
}
if (grid_Main.CurrentCell.ColumnIndex == grid_Main.Columns["col_code"].Index && (ItemType)grid_Main.Rows[row].Cells["col_zmtype"].Tag != ItemType.SectionItem)
{
if (string.IsNullOrEmpty(str)) return;
if ((ItemType)grid_Main.Rows[row].Cells["col_zmtype"].Tag == ItemType.BillItem)
{
DataTable dt = this.dataTransaction.GetDataTable("Bill");
if (dt == null)
{
dt = this.dataTransaction.GetDataTable("select * from Bill", "Bill", DataBaseType.BillDB);
}
DataRow[] rows = dt.Select("billcode='" + str + "'");
if (rows.Length == 0) return;
FillBillInfo(rows[0], false);
}
else if ((ItemType)grid_Main.Rows[row].Cells["col_zmtype"].Tag == ItemType.NormItem)
{
DataTable dt = this.dataTransaction.GetDataTable("Norm");
if (dt == null)
{
dt = this.dataTransaction.GetDataTable("select * from Norm", "Norm", DataBaseType.NormDB);
}
DataRow[] rows = dt.Select("normcode='" + str + "' and procode='" + normProKind + "'");
if (rows.Length == 0) return;
FillNormInfo(rows[0], false);
}
}
else if (col == grid_Main.Columns["col_amount"].Index)
{
this.projectTransaction.UpdateValuationItem(grid_Main.Rows[row], row);
}
else
{
this.projectTransaction.UpdateValuationItem(grid_Main.Rows[row], row);
}
}