private void DoTranAction(int climberID, string climberName, TransactionAction action, byte routeToClean) { long?activeTranID, nextTranID, toCheck; try { ResultListSpeed.GetSpeedTransactions(climberID, listID, out activeTranID, out nextTranID, cn); toCheck = (action == TransactionAction.ROLLBACK) ? activeTranID : nextTranID; string message = (action == TransactionAction.ROLLBACK) ? "��������" : "�������"; if (toCheck == null || !toCheck.HasValue) { MessageBox.Show(this, "���������� " + message + " ���������"); return; } if (MessageBox.Show(this, "�� �������, ��� ������ " + message + " ��������� �������� ��������� (" + climberName + ")?", message + " ���������?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.No) { return; } SqlTransaction tran = cn.BeginTransaction(); try { bool res; if (action == TransactionAction.ROLLBACK) { res = StaticClass.RollbackTransaction(toCheck.Value, cn, tran); } else { res = StaticClass.RestoreLogicTransaction(toCheck.Value, cn, tran); } if (res) { ResultListSpeed.RefreshTable(listID, baseIID, RefreshData, cn, CR, tran, false); tran.Commit(); RefreshData(); ClearClimberOnRoute(routeToClean); } else { MessageBox.Show("���������� ������� ����������� ���������� ������� SQL Server"); tran.Rollback(); } } catch (Exception ex) { try { tran.Rollback(); } catch { } throw ex; } } catch (Exception ex) { MessageBox.Show("������ ���������� �������:\r\n" + ex.Message); } }
private static void SetTransactionButtonsEnabled(Control labelControl, Control rollback, Control restore, out long?activeTranID, out long?nextTranID, SqlConnection cn, int listID, SqlTransaction tran = null) { activeTranID = null; nextTranID = null; rollback.Enabled = restore.Enabled = false; int clmID; if (!int.TryParse(labelControl.Text, out clmID)) { return; } ResultListSpeed.GetSpeedTransactions(clmID, listID, out activeTranID, out nextTranID, cn, tran); rollback.Enabled = (activeTranID != null && activeTranID.HasValue); restore.Enabled = (nextTranID != null && nextTranID.HasValue); }