void OperationInfo(CE_OperatorMode mode) { WS_MaterialsTransferExceptionListDispose tempLnq = new WS_MaterialsTransferExceptionListDispose(); tempLnq.ID = dataGridView2.CurrentRow == null ? 0 : Convert.ToInt32(dataGridView2.CurrentRow.Cells["ID"].Value); tempLnq.BatchNo = txtBatchNo.Text; tempLnq.Counts = numOperationCount.Value; tempLnq.GoodsID = Convert.ToInt32(txtCode.Tag); tempLnq.ListID = Convert.ToInt32(dataGridView1.CurrentRow.Cells["ID"].Value); m_serverException.OperationDisposeInfo(mode, tempLnq, out m_strError); dataGridView2.DataSource = m_serverException.GetDisposeInfo((int)dataGridView1.CurrentRow.Cells["ID"].Value); switch (mode) { case CE_OperatorMode.添加: case CE_OperatorMode.修改: PositioningRecord(tempLnq.GoodsID, tempLnq.BatchNo); break; case CE_OperatorMode.除: break; default: break; } }
/// <summary> /// 处理异常信息 /// </summary> /// <param name="mode">操作模式</param> /// <param name="operationDispose">处理信息</param> /// <param name="error">错误信息</param> /// <returns>成功返回True,失败返回False</returns> public bool OperationDisposeInfo(GlobalObject.CE_OperatorMode mode, WS_MaterialsTransferExceptionListDispose operationDispose, out string error) { error = null; try { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; var varData = from a in ctx.WS_MaterialsTransferExceptionListDispose select a; WS_MaterialsTransferExceptionListDispose tempLnq = new WS_MaterialsTransferExceptionListDispose(); switch (mode) { case CE_OperatorMode.添加: tempLnq.BatchNo = operationDispose.BatchNo; tempLnq.Counts = operationDispose.Counts; tempLnq.GoodsID = operationDispose.GoodsID; tempLnq.ListID = operationDispose.ListID; ctx.WS_MaterialsTransferExceptionListDispose.InsertOnSubmit(operationDispose); break; case CE_OperatorMode.修改: varData = from a in varData where a.ID == operationDispose.ID select a; if (varData.Count() != 1) { throw new Exception("数据序号不唯一"); } else { tempLnq = varData.Single(); tempLnq.BatchNo = operationDispose.BatchNo; tempLnq.Counts = operationDispose.Counts; tempLnq.GoodsID = operationDispose.GoodsID; } break; case CE_OperatorMode.除: varData = from a in varData where a.ID == operationDispose.ID select a; ctx.WS_MaterialsTransferExceptionListDispose.DeleteAllOnSubmit(varData); break; default: break; } ctx.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }