public frmPenDrive(bool Atualizar, NovoCiclo novoCiclo, List <string> unidades, string equip, int nTrat) { InitializeComponent(); this.Atualizar = Atualizar; this.novoCiclo = novoCiclo; this.unidades = unidades; this.equip = equip; this.nTrat = nTrat; }
private void Novo_Click(object sender, EventArgs e) { principal.ParaAtualizacao(); NovoCiclo novoCiclo = new NovoCiclo(); novoCiclo.ShowDialog(this); CarregaCiclos(); principal.RetomaAtualizacao(); }
public frmPenDrive(bool Atualizar, FileInfo[] listaTratamentos, NovoCiclo novoCiclo, string unidade, string equip, int nTrat) { InitializeComponent(); this.Atualizar = Atualizar; this.listaTratamentos = listaTratamentos; this.novoCiclo = novoCiclo; this.unidade = unidade; this.equip = equip; this.nTrat = nTrat; }
private void inserir_Click(object sender, EventArgs e) { string binario = decimalParaBinario(Convert.ToInt32(dtgHistorico.SelectedRows[0].Cells[0].Value)); int numTrat1 = binarioParaDecimal(binario.Substring(0, 8)); int numTrat2 = binarioParaDecimal(binario.Substring(8, 8)); NovoCiclo novo = new NovoCiclo(numTrat1, numTrat2, this, cmbCRG.SelectedIndex); novo.ShowDialog(this); AtualizaUltimoEquipamento(cmbCRG.SelectedIndex + 1); ciclos.CarregaCiclos(); }
private void Alterar_Click(object sender, EventArgs e) { if (Atualizar.Text == "Atualizar") { var frmTipoCom = new frmSelecionarMeioComunicacao(); frmTipoCom.ShowDialog(this); var tipoCom = frmTipoCom.comunicacao; if (string.IsNullOrWhiteSpace(tipoCom)) { return; } MessageBox.Show(tipoCom); return; int[] atualizacao = ConfiguracaoDAO.RetornaAtualizacao(); Configuracao config = new Configuracao(); config.atualizacao = atualizacao[0]; if (config.atualizacao == 1) { var checados = DtgChecked(dtgAndamento); if (checados.Count > 0) { foreach (var item in checados) { var ciclo = CicloDAO.buscaCiclo(Convert.ToInt32(item.Cells[2].Value), Convert.ToInt32(item.Cells[1].Value)); var novoCiclo = new NovoCiclo(true, Convert.ToInt32(item.Cells[4].Value), ciclo, Convert.ToInt32(item.Cells[2].Value) - 1, false); novoCiclo.ShowDialog(this); } CarregaCiclos(); } else { MessageBox.Show("Não há nenhum ciclo selecionado!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information); } /*for (int i = 0; i < dtgAndamento.Rows.Count; i++) * { * var rows = dtgAndamento.Rows; * if ((bool) dtgAndamento.Rows[i].Cells[0].Value) * { * VO.Ciclos ciclo = CicloDAO.buscaCiclo(Convert.ToInt32(dtgAndamento.Rows[i].Cells[2].Value), * Convert.ToInt32(dtgAndamento.Rows[i].Cells[1].Value)); * NovoCiclo novoCiclo = new NovoCiclo(true,Convert.ToInt32(dtgAndamento.Rows[i].Cells[4].Value), * ciclo, Convert.ToInt32(dtgAndamento.Rows[i].Cells[2].Value) - 1, false); * novoCiclo.ShowDialog(this); * } * }*/ } } else { var checados = DtgChecked(dtgFinalizados); if (checados.Count > 0) { foreach (var item in checados) { var ciclo = CicloDAO.buscaCiclo(Convert.ToInt32(item.Cells[2].Value), Convert.ToInt32(item.Cells[1].Value)); var novoCiclo = new NovoCiclo(true, Convert.ToInt32(item.Cells[4].Value), ciclo, Convert.ToInt32(item.Cells[2].Value) - 1, false); novoCiclo.ShowDialog(this); } CarregaCiclos(); } else { MessageBox.Show("Não há nenhum ciclo selecionado!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void Alterar_Click(object sender, EventArgs e) { if (Atualizar.Text == "Atualizar") { var checados = DtgChecked(dtgAndamento); if (checados.Count == 0) { return; } var frmTipoCom = new frmSelecionarMeioComunicacao(0); frmTipoCom.ShowDialog(this); if (!frmTipoCom.Sucesso) { return; } var tipoCom = frmTipoCom.TipoComunicacao; if (string.IsNullOrWhiteSpace(tipoCom)) { return; } foreach (var item in checados) { var crg = Convert.ToInt32(item.Cells[2].Value); var nTrat = Convert.ToInt32(item.Cells[4].Value); if (tipoCom == "ONLINE") { var func = new funcaoAssincrona(() => SecagensBO.ReceberSecagem(0, crg, ConfiguracaoDAO.retornaPorta())); this.Enabled = false; frmCarregar = new Carregar(); frmCarregar.Show(this); var asyncResult = func.BeginInvoke((ar) => { }, null); while (asyncResult.IsCompleted == false) { Application.DoEvents(); Thread.Sleep(50); } frmCarregar.Invoke(new MethodInvoker(() => frmCarregar.Close())); var listaRetorno = func.EndInvoke(asyncResult); if (listaRetorno == null || listaRetorno.Count == 0) { MessageBox.Show("Não foi possível comunicar com o equipamento!", "Erro de comunicação", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Enabled = true; return; } var secagem = SecagensBO.DescriptografarSecagem(listaRetorno); if (secagem == null) { MessageBox.Show("Não foi possível carregar este ciclo!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Enabled = true; return; } secagem.ciclo.crg = crg; var status = SecagensBO.SalvarSecagem(true, secagem, this); if (status.Cancelado) { this.Enabled = true; return; } if (!status.Sucesso) { var msgs = string.Empty; foreach (var msg in ErrorHandler.GetAllErrors) { msgs += Environment.NewLine + msg.ErrorMessage; } MessageBox.Show( "Não foi possível salvar o ciclo " + secagem.ciclo.nTrat + "!" + Environment.NewLine + Environment.NewLine + "Detalhes: " + msgs, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Enabled = true; return; } MessageBox.Show( "Ciclo " + secagem.ciclo.nTrat + " " + (status.Salvo ? "salvo" : "atualizado") + " com sucesso!", "Sucesso!", MessageBoxButtons.OK, MessageBoxIcon.Information); CarregaCiclos(); Enabled = true; Activate(); } else { var frmPendrive = new frmPendriveList(crg, nTrat); frmPendrive.ShowDialog(this); var arquivo = frmPendrive.Arquivo; if (string.IsNullOrWhiteSpace(arquivo) || nTrat == -1 || crg == -1) { return; } var bytes = File.ReadAllBytes(arquivo); if (!bytes.Any()) { ErrorHandler.ThrowNew(0, "Arquivo inválido!"); goto Fim; } var secagem = SecagensBO.DescriptografarSecagem(bytes.ToList(), 1); if (secagem == null) { var msg = "Não foi possível carregar este ciclo!"; if (ErrorHandler.GetLastError != null) { msg += Environment.NewLine + Environment.NewLine + "Detalhes:" + Environment.NewLine + ErrorHandler.GetLastError.ErrorMessage; ErrorHandler.ClearErrors(); } MessageBox.Show(msg, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); goto Fim; } secagem.ciclo.crg = crg; var status = SecagensBO.SalvarSecagem(true, secagem); if (status.Sucesso) { MessageBox.Show("Ciclo " + secagem.ciclo.nTrat + " " + (status.Salvo ? "salvo" : "atualizado") + " com sucesso!", "Sucesso!", MessageBoxButtons.OK, MessageBoxIcon.Information); goto Fim; } var ultimoErro = ErrorHandler.GetLastError; if (ultimoErro != null) { MessageBox.Show(ultimoErro.ErrorMessage, ultimoErro.Identifier == 0 ? "Erro" : "Informação", MessageBoxButtons.OK, ultimoErro.Identifier == 0 ? MessageBoxIcon.Error : MessageBoxIcon.Information); goto Fim; } } Fim: Activate(); CarregaCiclos(); } } else { var checados = DtgChecked(dtgFinalizados); if (checados.Count > 0) { foreach (var item in checados) { var ciclo = CicloDAO.buscaCiclo(Convert.ToInt32(item.Cells[2].Value), Convert.ToInt32(item.Cells[1].Value)); var novoCiclo = new NovoCiclo(true, Convert.ToInt32(item.Cells[4].Value), ciclo, Convert.ToInt32(item.Cells[2].Value) - 1, false); novoCiclo.ShowDialog(this); } CarregaCiclos(); } else { MessageBox.Show("Não há nenhum ciclo selecionado!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }