protected override void ds_SetOneRouteEvent(object sender, SetOneRouteResultEventArgs e) { if (sender == null || !(sender is DataFromSystem)) { return; } DataFromSystem ds = (DataFromSystem)sender; if (e.Route == 1) { leftRoute1.Text = e.Res; if (EnterFirstRoute()) { SetEditMode(false); ResultListSpeed.RefreshTable(listID, baseIID, RefreshData, cn, CR); fromEvent = true; try { SetNextClimber(); } finally { fromEvent = false; } if (leftIID.Text.Length > 0 && leftName.Text.Length > 0) { ds.Route1 = leftIID.Text + " " + leftName.Text + " (��.� " + leftStart.Text + ")"; } else { ds.Route1 = ""; } } } else if (e.Route == 2 && IFSC_WR && (e.Res.IndexOf("�/�") > -1)) { string iidLeft = leftIID.Text, resLeft = leftRoute1.Text, res2left = leftRoute2.Text, sumLeft = leftSum.Text; leftIID.Text = lblIID.Text; leftRoute1.Text = e.Res; if (EnterFirstRoute(true)) { SetEditMode(false); ResultListSpeed.RefreshTable(listID, baseIID, RefreshData, cn, CR); fromEvent = true; try { SetNextClimber(); } finally { fromEvent = false; } if (!String.IsNullOrEmpty(lblIID.Text) && !String.IsNullOrEmpty(lblName.Text)) { ds.Route2 = lblIID.Text + " " + lblName.Text + " (��.� " + lblStart.Text + ")"; } else { ds.Route2 = String.Empty; } } } }
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); } }
protected override void btnEdit_Click(object sender, EventArgs e) { if (btnEdit.Text == "������") { SetEditMode(true); return; } bool error = false; bool br = false; Dictionary <string, string> valLeft = null, valRight = null; int nTmp; long?resIdLeft, resIdRight; try { if (int.TryParse(leftIID.Text, out nTmp)) { resIdLeft = ResultListSpeed.GetClimbersResSpeed(nTmp, listID, cn, out valLeft); } else { resIdLeft = null; } } catch { resIdLeft = null; } try { if (int.TryParse(lblIID.Text, out nTmp)) { resIdRight = ResultListSpeed.GetClimbersResSpeed(nTmp, listID, cn, out valRight); } else { resIdRight = null; } } catch { resIdRight = null; } try { if (leftIID.Text.Length > 0) { //if (leftRoute1.Text.Length > 0) //{ if (leftRoute1.Text.IndexOf("�/�") > -1 || !UseBestRoute && (leftRoute1.Text.IndexOf("����") > -1 || leftRoute1.Text.IndexOf("�����") > -1)) { leftRoute2.Text = leftSum.Text = ""; } if (leftRoute2.Text.Length > 0 || leftSum.Text.Length > 0) { if (leftSum.Text.IndexOf("����") > -1 || leftSum.Text.IndexOf("�/�") > -1 || leftSum.Text.IndexOf("�����") > -1) { leftSum.Text = ""; ResultListSpeed.ClearClimber(3, leftIID.Text, listID, cn); error = !EnterFirstRoute(); } else { if (leftRoute2.Text.Length > 0 && leftSum.Text.Length > 0) { leftSum.Text = ""; } error = !EnterBothRoutes(leftIID, leftRoute1, leftRoute2, leftSum); } } else { error = !EnterFirstRoute(); } //} //else //{ // error = true; // MessageBox.Show("������� ��������� �� 1 ������"); //} } if (lblIID.Text.Length > 0) { //if (rightRoute2.Text.Length > 0 || rightSum.Text.Length > 0) error = error || (!(br = EnterBothRoutes())); //else //{ // error = true; // MessageBox.Show("������� ��������� 2 ������ ��� �����"); //} } } catch (Exception ex) { error = true; MessageBox.Show("������ ����� �����������\r\n" + ex.Message); } if (br && (!error)) { SqlCommand cmd = new SqlCommand(); } if (!error) { SetEditMode(false); ResultListSpeed.RefreshTable(listID, baseIID, RefreshData, cn, CR); if (resIdLeft != null && resIdLeft.HasValue || resIdRight != null && resIdRight.HasValue) { SqlTransaction tran = cn.BeginTransaction(); try { Dictionary <string, string> newVals; if (resIdLeft != null && resIdLeft.HasValue) { ResultListSpeed.GetClimbersResSpeed(resIdLeft.Value, cn, out newVals, tran); ResultListSpeed.AddTransaction(resIid: resIdLeft.Value, oldValues: valLeft, newValues: newVals, cn: cn, tran: tran); } if (resIdRight != null && resIdRight.HasValue) { ResultListSpeed.GetClimbersResSpeed(resIdRight.Value, cn, out newVals, tran); ResultListSpeed.AddTransaction(resIid: resIdRight.Value, oldValues: valRight, newValues: newVals, cn: cn, tran: tran); } tran.Commit(); } catch (Exception ex) { try { tran.Rollback(); } catch { } MessageBox.Show(this, "������ ���������� ������� ����������:\r\n" + ex.Message); } } RefreshData(); } }