示例#1
0
        public bool CadastrarCliente(ViewModelCadastroCliente vm_cadastro_cliente)
        {
            bool retorno = false;

            try
            {
                this.connection.Open();

                this.command.CommandText = string.Format(@"INSERT INTO cliente 
                                           (nome,
                                            identidade,
                                            cpf,
                                            endereco,
                                            email,
                                            autorizacao,
                                            ultima_alteracao,
                                            responsavel) 
                                           VALUES 
                                           ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}')",
                                                         vm_cadastro_cliente.cadastro_cliente_nome,
                                                         vm_cadastro_cliente.cadastro_cliente_identidade,
                                                         vm_cadastro_cliente.cadastro_cliente_cpf,
                                                         vm_cadastro_cliente.cadastro_cliente_endereco,
                                                         vm_cadastro_cliente.cadastro_cliente_email,
                                                         vm_cadastro_cliente.cadastro_cliente_autorizacao,
                                                         BASE_CORE.ConvertDateBrToMySql(vm_cadastro_cliente.cadastro_cliente_ultima_alteracao.ToString()),
                                                         vm_cadastro_cliente.cadastro_cliente_responsavel
                                                         );
                int insert_retorno = command.ExecuteNonQuery();

                if (insert_retorno > 0)
                {
                    retorno = true;
                }


                this.connection.Close();
            }
            catch (Exception ex)
            {
                if (this.connection.State == System.Data.ConnectionState.Open)
                {
                    this.connection.Close();
                }
            }

            return(retorno);
        }
示例#2
0
        public JsonResult <bool> Cadastrar(ViewModelCadastroCliente vm_cadastro_cliente)
        {
            ClienteBusiness cliente_busines = new ClienteBusiness();

            return(Json(cliente_busines.CadastrarCliente(vm_cadastro_cliente)));
        }