コード例 #1
0
        private void onEnviar(object sender, EventArgs e)
        {
            try {
                Validate Validate = new Validate(this, ErrorProvider);

                Validate.AddRule(textNome, "Nome Completo", "required|max:100");
                Validate.AddRule(textCPF, "CPF", "required|cpf");
                Validate.AddRule(textRG, "RG", "numeric|max:12");
                Validate.AddRule(combStatus, "Status", "required|numeric|exact:1");
                Validate.AddRule(textCNH, "CNH", "numeric|max:12");
                Validate.AddRule(timeVencimentoCNH, "Vencimento", "date:dd/MM/yyyy");
                Validate.AddRule(combCategoriaCNH, "Categoria", "min:1|max:2");
                Validate.AddRule(combSexo, "Sexo", "required|in:h,m");
                Validate.AddRule(combEstadoCivil, "Estado Civil", "required|numeric|exact:1");
                Validate.AddRule(textCEP, "CEP", "cep");
                Validate.AddRule(textEndereco, "Endereco", "max:100");
                Validate.AddRule(textN, "Nº", "max:10");
                Validate.AddRule(textBairro, "Bairro", "max:60");
                Validate.AddRule(textComplemento, "Complemento", "max:100");
                Validate.AddRule(textCidade, "Cidade", "max:100");
                Validate.AddRule(combEstado, "Estado", "exact:2");
                Validate.AddRule(combCargo, "Cargo", "numeric|exact:1");
                Validate.AddRule(textTelefone, "Telefone", "telefone");
                Validate.AddRule(textCelular, "Celular", "telefone");
                Validate.AddRule(textEmail, "Email", "email|max:100");

                Validate.Validation();

                if (Validate.IsValid())
                {
                    Motoristas motoristas = new Motoristas();

                    motoristas.Nome        = textNome.Text;
                    motoristas.CPF         = textCPF.Text;
                    motoristas.RG          = textRG.Text;
                    motoristas.Status      = combStatus.SelectedValue;
                    motoristas.CNH         = textCNH.Text;
                    motoristas.Vencimento  = timeVencimentoCNH.Text;
                    motoristas.Categoria   = combCategoriaCNH.SelectedValue;
                    motoristas.Sexo        = combSexo.SelectedValue;
                    motoristas.EstadoCivil = combEstadoCivil.SelectedValue;
                    motoristas.CEP         = textCEP.Text;
                    motoristas.Endereco    = textEndereco.Text;
                    motoristas.N           = textN.Text;
                    motoristas.Bairro      = textBairro.Text;
                    motoristas.Complemento = textComplemento.Text;
                    motoristas.Cidade      = textCidade.Text;
                    motoristas.Estado      = combEstado.SelectedValue;
                    motoristas.Cargo       = combCargo.SelectedValue;
                    motoristas.Telefone    = textTelefone.Text;
                    motoristas.Celular     = textCelular.Text;
                    motoristas.Email       = textEmail.Text;

                    if (Id > 0)
                    {
                        motoristas.Id = Convert.ToInt32(Id);
                        motoristas.Update();
                    }
                    else
                    {
                        motoristas.Create();
                    }

                    if (motoristas.Success)
                    {
                        DialogResult SuccessBox = MessageBox.Show(motoristas.Message, "CADASTRADO");
                        if (SuccessBox == DialogResult.OK)
                        {
                            if (fmPrincipal != null)
                            {
                                fmPrincipal.AtivarForm(new TMSForms.List.FormMotoristas(fmPrincipal));
                            }
                            else
                            {
                                Close();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Houver um erro ao salvar o motorista (" + motoristas.Message + ")");
                    }
                }
                else
                {
                    Validate.ErrorProviderShow();
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
 private void OnClickCadastrar(object sender, EventArgs e)
 {
     fmPrincipal.AtivarForm(new TMSForms.Register.FormMultas(fmPrincipal));
 }
コード例 #3
0
        private void onEnviar(object sender, EventArgs e)
        {
            try {
                Validate Validate = new Validate(this, ErrorProvider);

                Validate.AddRule(textFrota, "Frota", "max:20");
                Validate.AddRule(textPlaca, "Placa", "required|placa");
                Validate.AddRule(combCategoria, "Categoria", "required|numeric|max:2");
                Validate.AddRule(combMarca, "Marca", "required|numeric|max:2");
                Validate.AddRule(combCarroceria, "Carroceria", "required|numeric|max:2");
                Validate.AddRule(textModelo, "Modelo", "required|max:50");
                Validate.AddRule(combCor, "Cor", "required|numeric|max:2");
                Validate.AddRule(combCombustivel, "Combustivel", "required|numeric|max:2");
                Validate.AddRule(textMotorizacao, "Motorizacao", "max:30");
                Validate.AddRule(textRenavam, "Renavam", "numeric|max:30");
                Validate.AddRule(textChassi, "Chassi", "required|max:30");
                Validate.AddRule(combAnoFabricacao, "Ano Fabricação", "required|numeric|date:yyyy");
                Validate.AddRule(combAnoModelo, "Ano Modelo", "required|numeric|date:yyyy");
                Validate.AddRule(combStatus, "Status", "required|numeric|max:2");
                Validate.AddRule(textTara, "Tara", "peso|max:20");
                Validate.AddRule(textLotacao, "Lotação", "peso|max:20");
                Validate.AddRule(textPesoBrutoTotal, "Peso Bruto Total", "peso|max:20");
                Validate.AddRule(textCapacidade, "Capacidade M³", "quantidade|max:20");

                Validate.Validation();

                if (Validate.IsValid())
                {
                    Veiculos veiculos = new Veiculos();

                    veiculos.Frota          = textFrota.Text;
                    veiculos.Placa          = textPlaca.Text;
                    veiculos.Categoria      = combCategoria.SelectedValue.ToString();
                    veiculos.Marca          = combMarca.SelectedValue.ToString();
                    veiculos.Carroceria     = combCarroceria.SelectedValue.ToString();
                    veiculos.Modelo         = textModelo.Text;
                    veiculos.Cor            = combCor.SelectedValue.ToString();
                    veiculos.Combustivel    = combCombustivel.SelectedValue.ToString();
                    veiculos.Motorizacao    = textMotorizacao.Text;
                    veiculos.Renavam        = textRenavam.Text;
                    veiculos.Chassi         = textChassi.Text;
                    veiculos.AnoFabricacao  = combAnoFabricacao.SelectedValue.ToString();
                    veiculos.AnoModelo      = combAnoModelo.SelectedValue.ToString();
                    veiculos.Status         = combStatus.SelectedValue.ToString();
                    veiculos.Tara           = textTara.Text;
                    veiculos.Lotacao        = textLotacao.Text;
                    veiculos.PesoBrutoTotal = textPesoBrutoTotal.Text;
                    veiculos.Capacidade     = textCapacidade.Text;

                    if (Id > 0)
                    {
                        veiculos.Id = Convert.ToInt32(Id);
                        veiculos.Update();
                    }
                    else
                    {
                        veiculos.Create();
                    }

                    if (veiculos.Success)
                    {
                        DialogResult SuccessBox = MessageBox.Show(veiculos.Message, "CADASTRADO");
                        if (SuccessBox == DialogResult.OK)
                        {
                            if (fmPrincipal != null)
                            {
                                fmPrincipal.AtivarForm(new TMSForms.List.FormVeiculos(fmPrincipal));
                            }
                            else
                            {
                                Close();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Houve um erro ao salvar o veiculo. (" + veiculos.Message + ")");
                    }
                }
                else
                {
                    Validate.ErrorProviderShow();
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #4
0
        private void onEnviar(object sender, EventArgs e)
        {
            try {
                Validate Validate = new Validate(this, ErrorProvider);

                Validate.AddRule(combTipoManutencao, "Tipo Manuteção", "required|numeric|exact:1");
                Validate.AddRule(combTipoPreventiva, "Tipo Preventiva", "numeric|exact:1");
                Validate.AddRule(combVeiculo, "Veiculo", "required|numeric|max:11");
                Validate.AddRule(combStatus, "Status", "required|numeric|exact:1");
                Validate.AddRule(combMotorista, "Motorista", "required|numeric|max:11");
                Validate.AddRule(timeDataAgendada, "Data Agendada", "required|date:dd/MM/yyyy HH:mm");
                Validate.AddRule(timeDataRealizada, "Data Realizada", "date:dd/MM/yyyy HH:mm");
                Validate.AddRule(textHodometroAgendado, "Hodômetro Agendado", "required|numeric|max:20");
                Validate.AddRule(textHodometroRealizado, "Hodômetro Realizado", "numeric|max:20");
                Validate.AddRule(textObservacoes, "Motivo/Observações", "max:1000");
                Validate.AddRule(textOrdemServico, "Ordem Servico", "max:20");
                Validate.AddRule(combFornecedor, "Concessionaria/Fornecedor", "numeric|max:11");
                Validate.AddRule(textMaoObra, "Mão de Obra", "reais|max:20");
                Validate.AddRule(textDesconto, "Desconto", "reais|max:20");
                Validate.AddRule(textAcrecimo, "Acrécimo", "reais|max:20");
                Validate.AddRule(textValor, "Valor Total", "reais|max:20");

                Validate.Validation();

                if (Validate.IsValid())
                {
                    PreencherJson();

                    Manutencoes manutencoes = new Manutencoes();

                    manutencoes.Tipo               = combTipoManutencao.SelectedValue;
                    manutencoes.Preventiva         = combTipoPreventiva.SelectedValue;
                    manutencoes.Veiculo            = combVeiculo.SelectedValue;
                    manutencoes.Status             = combStatus.SelectedValue;
                    manutencoes.Motorista          = combMotorista.SelectedValue;
                    manutencoes.DataAgendada       = timeDataAgendada.Text;
                    manutencoes.DataRealizada      = timeDataRealizada.Text;
                    manutencoes.HodometroAgendado  = textHodometroAgendado.Text;
                    manutencoes.HodometroRealizado = textHodometroRealizado.Text;
                    manutencoes.Observacoes        = textObservacoes.Text;
                    manutencoes.OrdemServico       = textOrdemServico.Text;
                    manutencoes.Fornecedor         = combFornecedor.SelectedValue;
                    manutencoes.MaoObra            = Converter.ToDecimal(textMaoObra.Text, true);
                    manutencoes.Desconto           = Converter.ToDecimal(textDesconto.Text, true);
                    manutencoes.Acrecimo           = Converter.ToDecimal(textAcrecimo.Text, true);
                    manutencoes.Valor              = Converter.ToDecimal(textValor.Text, true);
                    manutencoes.Itens              = jsonItens;

                    if (Id > 0)
                    {
                        manutencoes.Id = Convert.ToInt32(Id);
                        manutencoes.Update();
                    }
                    else
                    {
                        manutencoes.Create();
                    }

                    if (manutencoes.Success)
                    {
                        DialogResult SuccessBox = MessageBox.Show(manutencoes.Message, "CADASTRADO");
                        if (SuccessBox == DialogResult.OK)
                        {
                            if (fmPrincipal != null)
                            {
                                fmPrincipal.AtivarForm(new TMSForms.List.FormManutencoes(fmPrincipal));
                            }
                            else
                            {
                                Close();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Houve um erro ao salvar a manutenção (" + manutencoes.Message + ")");
                    }
                }
                else
                {
                    Validate.ErrorProviderShow();
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #5
0
        private void OnEnviar(object sender, EventArgs e)
        {
            try {
                Validate Validate = new Validate(this, ErrorProvider);

                Validate.AddRule(timeData, "Data", "required|date:dd/MM/yyyy HH:mm");
                Validate.AddRule(textCupom, "Cupom", "max:20");
                Validate.AddRule(combPosto, "Posto", "required|numeric|max:11");
                Validate.AddRule(combCombustivel, "Combustivel", "required|numeric|exact:1");
                Validate.AddRule(combVeiculo, "Veiculo", "numeric|max:11");
                Validate.AddRule(combMotorista, "Motorista", "numeric|max:11");
                Validate.AddRule(textHodometro, "Hodômetro", "numeric|max:22");
                Validate.AddRule(combStatus, "Status", "required|numeric|max:22");
                Validate.AddRule(textLitros, "Litros", "required|quantidade|max:11");
                Validate.AddRule(textValor, "Valor", "required|reais|max:11");
                Validate.AddRule(textTotal, "Total", "required|reais|max:11");

                Validate.Validation();

                if (Validate.IsValid())
                {
                    Abastecimentos abastecimentos = new Abastecimentos();

                    decimal total = (Convert.ToDecimal(textValor.Text) * Convert.ToDecimal(textLitros.Text));

                    abastecimentos.Data        = timeData.Text;
                    abastecimentos.Cupom       = textCupom.Text;
                    abastecimentos.Posto       = combPosto.SelectedValue;
                    abastecimentos.Combustivel = combCombustivel.SelectedValue;
                    abastecimentos.Veiculo     = combVeiculo.SelectedValue;
                    abastecimentos.Motorista   = combMotorista.SelectedValue;
                    abastecimentos.Hodometro   = textHodometro.Text;
                    abastecimentos.Status      = combStatus.SelectedValue;
                    abastecimentos.Litros      = Converter.ToDecimal(textLitros.Text, true);
                    abastecimentos.Valor       = Converter.ToDecimal(textValor.Text, true);
                    abastecimentos.Total       = Converter.ToDecimal(textTotal.Text, true);

                    if (Id > 0)
                    {
                        abastecimentos.Id = Convert.ToInt32(Id);
                        abastecimentos.Update();
                    }
                    else
                    {
                        abastecimentos.Create();
                    }

                    if (abastecimentos.Success)
                    {
                        DialogResult SuccessBox = MessageBox.Show(abastecimentos.Message, "CADASTRADO");
                        if (SuccessBox == DialogResult.OK)
                        {
                            if (fmPrincipal != null)
                            {
                                fmPrincipal.AtivarForm(new TMSForms.List.FormAbastecimentos(fmPrincipal));
                            }
                            else
                            {
                                Close();
                            }
                        }
                    }
                    else
                    {
                        throw new Exception("Houve um erro ao salvar o abastecimento (" + abastecimentos.Message + ")");
                    }
                }
                else
                {
                    Validate.ErrorProviderShow();
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #6
0
        private void OnEnviar(object sender, EventArgs e)
        {
            try {
                Validate Validate = new Validate(this, ErrorProvider);

                Validate.AddRule(textNome, "Nome", "required|max:30");
                Validate.AddRule(combTipo, "Tipo", "required|numeric|exact:1");
                Validate.AddRule(combCentroCusto, "Centro de Custo", "required|max:2");
                Validate.AddRule(combFormaPagamento, "Forma de Pagamento", "required|max:2");
                Validate.AddRule(combStatus, "Status", "required|numeric|exact:1");
                Validate.AddRule(timeDataEmissao, "Data Emissão", "required|data:dd/MM/yyyy");
                Validate.AddRule(timeDataVencimento, "Data Vencimento", "required|data:dd/MM/yyyy");
                Validate.AddRule(textValor, "Valor", "required|reais|max:11");
                Validate.AddRule(textDocumento, "Nº Document", "max:30");
                Validate.AddRule(combOcorrencia, "Ocorrencia", "required|numeric|exact:1");
                Validate.AddRule(textQtdParcelas, "Qtd. Parcelas", "required_if:combOcorrencia,2|max:3");
                Validate.Validation();

                if (Validate.IsValid())
                {
                    PreencherJson();

                    Connection.Financeiro financeiro = new Connection.Financeiro();

                    financeiro.Nome           = textNome.Text;
                    financeiro.Tipo           = combTipo.SelectedValue.ToString();
                    financeiro.Referencia     = Referencia;
                    financeiro.CentroCusto    = combCentroCusto.SelectedValue.ToString();
                    financeiro.FormaPagamento = combFormaPagamento.SelectedValue.ToString();
                    financeiro.Status         = combStatus.SelectedValue.ToString();
                    financeiro.DataEmissao    = timeDataEmissao.Text;
                    financeiro.DataVencimento = timeDataVencimento.Text;
                    financeiro.Valor          = Converter.ToDecimal(textValor.Text, true);
                    financeiro.Documento      = textDocumento.Text;
                    financeiro.Ocorrencia     = combOcorrencia.SelectedValue.ToString();
                    financeiro.QtdParcelas    = textQtdParcelas.Text;
                    financeiro.Parcelas       = jsonParcelas;

                    if (Id > 0)
                    {
                        financeiro.Id = Convert.ToInt32(Id);
                        financeiro.Update();
                    }
                    else
                    {
                        financeiro.Create();
                    }

                    if (financeiro.Success)
                    {
                        DialogResult SuccessBox = MessageBox.Show(financeiro.Message, "CADASTRADO");
                        if (SuccessBox == DialogResult.OK)
                        {
                            if (fmPrincipal != null)
                            {
                                fmPrincipal.AtivarForm(new TMSForms.List.FormFinanceiro(fmPrincipal));
                            }
                            else
                            {
                                Close();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Houve um erro ao salvar o financeiro (" + financeiro.Message + ")");
                    }
                }
                else
                {
                    Validate.ErrorProviderShow();
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #7
0
        private void OnEnviar(object sender, EventArgs e)
        {
            try {
                Validate Validate = new Validate(this, ErrorProvider);

                Validate.AddRule(combVeiculo, "Veiculo", "required|numeric|max:11");
                Validate.AddRule(combMotorista, "Motorista", "numeric|max:11");
                Validate.AddRule(combGravidade, "Gravidade", "required|numeric|exact:1");
                Validate.AddRule(combStatus, "Status", "required|numeric|exact:1");
                Validate.AddRule(timeDataOcorrencia, "Data Ocorrencia", "required|date:dd/MM/yyyy");
                Validate.AddRule(timeDataNotificacao, "Data Notificacao", "date:dd/MM/yyyy");
                Validate.AddRule(timeDataVencimento, "Data Vencimento", "date:dd/MM/yyyy");
                Validate.AddRule(textValor, "Valor", "reais|max:11");
                Validate.AddRule(textDescricao, "Descrição da Infração", "max:500");
                Validate.AddRule(textLocal, "Local da Infração", "max:500");

                Validate.Validation();

                if (Validate.IsValid())
                {
                    Multas multas = new Multas();

                    multas.Veiculo         = combVeiculo.SelectedValue;
                    multas.Motorista       = combMotorista.SelectedValue;
                    multas.Gravidade       = combGravidade.SelectedValue;
                    multas.Status          = combStatus.SelectedValue;
                    multas.DataOcorrencia  = timeDataOcorrencia.Text;
                    multas.DataNotificacao = timeDataNotificacao.Text;
                    multas.DataVencimento  = timeDataVencimento.Text;
                    multas.Valor           = Converter.ToDecimal(textValor.Text, true);
                    multas.Descricao       = textDescricao.Text;
                    multas.Local           = textLocal.Text;

                    if (Id > 0)
                    {
                        multas.Id = Convert.ToInt32(Id);
                        multas.Update();
                    }
                    else
                    {
                        multas.Create();
                    }

                    if (multas.Success)
                    {
                        DialogResult SuccessBox = MessageBox.Show(multas.Message, "CADASTRADO");
                        if (SuccessBox == DialogResult.OK)
                        {
                            if (fmPrincipal != null)
                            {
                                fmPrincipal.AtivarForm(new TMSForms.List.FormMultas(fmPrincipal));
                            }
                            else
                            {
                                Close();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Houver um erro ao salvar a multas (" + multas.Message + ")");
                    }
                }
                else
                {
                    Validate.ErrorProviderShow();
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #8
0
        private void OnSalvar(object sender, EventArgs e)
        {
            try {
                Validate Validate = new Validate(this, ErrorProvider);

                Validate.AddRule(combRemetente, "Remetente", "required|numeric|max:11");
                Validate.AddRule(combDestinatario, "Destinatario", "required|numeric|max:11");
                Validate.AddRule(combTomador, "Tomador", "required|numeric|exact:1");
                Validate.AddRule(textCodigoInterno, "Codigo Interno", "max:10");
                Validate.AddRule(combTipoViagem, "Tipo Viagem", "required|numeric|exact:1");
                Validate.AddRule(combVeiculo, "Veiculo", "required|numeric|max:11");
                Validate.AddRule(combReboque, "Reboque", "numeric|max:11");
                Validate.AddRule(combMotorista, "Motorista", "required|numeric|max:11");
                Validate.AddRule(textSaidaCidade, "Cidade Saida", "required|max:100");
                Validate.AddRule(combSaidaUF, "UF Saida", "required|exact:2");
                Validate.AddRule(textDestinoCidade, "Cidade Destino", "required|max:100");
                Validate.AddRule(combDestinoUF, "UF Destino", "required|exact:2");
                Validate.AddRule(combStatus, "Status", "required|numeric|exact:1");
                Validate.AddRule(timeDataSaida, "Data Saida", "required|date:dd/MM/yyyy HH:mm");
                Validate.AddRule(timeDataEntrega, "Data Entrega", "date:dd/MM/yyyy HH:mm");
                Validate.AddRule(timeDataEntrega, "Data Chegada", "date:dd/MM/yyyy HH:mm");
                Validate.AddRule(textHodometroSaida, "KM Saida", "numeric|max:20");
                Validate.AddRule(textHodometroEntrega, "KM Entrega", "numeric|max:20");
                Validate.AddRule(textHodometroChegada, "KM Chegada", "numeric|max:20");
                Validate.AddRule(textHodometroPercorrido, "KM Percorrido", "numeric|max:11");
                Validate.AddRule(textValor, "Valor do Frete", "reais|max:11");
                Validate.AddRule(textInformacoesComplementares, "Informações Complementares", "max:1000");

                Validate.Validation();

                if (Validate.IsValid())
                {
                    PreencherJson();

                    Viagens viagens = new Viagens();

                    viagens.Remetente           = combRemetente.SelectedValue;
                    viagens.Destinatario        = combDestinatario.SelectedValue;
                    viagens.Tomador             = combTomador.SelectedValue;
                    viagens.CodigoInterno       = textCodigoInterno.Text;
                    viagens.TipoViagem          = combTipoViagem.SelectedValue;
                    viagens.Veiculo             = combVeiculo.SelectedValue;
                    viagens.Reboque             = combTipoViagem.SelectedValue;
                    viagens.Motorista           = combMotorista.SelectedValue;
                    viagens.SaidaCidade         = textSaidaCidade.Text;
                    viagens.SaidaUF             = combSaidaUF.SelectedValue;
                    viagens.DestinoCidade       = textDestinoCidade.Text;
                    viagens.DestinoUF           = combDestinoUF.SelectedValue;
                    viagens.Status              = combStatus.SelectedValue;
                    viagens.DataSaida           = timeDataSaida.Text;
                    viagens.DataEntrega         = (timeDataEntrega.Checked ? timeDataEntrega.Text : string.Empty);
                    viagens.DataChegada         = (timeDataEntrega.Checked ? timeDataEntrega.Text : string.Empty);
                    viagens.HodometroSaida      = textHodometroSaida.Text;
                    viagens.HodometroEntrega    = textHodometroEntrega.Text;
                    viagens.HodometroChegada    = textHodometroChegada.Text;
                    viagens.HodometroPercorrido = textHodometroPercorrido.Text;
                    viagens.Valor = Converter.ToDecimal(textValor.Text, true);
                    viagens.InformacoesComplementares = textInformacoesComplementares.Text;
                    viagens.Cargas              = jsonCargas;
                    viagens.TotalCargas         = Convert.ToString(TotalCargas);
                    viagens.Custos              = jsonCustos;
                    viagens.TotalCustos         = Convert.ToString(TotalCustos);
                    viagens.Abastecimentos      = jsonAbastecimentos;
                    viagens.TotalAbastecimentos = Convert.ToString(TotalAbastecimentos);

                    if (Id > 0)
                    {
                        viagens.Id = Convert.ToInt32(Id);
                        viagens.Update();
                    }
                    else
                    {
                        viagens.Create();
                    }

                    if (viagens.Success)
                    {
                        DialogResult SuccessBox = MessageBox.Show(viagens.Message, "CADASTRADO");
                        if (SuccessBox == DialogResult.OK)
                        {
                            if (fmPrincipal != null)
                            {
                                fmPrincipal.AtivarForm(new TMSForms.List.FormViagens(fmPrincipal));
                            }
                            else
                            {
                                Close();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Houve um erro ao salvar a viagem. (" + viagens.Message + ")");
                    }
                }
                else
                {
                    Validate.ErrorProviderShow();
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #9
0
        private void onEnviar(object sender, EventArgs e)
        {
            try {
                Validate Validate = new Validate(this, ErrorProvider);

                Validate.AddRule(combTipoCadastro, "Tipo Cadastro", "required|in:C,F,A|exact:1");
                Validate.AddRule(combTipoPessoa, "Tipo Pessoa", "required|in:PF,PJ|exact:2");
                Validate.AddRule(textCNPJ, lblCNPJ.Text, "required|" + ((string)combTipoPessoa.SelectedValue == "PJ" ? "cnpj" : "cpf"));
                Validate.AddRule(textRazaoSocial, lblRazaoSocial.Text, "required|max:150");
                Validate.AddRule(textNomeFantasia, "Razão Social", "max:150");
                Validate.AddRule(textInscricaoMunicipal, lblInscricaoMunicipal.Text, "max:12");
                Validate.AddRule(textInscricaoEstadual, lblInscricaoEstadual.Text, "max:12");
                Validate.AddRule(textCEP, "CEP", "cep");
                Validate.AddRule(textEndereco, "Endereco", "max:100");
                Validate.AddRule(textN, "Nº", "max:10");
                Validate.AddRule(textBairro, "Bairro", "max:60");
                Validate.AddRule(textComplemento, "Complemento", "max:100");
                Validate.AddRule(textCidade, "Cidade", "max:100");
                Validate.AddRule(combEstado, "Estado", "exact:2");
                Validate.AddRule(textNome, "Contato Nome", "max:100");
                Validate.AddRule(textTelefone, "Telefone", "telefone");
                Validate.AddRule(textRamal, "Ramal", "numeric|max:10");
                Validate.AddRule(textCelular, "Celular", "telefone");
                Validate.AddRule(textEmail, "Email", "email|max:100");
                Validate.AddRule(textObservacoes, "Observações", "max:500");

                Validate.Validation();

                if (Validate.IsValid())
                {
                    Clientes clientes = new Clientes();

                    clientes.TipoCadastro       = combTipoCadastro.SelectedValue;
                    clientes.TipoPessoa         = combTipoPessoa.SelectedValue;
                    clientes.CNPJ               = textCNPJ.Text;
                    clientes.RazaoSocial        = textRazaoSocial.Text;
                    clientes.NomeFantasia       = textNomeFantasia.Text;
                    clientes.InscricaoMunicipal = textInscricaoMunicipal.Text;
                    clientes.InscricaoEstadual  = textInscricaoEstadual.Text;
                    clientes.Isento             = checkIsento.Checked;
                    clientes.CEP         = textCEP.Text;
                    clientes.Endereco    = textEndereco.Text;
                    clientes.N           = textN.Text;
                    clientes.Bairro      = textBairro.Text;
                    clientes.Complemento = textComplemento.Text;
                    clientes.Cidade      = textCidade.Text;
                    clientes.Estado      = combEstado.SelectedValue;
                    clientes.Nome        = textNome.Text;
                    clientes.Telefone    = textTelefone.Text;
                    clientes.Ramal       = textRamal.Text;
                    clientes.Celular     = textCelular.Text;
                    clientes.Email       = textEmail.Text;
                    clientes.Observacoes = textObservacoes.Text;

                    if (Id > 0)
                    {
                        clientes.Id = Convert.ToInt32(Id);
                        clientes.Update();
                    }
                    else
                    {
                        clientes.Create();
                    }

                    if (clientes.Success)
                    {
                        DialogResult SuccessBox = MessageBox.Show(clientes.Message, "CADASTRADO");
                        if (SuccessBox == DialogResult.OK)
                        {
                            if (fmPrincipal != null)
                            {
                                fmPrincipal.AtivarForm(new TMSForms.List.FormClientes(fmPrincipal));
                            }
                            else
                            {
                                Close();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Houve um erro ao salvar o cliente (" + clientes.Message + ")");
                    }
                }
                else
                {
                    Validate.ErrorProviderShow();
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }