Beispiel #1
0
        private void infoCliente_Load(object sender, EventArgs e)
        {
            CarSystem.Cliente cliente = new CarSystem.Cliente(_dados);

            cliente.getCliente(_pedido);

            txtNome.Text             = cliente.nome;
            txtPedido.Text           = cliente.contrato;
            txtProduto.Text          = cliente.produto;
            txtRenovacao.Text        = cliente.renovacao.ToString("dd/MM/yyyy");
            txtUltimoVencimento.Text = cliente.ultimoVencimento.ToString("dd/MM/yyyy");

            cliente = null;

            _dados.retornaDados         = true;
            _dados.Comandos.tipoComando = CommandType.StoredProcedure;

            _dados.Comandos.limpaParametros();

            _dados.Comandos.textoComando = "sgb..pro_SGB_getTodosDebitos";
            _dados.Comandos.adicionaParametro("@contrato", SqlDbType.VarChar, 10, _pedido);
            _dados.Comandos.adicionaParametro("@codigoRemessa", SqlDbType.Int, 4, _remessa.infoRemessa.codigoRemessa);

            _dados.execute();

            dgRemessa.DataSource = _dados.dsDados.Tables[0];
            dgDebitos.DataSource = _dados.dsDados.Tables[1];
        }
Beispiel #2
0
        private void inicializaObjetos()
        {
            string nomeFuncao = "geraBoletos.Boletos.inicializaObjetos";

            try
            {
                if (debitos == null)
                {
                    debitos = new CarSystem.Debitos.Debito(CarSystem.Tipos.tipoEmissao.Producao, dados);
                }

                if (cliente == null)
                {
                    cliente = new CarSystem.Cliente(dados);
                }

                if (boletos == null)
                {
                    boletos = new CarSystem.Boletos.Boleto(dados);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("(" + nomeFuncao + ")" + ex.Message);
            }
        }
        //private bool efetuaBloqueios(string contrato, bool isPerguntar)
        //{
        //    if ( txt_pedido.Text != "" )
        //        carregaListas("","","",txt_pedido.Text);
        //    if (isPerguntar)
        //        if (MessageBox.Show("Bloquear " + dg_Filtrados.Rows.Count.ToString() + " com o motivo " + cb_motivos.Text + "?", "Bloquear?",
        //                             MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
        //            return false;

        //    try
        //    {
        //        foreach (System.Windows.Forms.DataGridViewRow dgrLinha in dg_Filtrados.Rows)
        //            if (dgrLinha.Cells["contrato"].Value.ToString()!= null && dgrLinha.Cells["contrato"].Value.ToString() != "")
        //                remessa.efetuaBloqueio(dgrLinha.Cells["contrato"].Value.ToString(), CarSystem.Tipos.Converter.toBloqueiosDebito(Convert.ToInt32(cb_motivos.SelectedValue)));
        //    }
        //    catch
        //    {
        //        return false;
        //    }

        //    return true;
        //}
        #endregion
        private bool executaComandos(string comando, bool isPerguntar)
        {
            string contrato   = "";
            string nomeFuncao = "BloqueioBoletos.executaComandos";

            if (txt_pedido.Text != "")
            {
                carregaListas("", "", "", txt_pedido.Text);
            }

            comando = comando.ToUpper();

            try
            {
                foreach (DataGridViewRow dgrLinha in dg_Filtrados.Rows)
                {
                    contrato = dgrLinha.Cells["contrato"].Value.ToString();

                    if (contrato != null && contrato != "")
                    {
                        switch (comando)
                        {
                        case "ALT.VALOR":

                            if (isPerguntar)
                            {
                                if (MessageBox.Show(String.Format("Alterar valores do contrato {0}?", contrato), "Alterar?",
                                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                                {
                                    return(false);
                                }
                            }

                            double valor = Convert.ToDouble(Microsoft.VisualBasic.Interaction.InputBox("Qual o novo valor?", "Valores", "", 50, 50).Replace('.', ','));

                            if (remessa.alterarValor(contrato, valor))
                            {
                                MessageBox.Show(String.Format("Os valores do contrato {0}, foram alterados com sucesso!!", contrato),
                                                "Alteração de valores", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            else
                            {
                                MessageBox.Show(String.Format("Os valores do contrato {0}, não foram alterados!!", contrato),
                                                "Alteração de valores", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }

                            break;

                        case "BLOQUEAR":
                            if (isPerguntar)
                            {
                                if (MessageBox.Show(String.Format("{0} {1} com o motivo {2}?", comando, dg_Filtrados.Rows.Count, cb_motivos.Text), "Bloquear?",
                                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                                {
                                    return(false);
                                }
                            }

                            isPerguntar = false;
                            if (remessa.efetuaBloqueio(contrato, CarSystem.Tipos.Converter.toBloqueiosDebito(Convert.ToInt32(cb_motivos.SelectedValue)), cb_motivos.SelectedValue.ToString()))
                            {
                                tbCarregamento.Rows.Find(contrato).Delete();
                            }

                            break;

                        case "IMPRIMIR":
                            remessa.imprimeBoleto(contrato);
                            break;

                        case "PIM":
                            string            retorno;
                            CarSystem.Cliente cliente = new CarSystem.Cliente(remessa.dados);
                            cliente.getCliente(contrato);
                            cliente.ultimoVencimento = (System.DateTime)dgrLinha.Cells["primeiroVencimento"].Value;

                            /*
                             * try
                             * {
                             *  (new SolicitacoesSGB((CarSystem.BancoDados.Dados)remessa.dados, contrato, remessa.infoRemessa.dataEtapa)).ShowDialog(this);
                             * }
                             * catch
                             * { }
                             */
                            if (cliente.isPodeGerar(out retorno, remessa.infoRemessa.codigoRemessa))
                            {
                                remessa.efetuaBloqueio(contrato, CarSystem.Tipos.bloqueiosDebito.boletosImpressos, "BOLETOS IMPRESSOS");
                                if (!remessa.exportaDebitos(contrato))
                                {
                                    lbl_fundo.BackColor = System.Drawing.Color.Blue;
                                    MessageBox.Show("Cliente não atualizado!");
                                }
                                else
                                {
                                    lbl_fundo.BackColor = System.Drawing.Color.Green;
                                }
                            }
                            else
                            {
                                remessa.efetuaBloqueio(contrato, retorno);
                                lbl_fundo.BackColor = System.Drawing.Color.Red;
                                MessageBox.Show(String.Format("Separar: {0}", retorno));
                            }
                            txt_pedido.Text = "";
                            break;

                        case "EXPORTAR":

                            string diretorio = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Geracao\";
                            CarSystem.Utilidades.IO.Arquivo.isExisteDir(diretorio, true);

                            string arquivo = diretorio + @"EXP_" + remessa.infoRemessa.nomeRemessa + "_" + DateTime.Today.ToString("ddMMyyyy") + ".txt";

                            MessageBox.Show(String.Format("Arquivo: {0}", CarSystem.Utilidades.IO.Arquivo.gridTOtxt(arquivo, dg_Filtrados)));
                            return(true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("(" + nomeFuncao + ")" + ex.Message);
                return(false);
            }

            return(true);
        }