private void btnDelete_Click(object sender, EventArgs e) { int idReplica = replicas[DGVReplicatorData.CurrentCell.RowIndex].IntIdReplica; ReplicaDA replicaDA = new ReplicaDA(); replicaDA.Delete(idReplica); Reload_Replicas(); }
private void btnEnableDisable_Click(object sender, EventArgs e) { ReplicaDA replicaDA = new ReplicaDA(); int selectedReplicaId = replicas[DGVReplicatorData.CurrentCell.RowIndex].IntIdReplica; if (!replicas[DGVReplicatorData.CurrentCell.RowIndex].BoolEnable) { replicaDA.Enable(selectedReplicaId); } else { replicaDA.Disable(selectedReplicaId); } Reload_Replicas(); }
/// <summary> /// Method that is going to update the ReplicaView List so the GridView will be updated. /// </summary> private void Reload_Replicas() { ReplicaDA replicaDA = new ReplicaDA(); replicas = replicaDA.GetAllReplicas(); List<ReplicaView> replicasView = new List<ReplicaView>(); if (replicas.Count > 0) { foreach (Replica replica in replicas) { replicasView.Add(new ReplicaView(replica)); } //Adding Order to the Unorder List DGVReplicatorData.DataSource = replicasView; DGVReplicatorData.Columns["Enable"].DisplayIndex = 0; DGVReplicatorData.Columns["SourceEngine"].DisplayIndex = 1; DGVReplicatorData.Columns["SourceIPAddress"].DisplayIndex = 2; DGVReplicatorData.Columns["SourcePort"].DisplayIndex = 3; DGVReplicatorData.Columns["SourceUser"].DisplayIndex = 4; DGVReplicatorData.Columns["SourcePassword"].DisplayIndex = 5; DGVReplicatorData.Columns["SourceDatabase"].DisplayIndex = 6; DGVReplicatorData.Columns["SourceTable"].DisplayIndex = 7; DGVReplicatorData.Columns["TerminalEngine"].DisplayIndex = 8; DGVReplicatorData.Columns["TerminalIPAddress"].DisplayIndex = 9; DGVReplicatorData.Columns["TerminalPort"].DisplayIndex = 10; DGVReplicatorData.Columns["TerminalUser"].DisplayIndex = 11; DGVReplicatorData.Columns["TerminalPassword"].DisplayIndex = 12; DGVReplicatorData.Columns["TerminalDatabase"].DisplayIndex = 13; DGVReplicatorData.Columns["Created"].DisplayIndex = 14; DGVReplicatorData.Columns["LastCheckOnSource"].DisplayIndex = 15; DGVReplicatorData.Columns["LastCheckOnTerminal"].DisplayIndex = 16; btnDelete.Enabled = true; btnEnableDisable.Enabled = true; } else { MessageBox.Show("Replicas Not Found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); btnDelete.Enabled = false; btnEnableDisable.Enabled = false; DGVReplicatorData.DataSource = null; } if (replicas.Count > 0) { ReplicaBL replicaBL = new ReplicaBL(); Thread t = new Thread(new ThreadStart(delegate { for (int i = 0; i < 100; i++) { this.Invoke((Action)delegate { foreach (Replica replicat in replicas) { if (replicat.BoolEnable) { replicaBL.CheckChangesReplica(replicat); } } }); Thread.Sleep(1000); } })); t.IsBackground = true; t.Start(); } }
/// <summary> /// This method insert on ReplicaManager Database /// </summary> /// <param name="replica"></param> public void InsertReplica(Replica replica) { ReplicaDA replicaDA = new ReplicaDA(); replicaDA.Insert(replica); }